Clearing client window
-
Using Visual C++ 6.0 MFC in SDI application Under certain conditions I want my OnDraw routine to display a blank window, instead of what was previously drawn there. When I use the InvalidateRect(0) function, the OnDraw gets called, but I am looking for some window function that will clear everything. How do I do that? Thanks
-
Using Visual C++ 6.0 MFC in SDI application Under certain conditions I want my OnDraw routine to display a blank window, instead of what was previously drawn there. When I use the InvalidateRect(0) function, the OnDraw gets called, but I am looking for some window function that will clear everything. How do I do that? Thanks
Why don't you put a flag in your OnDraw ()?
OnDraw ()
{
if (bBlank) //Nothing has to be drawn
return;Your Drawing code...
}
and bBlank = TRUE or FALSE as you need the blank window or not
Regards. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you “The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson Rating helpfull answers is nice, but saying thanks can be even nicer.
-
Why don't you put a flag in your OnDraw ()?
OnDraw ()
{
if (bBlank) //Nothing has to be drawn
return;Your Drawing code...
}
and bBlank = TRUE or FALSE as you need the blank window or not
Regards. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you “The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson Rating helpfull answers is nice, but saying thanks can be even nicer.
The problem was that I would set a flag for my OnDraw routine to do as you suggested, but in the function that set that flag I simply did flag = NOTDRAW; Invalidate(0); When I did this, with the OnDraw routine simply returning when it saw that flag, the old info in the client window would not be erased. When I changed things to Invalidate(0); flag = NOTDRAW; Invalidate(0); in the function that set the flag, then the old info in the client window would get erased. So I'm confused as to what is happening with the Invalidate(0) function.
-
The problem was that I would set a flag for my OnDraw routine to do as you suggested, but in the function that set that flag I simply did flag = NOTDRAW; Invalidate(0); When I did this, with the OnDraw routine simply returning when it saw that flag, the old info in the client window would not be erased. When I changed things to Invalidate(0); flag = NOTDRAW; Invalidate(0); in the function that set the flag, then the old info in the client window would get erased. So I'm confused as to what is happening with the Invalidate(0) function.
I am not sure why it happens. I usually use the Invalidate () without 0 and just afterwards an UpdateWindow (). It is supposed that Invalidate triggers the update, but I got used to that when I start coding in MFC because of some tutorials I used. The only problem with this is that depending on how much info is on the screen it can make it flick a bit.
Regards. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you “The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson Rating helpfull answers is nice, but saying thanks can be even nicer.
-
Using Visual C++ 6.0 MFC in SDI application Under certain conditions I want my OnDraw routine to display a blank window, instead of what was previously drawn there. When I use the InvalidateRect(0) function, the OnDraw gets called, but I am looking for some window function that will clear everything. How do I do that? Thanks
Kwanalouie wrote:
I am looking for some window function that will clear everything
Write a handler for
WM_ERASEBKGND
[^] /raviMy new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com