tags:

views:

71

answers:

3
+1  Q: 

WM_SIZE message

Just by processing the WM_SIZE message, is it possible to know if the window was restored from a minimized state ?

A: 

Not directly from the current parameters.

But if you store the parameters passed to WM_SIZE every time you receive the message, then you just check whether the last parameter passed was a SIZE_MINIMIZED.

James Gaunt
I don't want to keep a static variable to catch the SIZE_MINIMIZED from a prior WM_SIZE.
jaayrosa
Notwithstanding your kind remarks, I have to say this is not THE ONLY way to do it, as Romain Hippeau showed below.
jaayrosa
Lol, I apologise for the tone... but the comment by Romain is the same as mine. As he confirms - you need to store the value last passed to WM_SIZE. Windows API does not store a history of WM_SIZE for you.
James Gaunt
@jaayrosa - James is right, you CANNOT know from the message alone unless you store the previous results from the last WM_SIZE. When you minimize you get a message with a wParam of SIZE_MINIMIZED at that point you need to save it, if the next message has a wParam of SIZE_RESTORED then you know you just came back from being minimized. I would not use statics if you have a lot of windows, instead use the private window data to put that in.
Romain Hippeau
A: 

No it is not -

wParam will be SIZE_RESTORED (0)
and lParam will have the new size of the window.

Unless you stored in the window when it was minimized, you will not be able to know when it is restored from this message alone.

Romain Hippeau
Are you sure about this ?
jaayrosa
@jaayrosa http://msdn.microsoft.com/en-us/library/ms632646(VS.85).aspx
Romain Hippeau
A: 

Will the GetWindowPlacement Function work?

Retrieves the show state and the restored, minimized, and maximized positions of the specified window.

JustBoo
This returns the current placement, so if you call it in the WM_SIZE handler it will just tell you what the WM_SIZE parameters are already telling you.
James Gaunt