-
June 20th, 2011, 08:38 PM
#1
Refreshing region outside client area.
I have a window, and as part of an internal diagnostic, I frame a region around it. I have a CRgn member, and whenever my window receives the WM_PAINT message, I create a CWindowDC given the Desktop window and call FrameRgn on it. This part works fine. However when my window goes away, I want to invalidate and repaint the region to remove the frame from the windows I painted over. I can't seem to figure out how to do this since the InvalidateRgn and Update API methods all take an HWND. In this case, I don't have an HWND, I just have an HRGN on the screen. What's the best way to invalidate this region without knowing what windows intersect it? Thanks!
-
June 20th, 2011, 10:01 PM
#2
Re: Refreshing region outside client area.
I was able to find a way to do it by enumerating all top-level windows (EnumWindows) and seeing if the region intersected with each window. If so, invalidate and redraw that window (as long as its visible). While this seems to work, it's not ideal. Is there a better way?
-
June 21st, 2011, 02:01 AM
#3
Re: Refreshing region outside client area.
What is wrong with this solution?
What should be better?
-
June 21st, 2011, 08:44 AM
#4
Re: Refreshing region outside client area.
I was hoping you could just pass NULL as the 'hWnd' into InvalidateRgn or something, and the Win32API would invalidate all windows that intersect the given region. It just seems like there should be a single API for doing this rather than having to enumerate all the top-level windows. Seems like a hack to me.
-
June 21st, 2011, 09:50 AM
#5
Re: Refreshing region outside client area.
The MSDN says:
Originally Posted by MSDN
A handle to the window whose update region has changed. If this parameter is NULL, the system invalidates and redraws all windows, not just the windows for this application, and sends the WM_ERASEBKGND and WM_NCPAINT messages before the function returns. Setting this parameter to NULL is not recommended.
To try it out I did the following:
Code:
HWND hWnd = ::GetDesktopWindow();
if (hWnd)
{
::InvalidateRect(hWnd, NULL, TRUE);
::SendMessage(hWnd, WM_PAINT, 0, 0);
}
and it didn't work (no flickering of my great IDE occured)
But the MSDN indeed is right:
Code:
::InvalidateRect(NULL, NULL, TRUE);
worked.
So you shouldn't set the HWND param of InvalidateRect to the handle of the desktop window, but instead set it to NULL.
I don't knwo exactly how mean I'm since I'm doing something "not recommended"..., but it worked.
regards
PA
-
June 21st, 2011, 12:36 PM
#6
Re: Refreshing region outside client area.
I do lots of things that aren't recommended, so what's one more? =) Thanks for your assistance, ProgramArtist.
-
June 21st, 2011, 12:44 PM
#7
Re: Refreshing region outside client area.
So it looks like the appilication windows aren't all children of the desktop window. Instead, the desktop is just some sort of another application window, invariably lying below all the others in the Z order.
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|