the study of programmng windows with mfc--timer
2010-08-02 11:33
489 查看
BEGIN_MESSAGE_MAP (CMainWindow, CFrameWnd) ON_WM_CREATE () ON_WM_TIMER () END_MESSAGE_MAP () int CMainWindow::OnCreate (LPCREATESTRUCT lpcs) { if (CFrameWnd::OnCreate (lpcs) == -1) return -1; if (!SetTimer (ID_TIMER_ELLIPSE, 100, NULL) ¦¦ !SetTimer (ID_TIMER_RECTANGLE, 100, NULL)) { MessageBox (_T ("Error: SetTimer failed")); return -1; } return 0; } void CMainWindow::OnTimer (UINT nTimerID) { CRect rect; GetClientRect (&rect); int x1 = rand () % rect.right; int x2 = rand () % rect.right; int y1 = rand () % rect.bottom; int y2 = rand () % rect.bottom; CClientDC dc (this); CBrush brush (RGB (rand () % 255, rand () % 255, rand () % 255)); CBrush* pOldBrush = dc.SelectObject (&brush); if (nTimerID == ID_TIMER_ELLIPSE) dc.Ellipse (min (x1, x2), min (y1, y2), max (x1, x2), max (y1, y2)); else // nTimerID == ID_TIMER_RECTANGLE dc.Rectangle (min (x1, x2), min (y1, y2), max (x1, x2), max (y1, y2)); dc.SelectObject (pOldBrush); }
相关文章推荐
- The study of Programming Windows with MFC-printing tips
- The study of chapter 13 in programming windows with mfc-printing with document and views
- The study of Programming Windows with MFC--Common Control
- The study of Programming Windows with MFC--CRgn
- The study of Programming Windows with MFC--Ip Address control and Date control
- The Study of Programming Windows with MFC--Imagelist and ComboBoxEx
- The Study of Programming Windows with MFC--Slider,Spin,ToolTip
- The study of Programming Windows with MFC
- The study of Programming Windows with MFC--print's example
- The study of Programming Windows with MFC-Palette
- The Study of Programming Windows with MFC--Progress and Animate control
- The study of Programming Windows with MFC--BitMap
- The Study of Programming Windows with MFC--Bitmap2
- Python——Windows安装Python出现A program run as part of the setup did not finish as expected的解决办法
- Description of the default C and C++ libraries that a program will link with when built by using Vis
- 【redis启动失败】he Windows version of Redis allocates a memory mapped heap for sharing with the forked pr
- WinFX Workflow:Simplify Development With The Declarative Model Of Windows Workflow Foundation. From Don Box & Dharma Shukla
- Discussing the scenery in the program of 863 with Doctor Zhang!
- windows安装python出现A program run as part of the setup did not finish as expected 的解决办法
- 遗传算法—Survival of the Fittest: Natural Selection with Windows Forms