I have a Windows application for which I want to save the window coordinates whenever the user resizes or moves it, except when those events are due to the window being minimized (the coordinates don't make sense then). My issue is that when the window gets minimized, the message WM_MOVE comes before WM_SIZE, and I can only detect minimization in the WM_SIZE case (using the test wParam == SIZE_MINIMIZED). Now I've noticed that the xy coordinates as given by GetWindowRect take the value -32000 in the minimized case, so I could test for that, but are those values reliable across different systems? Is there a better way?
Thank you!
SetWindowPlacement
/GetWindowPlacement
is the best way to restore/save window position.
If you absolutely don't want to remember the minimized state, if WINDOWPLACEMENT::showCmd
is SW_SHOWMINIMIZED
, change it to SW_SHOW
before calling SetWindowPlacement
.