UpdateWindow()

Hi, could you explain to me what am i doing by putting:

UpdateWindow(hWindow);

Ive read some informatin on the internet but i dont quite follow it.

What does it do and whats its purpose?
closed account (zb0S216C)
It's best asking in the Windows Programming section for this.

Basically, it tells Windows which window to draw/display. It sends a WM_PAINT message to the window's procedure( which jumps in front of the message queue ). The single argument is the handle to the window you wish to draw.
Last edited on
Ok, you say "it tells Windows which window to draw/display"

But i thought this function does this:

ShowWindow(hWindow, iCmdShow);

???
Nope, ShowWindow makes the window visible. Or, to be more precise, it sets the visibility state of the window that hWindow is the handle to to iCmdShow.
closed account (zb0S216C)
iCmdShow

If this isn't of type HWND then you're wrong; the argument takes a HWND instance.

My post but re-phrased: It updates the client area of the given window( argument ). It still sends a WM_PAINT message to the front of the window's message queue.

Think I'm still wrong? Tell it to Microsoft.
Last edited on
Ok, just to double check:

ShowWindow() just gives the visibility state (whether its minimized or maximized and so on...)

UpdateWindow() displays the window (actually draws the windows on the screen)

?

closed account (zb0S216C)
ShowWindow( ) Determines how the window shall be shown. ( See the table for window display options: http://msdn.microsoft.com/en-us/library/ms633548(v=vs.85).aspx )

UpdateWindow( ) updates the client area of the given window( the argument is the handle to the window you want to update ). See here for information from Microsoft: http://msdn.microsoft.com/en-us/library/ms915501.aspx
when you say "updates the client area of the given window"

Is that just another way of saying it draws the window on the screen?
closed account (zb0S216C)
I'm sorry, I should have said this before. This image represents the client area: http://www.codemorphis.com/articles/tip1/window_client_area.jpg Where the red box is the client area of the window.
Last edited on
From what im understanding UpdateWindow() does infact DRAW the window on screen.

Correct?
closed account (zb0S216C)
Basically, yeah. However, it doesn't draw the border, caption, window button glyphs, etc...
Then what draws the border, caption, window button glyphs, etc...
Last edited on
Ive just been reading and ive come up with a new idea of what these two do:

ShowWindow() sets the "show-state". This function also DISPLAYS the window as we are setting the show state to a state which is displayed, so the window IS displayed because of this function.

UpdateWindow() does what it says on the tin. It updates the client area to make sure things such as strings and boxs are visible when the window is first created. Another thing which tells me that the updatewindow() does NOT display the window is that my application still displays if i remove the updatewindow().

Is this correct?

If so, why do need to make sure things such as strings and boxs are visible when the window is first created, why would they not be visible?
closed account (zb0S216C)
I think you might need to update the client area when you modify a static text element or something along those lines.

And yes, those descriptions look fine to me.
Thanks :D.

To sum up, showwindow is the one which actually displays the window, and updatewindow is the one which updates the client area for things like if ive modified a box
You don't really need to explicitly call UpdateWindow for the standard windows, like statics or pushbuttons, they do that themselves. Just do it once after calling ShowWindow.
closed account (zb0S216C)
like statics

If your static string changed, then you will need to update the client area. If nothing changes then there will be no need to update the client area. However, if you were creating custom elements, then you might have to update the client area. These are my thoughts, however.
Not really, if you call SetWindowText the controls handle themselves quite well.
Topic archived. No new replies allowed.