Cannot size window using STARTUPINFO
-
I would like my newly window to open up with the given sizes. The following code maximizes the window when it gets created. Why doesn't it work? Thanks! STARTUPINFO stStartUpInfo; PROCESS_INFORMATION pProcessInfo; memset(&stStartUpInfo, 0, sizeof(STARTUPINFO)); stStartUpInfo.cb = sizeof(STARTUPINFO); stStartUpInfo.dwFlags = STARTF_USESIZE; CreateProcess(NULL, CmdLine, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &stStartUpInfo, &pProcessInfo);
-
I would like my newly window to open up with the given sizes. The following code maximizes the window when it gets created. Why doesn't it work? Thanks! STARTUPINFO stStartUpInfo; PROCESS_INFORMATION pProcessInfo; memset(&stStartUpInfo, 0, sizeof(STARTUPINFO)); stStartUpInfo.cb = sizeof(STARTUPINFO); stStartUpInfo.dwFlags = STARTF_USESIZE; CreateProcess(NULL, CmdLine, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &stStartUpInfo, &pProcessInfo);
Look like the following is missing:
stStartUpInfo.wShowWindow = SW_MAXIMIZE;
Your code looks like it would show the window hidden as it memsets the struct to zero and 0 is SW_HIDE. Steve -
Look like the following is missing:
stStartUpInfo.wShowWindow = SW_MAXIMIZE;
Your code looks like it would show the window hidden as it memsets the struct to zero and 0 is SW_HIDE. SteveThe window does show up but it's maximized. That's not what I want. I want the window size to be set to what I defined for dwXSize and dwYSize .
-
The window does show up but it's maximized. That's not what I want. I want the window size to be set to what I defined for dwXSize and dwYSize .
Try this:
STARTUPINFO si; ZeroMemory(&si, sizeof(si)); si.cb sizeof(si); si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USEPOSITION | STARTF_USESIZE; si.wShowWindow = SW_SHOWNORMAL; si.dwX = 0; si.dwY = 0; si.dwXSize = 100; si.dwYSize = 100;
Steve
-
I would like my newly window to open up with the given sizes. The following code maximizes the window when it gets created. Why doesn't it work? Thanks! STARTUPINFO stStartUpInfo; PROCESS_INFORMATION pProcessInfo; memset(&stStartUpInfo, 0, sizeof(STARTUPINFO)); stStartUpInfo.cb = sizeof(STARTUPINFO); stStartUpInfo.dwFlags = STARTF_USESIZE; CreateProcess(NULL, CmdLine, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &stStartUpInfo, &pProcessInfo);
An application is free to ignore the values in the
STARTUPINFO
structure if it wants to.Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
-
Try this:
STARTUPINFO si; ZeroMemory(&si, sizeof(si)); si.cb sizeof(si); si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USEPOSITION | STARTF_USESIZE; si.wShowWindow = SW_SHOWNORMAL; si.dwX = 0; si.dwY = 0; si.dwXSize = 100; si.dwYSize = 100;
Steve
It still maximizes the window. Ryan (below) mentioned that application can ignore the STARTUPINFO struct if it wants to. So is there no way around this?
-
It still maximizes the window. Ryan (below) mentioned that application can ignore the STARTUPINFO struct if it wants to. So is there no way around this?
Before I started to look for ways around it I would verify the code with notepad (an application that respects it, I think) or something. I can't think of any easy way around it. You could install a
WM_CBT
hook with theSetWindowsHookEx
API but this would involve setting a global hook (and thus creating a DLL and taking care that it doesn't crash or effect other applications). Steve