Invisible static control and window update hangs?
-
Hi! I recently made a invisible static control by overriding
CMyStatic::OnPaint()
and doing nothing there. Ouch. This does totally screw up the update of my parent window! When hiding the parent window (a dialog) through another window and get my dialog back on top of z-order, then all controls will be painted until my invisible control. All controls after my invisible control will not be repainted, I need to move the window to get them repainted. That's pretty strange. I can't call the base class memberCStatic::OnPaint()
, because then it wouldn't be invisible anymore. I tried a bit and added this as only line in my OnPaint() handler:CPaintDC dc(this);
Now window update works as usually. Can somebody explain what's happening? I really like to understand. Thanks :) -
Hi! I recently made a invisible static control by overriding
CMyStatic::OnPaint()
and doing nothing there. Ouch. This does totally screw up the update of my parent window! When hiding the parent window (a dialog) through another window and get my dialog back on top of z-order, then all controls will be painted until my invisible control. All controls after my invisible control will not be repainted, I need to move the window to get them repainted. That's pretty strange. I can't call the base class memberCStatic::OnPaint()
, because then it wouldn't be invisible anymore. I tried a bit and added this as only line in my OnPaint() handler:CPaintDC dc(this);
Now window update works as usually. Can somebody explain what's happening? I really like to understand. Thanks :)If you Invalidate() a window it will try to redraw itself at the next opportunity. Because your 'invisible' static control is hidden for a while it is automatically Invalidate()ed. So when it comes to draw it again, it still thinks it is Invalidate()ed. If you Validate() your static control rather than creating a DC from the window, it will also work. :confused:HOWEVER, why did you not just create the window without WS_VISIBLE set?
-
Hi! I recently made a invisible static control by overriding
CMyStatic::OnPaint()
and doing nothing there. Ouch. This does totally screw up the update of my parent window! When hiding the parent window (a dialog) through another window and get my dialog back on top of z-order, then all controls will be painted until my invisible control. All controls after my invisible control will not be repainted, I need to move the window to get them repainted. That's pretty strange. I can't call the base class memberCStatic::OnPaint()
, because then it wouldn't be invisible anymore. I tried a bit and added this as only line in my OnPaint() handler:CPaintDC dc(this);
Now window update works as usually. Can somebody explain what's happening? I really like to understand. Thanks :)u need to know a little win32 story. if u override WM_PAINT message, u must have min 2 lines to tell OS related info. the function CPaintDC dc(this) has these 2 lines inside. includeh10
-
If you Invalidate() a window it will try to redraw itself at the next opportunity. Because your 'invisible' static control is hidden for a while it is automatically Invalidate()ed. So when it comes to draw it again, it still thinks it is Invalidate()ed. If you Validate() your static control rather than creating a DC from the window, it will also work. :confused:HOWEVER, why did you not just create the window without WS_VISIBLE set?
ah thx for the good explanation, I remember from my Win32 experience. :) Mythago wrote: HOWEVER, why did you not just create the window without WS_VISIBLE set? I remake a splitter control, the splitter itself _can_ be "invisible". If I set the WS_VISIBLE style I can't get mouse messages and stuff anymore.
-
ah thx for the good explanation, I remember from my Win32 experience. :) Mythago wrote: HOWEVER, why did you not just create the window without WS_VISIBLE set? I remake a splitter control, the splitter itself _can_ be "invisible". If I set the WS_VISIBLE style I can't get mouse messages and stuff anymore.
-
btw, one more question: Is there a easier MFC solution to validate a client rect than calling
CPaintDC dc(this);
? Or does it already provide the mininum solution?