Description
On Windows, when starting a process, there are options that can be configured on the initial window.
In a shortcut this looks like this:
And when creating a process with CreateProcess
, it can be specified in the PROCESS_INFORMATION
in the fields wShowWindow
and dwFlags
.
This maximizes a window even if the messagebox is not created maximized.
On a normal window (SDL_CreateWindow
) this does not seem to occur anymore (in SDL3, in SDL2 a normal window was affected as well).
Example code that reproduces:
int main(int argc, char* argv[])
{
SDL_MessageBoxButtonData buttons[2] = {};
buttons[0].buttonID = 0;
buttons[0].text = "Quit";
buttons[1].buttonID = 1;
buttons[1].text = "Maximized";
SDL_MessageBoxData mbdata = {};
mbdata.flags = SDL_MESSAGEBOX_INFORMATION;
mbdata.message = "Spawn the next window 'maximized' or quit:";
mbdata.title = "Example";
mbdata.numbuttons = _countof(buttons);
mbdata.buttons = buttons;
int button = -1;
SDL_ShowMessageBox(&mbdata, &button);
if (button == 1)
{
char buf[512];
GetModuleFileNameA(NULL, buf, _countof(buf));
STARTUPINFOA si = { sizeof(si) };
// The magic / bug:
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_MAXIMIZE;
PROCESS_INFORMATION pi = {};
if (CreateProcessA(buf, NULL, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
{
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
}
}
return 0;
}
Putty has a workaround for this:
https://github.com/KasperDeng/putty/blob/037a4ccb6e731fafc4cc77c0d16f80552fd69dce/putty-src/windows/windlg.c#L662
Should there be something in SDL that works around it, or is that already happening but not triggering for the messagebox?