What am i doing wrong?

Pages: 12
Well, adding to the update region...

And, is the update region by default set to null?
Last edited on
http://msdn.microsoft.com/en-us/library/dd145002(v=VS.85).aspx

http://msdn.microsoft.com/en-us/library/dd145167(v=VS.85).aspx

Basically, UpdateWindow() doesn't know anything has changed unless you InvalideRect() it.
Last edited on
Thanks, is the update region by default set to null?
I don't know if it is literally set to NULL, but I do know that if the client area of the window is empty then UpdateWindow() will return FALSE.

Again, you must understand that you are dealing with two DIFFERENT objects here.
thanks
Lamblion wrote:
UpdateWindow() merely updates the window attributes and corroborating sysmtem parameters.

Are you sure? This is what I read:
MSDN wrote:
The UpdateWindow function updates the client area of the specified window by sending a WM_PAINT message to the window if the window's update region is not empty. The function sends a WM_PAINT message directly to the window procedure of the specified window, bypassing the application queue. If the update region is empty, no message is sent.


Lamblion wrote:
InvalidateRect() erases and then redraws the specified rectangle within the window itself, assuming you've WM_PAINT or other such functions to do the redraw.

Or does it mark the rectangle for redrawing, and then leave the OS to have it redrawn:
MSDN wrote:
The invalidated areas accumulate in the update region until the region is processed when the next WM_PAINT message occurs or until the region is validated by using the ValidateRect or ValidateRgn function.

The system sends a WM_PAINT message to a window whenever its update region is not empty and there are no other messages in the application queue for that window.


Tporeilly wrote:
update region by default set to null?

NULL is a pointer thing, so I doubt the actual update region is set to NULL. However, I should guess it would be empty following a paint operation. Then it will remain empty until you invalidate it, or until the system invalidates it due to a resize or something.
Last edited on
My first statement is merely a basic paraphrase of what you read. If the window parameters aren't altered, then no message is sent, just like it says.

Again, my statement on InvalidateRect() is just a basic paraphrase of what happens, and it in no way contradicts the MSDN statement. . I had no intention of getting into techical step-by-step detail of exactly how it works.

That's why I suggested reading Petzold. InvalidateRect() must invalidate the specified rectangle and then send the appropriate message to Windows so that WM_PAINT or other such calls can then perform the desired action. No, InvalidateRect() doesn't actually do the redraw itself, and I didn't mean to to imply that in the statement, which is why I added the qualifier.

The best thing to do is read the MSDN links and follow the further links to understand the technical step-by-step actions that are performed, although even MSDN won't given you all of that info. You need Petzold and Richter and other outside sources for that.
This may help explain it. From Petzold --

"Your window procedure receives a WM_PAINT message ONLY if part of your client area is invalid." Petzold, p 74, 5th Edition Programming Windows

UpdateWindow() obviously does NOT invalidate any of the client area, and thus no new WM_PAINT message will be sent because Windows doesn't know that any parameters of the window have changed.
Last edited on
Thanks :)
UpdateWindow() will, of course, cause a WM_PAINT message to be dispatched if the update region is already non empty.

@Lamblion Fair enough. I think I misunderstood what you meant by "window parameters" :)
Well, I'm not the most solid person when it comes to programming terms, so "parameters" may not even be the right word, but it was the best I could do at the moment. -:)
Topic archived. No new replies allowed.
Pages: 12