Hi @Siji, Merlin ,
Thanks for reaching out.
I looked at the behavior you’re seeing with SW_SHOWMAXIMIZED on Windows 11 23H2 in a multi-monitor MFC setup. Specifically:
- When you call
ShowWindow(SW_SHOWMAXIMIZED)and then immediatelyMoveWindow, Windows may not always apply the maximized state to all monitors consistently. In Windows 10, this sequence often “just worked,” but Windows 11 is stricter about letting the system handle maximized window positioning. - Your current
if (nID == SC_RESTORE)check is also a bit fragile, it’s better to mask the lower bits like(nID & 0xFFF0) == SC_RESTOREto reliably catch restore messages.
I suggest a couple of approaches:
- Let the system handle maximization: Call
ShowWindow(SW_SHOWMAXIMIZED)for each window and avoid callingMoveWindowafterward. Windows will place the window on the correct monitor. - Reposition before maximizing: If you need precise positioning, call
MoveWindowfirst to set the bounds, then callShowWindow(SW_SHOWMAXIMIZED),which should ensure the window is maximized with the intended geometry.
Hope this helps! If my answer was helpful - kindly follow the instructions here so others with the same problem can benefit as well.