Task 1
1. Draw image, paint a section of a bmp image, implement animation(Tuesday).
Conclusion:
1, add a bmp to resource file.
right click top node in resource view->Add resource->bit map->import ...
2, Draw image. add following code in CView->OnDraw():
//Draw bitmap
CBitmap bitmap;
CDC dcMemory;
bitmap.LoadBitmapW(IDB_BITMAP1); //IDB_BITMAP1 IS id of the bitmap you added.
dcMemory.CreateCompatibleDC(pDC);
dcMemory.SelectObject(&bitmap);
pDC->BitBlt(100,100,12,22, &dcMemory, CMainFrame::image_x_index * 12,0,SRCCOPY)
3, about animation.
add a WM_TIMER EVENT to mainframe(otherwise there will be some problems) in class view -> properies. VS2008 will do following 3 steps:
a, add ON_WM_TIMER() to BEGIN_MESSAGE_MAP(XX,XX)
b, add declaration afx_msg void OnTimer(UINT_PTR nIDEvent); to Mainfram.h
c, add functon definition void CMainFrame::OnTimer(UINT_PTR nIDEvent) to Mainframe.cpp
you should do following steps to make a timer work.
1, in a function(such as in a on_lbuttondown() event call), call SetTimer(1, 1000,NULL) to start timer.
2, in function OnTimer(UINT_PTR nIDEvent) , add your code to do what you want to do when timer event comes.
To make animation alive, add code: this->invalidate() or this->RedrawWindow() in mainframe::OnTimer(nIDEvent).
Task 2
2.Click event detection:verify which area does the mouse clicked, and implement a toggle button.
Conclusion:
1, this task is so easy. nothing to say.
2, toggle button is so easy, i skipped it, is ok?