1
votes

Consider this situation:

  • on a multi-monitor system,
  • an application was maximized, then minimized,
  • in my application I have the HWND of the main window of above application

Now, how can I determine which monitor the window will show on when restored from minimized state? GetWindowRect and GetWindowInfo results in negative values, and apparently the same for all monitors. GetWindowPlacement gives good values in rcNormalPosition, but these are the coordinates the application returns to when un-maximized, which could be partly or wholly on another monitor.

1
I've never tried this, but doesn't WINDOWPLACEMENT.ptMaxPosition give you the answer? - arx
Nope, those hold the same negative values I get from GetWindowRect and GetWindowInfo - Stijn Sanders
Negative values doesn't mean that they're the wrong values. The virtual desktop contains points with negative coordinate values. - Cody Gray
If the negative values were different if the application is on either monitor, I would try to make sense of them. Since they're the same on both monitors, I don't think I could find what I'm searching there. - Stijn Sanders

1 Answers

2
votes

Try MonitorFromRect function with rcNormalPosition and MONITOR_DEFAULTTONEAREST flag. After that - call GetMonitorInfo to determine working monitor area.