Archived

This topic is now archived and is closed to further replies.

boxdot3

Redrawing the Window

Recommended Posts

boxdot3    242
Whenever i draw text onto the screen in windows, the text doesnt appear until i minimize then maximize... Whats the command to redraw or refresh the window? later... Simon

Share this post


Link to post
Share on other sites
Daishim    244
Are you drawing the text in an event or is your program on hold until an event?



I know only that which I know, but I do not know what I know.

Share this post


Link to post
Share on other sites
boxdot3    242
Whenever WM_PAINT is called i call Paint(), and whenever WM_KEYDOWN is called i call Paint().

Does that help any?

Thanx for the help

Simon

Share this post


Link to post
Share on other sites
IndirectX    122
You may be drawing into an area that isn''t included in the clipping region. How are you acquiring your device context? BeginPaint() will AFAIK only allow you to draw to the ''dirty'' area of your window (the part of it that needs repainting). Use GetDC to get a DC for all client area.

Share this post


Link to post
Share on other sites
merlin9x9    174
Windows uses an internal list of "dirty" regions to determine where and when it needs to repaint a window. So, a WM_PAINT only gets sent when there''s at least one "dirty" region. These can be created automatically when, say, when a window is dragged in front of yours. They can also be created manually. Use the InvalidateRect or InvalidateRgn function, specifying NULL for the rectangle or region (respectively) to tell Windows that the entire client area of your window is "dirty." That''s all you have to do. Now, make sure you never call WM_PAINT (in any of its variants) directly. Do it the way I just mentioned. Also, in your WM_PAINT handler, if you''re using BeginPaint and EndPaint to obtain the device context you''re all good to go. But if you''re using a mechanism such as GetDC you have to make sure that you "validate" the region you painted, otherwise Windows will think that the region is still dirty and WM_PAINT will keep getting sent--your app will be dog slow. So, just call ValidateRect or ValidateRgn, again with NULL to tell Windows that the client area is "clean."

Share this post


Link to post
Share on other sites