正在加载图片...
9单元 WINDOWS编程 afx msg void OnLBut tonDown ( UINT nFlags, CPoint point) DECLARE MESSAGE MAP O //消息映射 BEGIN MESSAGE MAP(CMyWnd, CFrameWnd ON WM LBUTTONDOWN O ON WM PAINTO END MESSAGE MAPO /框架窗口类的成员函数 void CMy Wnd:: OnLButtonDown (UINT nFlags, CPoint point) if(m nBubble Count MAX BUBBLE) int r= rand O%50+10 CRect rect(point x-r, point. y-r, point x+r, point y+r) m rectBubble [m nBubble Count]= rect m nBubbleCount++ InvalidateRect(rect, FALSE void CMyWnd: OnPainto CPaintDC dc(this dc. SelectStockObject (LTGRAY BRUSH) for(int i=0; i<m nUbble Count: i++) dc Ellipse(m rectBubble[il) /应用程序类 class CMy App: public CWinApp ablie BOOL InitInstance o //应用程序类的成员函数 ooL CMyApp: InitInstar CMy Wnd *kpFrame new CMyWnd第 9 单元 WINDOWS 编程 - 177 - afx_msg void OnLButtonDown(UINT nFlags, CPoint point); afx_msg void OnPaint(); DECLARE_MESSAGE_MAP() }; // 消息映射 BEGIN_MESSAGE_MAP(CMyWnd, CFrameWnd) ON_WM_LBUTTONDOWN() ON_WM_PAINT() END_MESSAGE_MAP() // 框架窗口类的成员函数 void CMyWnd::OnLButtonDown(UINT nFlags, CPoint point) { if(m_nBubbleCount < MAX_BUBBLE) { int r = rand()%50+10; CRect rect(point.x-r, point.y-r, point.x+r, point.y+r); m_rectBubble[m_nBubbleCount] = rect; m_nBubbleCount++; InvalidateRect(rect, FALSE); } } void CMyWnd::OnPaint() { CPaintDC dc(this); dc.SelectStockObject(LTGRAY_BRUSH); for(int i=0; i<m_nBubbleCount; i++) dc.Ellipse(m_rectBubble[i]); } // 应用程序类 class CMyApp: public CWinApp { public: BOOL InitInstance(); }; // 应用程序类的成员函数 BOOL CMyApp::InitInstance() { CMyWnd *pFrame = new CMyWnd;
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有