-
MFC: Clear Client Area
I am begginer with MFC im writing a small program where you can draw lines freely in the Client Area.. and i have a menu with only 1 option.. lol
Its "Clear" Its suppose to clear w/e the user has drawn..
right now i have it to post a WM_PAINT message but it doesn't seem to do anything... How ever if you do something to cause Windows to send a WM_PAINT message to the program it clears it..
for example when you drag another window over it, or when you resize it..
So how do i Clear the Client Area?
EDIT:
Forgot to mention im drawing something everytime WM_PAINT is called.. and thats whats causing it not to clear the Client area.. i tried without drawing anything and it works perfectly..
-
You could always paint via CClientDC. Instantiate a new CClientDC and pass in the view. Get the client area via GetClientRect().
Kuphryn
-
The short answer is InvalidateRect(hwnd,0,TRUE); in the handler for "Clear" menu option;
However you have other problems such as "How do I keep the window from clearing when I minimize or resize?" If you have the MS Visual studio, there is a MFC tutorial that comes with it called scribble which is a simple drawing tutorial like what you are doing. I'd recommend you work through it. I believe it's online to at msdn.