Explorer seems to always start my application with SW_MAXIMIZE
(STARTF_USESHOWWINDOW
is set in STARTUPINFO.dwFlags
). I know that ShowWindow
will use this value the first time you/Windows needs to display a window but it has the unfortunate consequence of maximizing a window that should never be maximized.
My window is created with CreateDialogIndirectParam
and has the following styles: WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_CLIPCHILDREN|DS_MODALFRAME|DS_CENTER|WS_VISIBLE
. Why does ShowWindow
not check if WS_MAXIMIZEBOX
is set before allowing STARTF_USESHOWWINDOW
to force SW_MAXIMIZE
? Is this a bug in Windows?
This happens on a HP Stream 7 with Windows 8.1. I'm not sure if Explorer does this because it is touch enabled or because of the small screen.
Is this Explorer behavior documented anywhere and is there a way to turn it off? What is the best way to stop Explorer (or any other parent process) from affecting my initial window mode? (I don't want to block people starting me with SW_*MINIMIZE*
)
WinVer.exe in system32 has the same problem:
cmd.exe /c start /MAX c:\myapp.exe
also has the same issue... – StreetwalkerShowWindow
twice in a row would produce the result you are looking for. – PungShowWindow
where it will also maximize non-maximizable windows if the startup info saysSW_MAXIMIZE
. Sorry. You can work around this by detecting that somebody is trying to launch your app maximized (GetStartupInfo
) and creating a dummy window first (that will eat the bogus Maximize.) – Vesicate