Windows 编程实例删除泡泡

时间:2012-01-23 16:28:48
【文件属性】:

文件名称:Windows 编程实例删除泡泡

文件大小:33KB

文件格式:DOC

更新时间:2012-01-23 16:28:48

编程

// MyView.cpp : implementation of the CMyView class // #include "stdafx.h" #include "My.h" #include "MyDoc.h" #include "MyView.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CMyView IMPLEMENT_DYNCREATE(CMyView, CView) BEGIN_MESSAGE_MAP(CMyView, CView) //{{AFX_MSG_MAP(CMyView) ON_WM_LBUTTONDOWN() ON_WM_RBUTTONDOWN() //}}AFX_MSG_MAP // Standard printing commands ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint) ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint) ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CMyView construction/destruction CMyView::CMyView() { // TODO: add construction code here } CMyView::~CMyView() { } BOOL CMyView::PreCreateWindow(CREATESTRUCT& cs) { // TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs return CView::PreCreateWindow(cs); } ///////////////////////////////////////////////////////////////////////////// // CMyView drawing void CMyView::OnDraw(CDC* pDC) { CMyDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); // TODO: add draw code for native data here for(int i=0; im_nBubbleCount; i++) pDC->Ellipse(pDoc->m_rectBubble[i]); } ///////////////////////////////////////////////////////////////////////////// // CMyView printing BOOL CMyView::OnPreparePrinting(CPrintInfo* pInfo) { // default preparation return DoPreparePrinting(pInfo); } void CMyView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) { // TODO: add extra initialization before printing } void CMyView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) { // TODO: add cleanup after printing } ///////////////////////////////////////////////////////////////////////////// // CMyView diagnostics #ifdef _DEBUG void CMyView::AssertValid() const { CView::AssertValid(); } void CMyView::Dump(CDumpContext& dc) const { CView::Dump(dc); } CMyDoc* CMyView::GetDocument() // non-debug version is inline { ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMyDoc))); return (CMyDoc*)m_pDocument; } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CMyView message handlers void CMyView::OnLButtonDown(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default CMyDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); if(pDoc->m_nBubbleCount < MAX_BUBBLE) { int r = rand()%50+10; CRect rect(point.x-r, point.y-r, point.x+r, point.y+r); pDoc->m_rectBubble[pDoc->m_nBubbleCount] = rect; pDoc->m_nBubbleCount++; InvalidateRect(rect, FALSE); } CView::OnLButtonDown(nFlags, point); } void CMyView::OnRButtonDown(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default CMyDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); CRect rect; rect=pDoc->m_rectBubble[pDoc->m_nBubbleCount] ; pDoc->m_nBubbleCount--; InvalidateRect(rect, TRUE); CView::OnRButtonDown(nFlags, point); }


网友评论

  • 一般般,资源积分有点高