SW_MAXIMIZED and apps that can't be maximized

205 Views Asked by At

I am using ShellExecuteEx to launch applications from my own application. One feature of my application is that is allows apps that it launches to be maximized when they open ... this works fine 99% of the time because I can add the SW_SHOWMAXIMIZED flag to the nShow field in the SHELLEXECUTEINFO structure.

Now, there are some applications that do not allow themselves to be maximized (the maximize button in the title bar area is greyed out). Out of that set of applications, some -- like calc.exe -- will just ignore the SW_MAXIMIZE flag and launch at their default size. Unfortunately, other apps -- like charmap.exe -- manage to open maximized anyway (and just look weird because of it).

I am trying to decide if either (1) this is a bug in those particular applications that I have to live with, (2) there is something I can do better to stop this happening or (3) I need to come up with some non-obvious workaround. Any help appreciated.

   SHELLEXECUTEINFO info = { 0 };

   info.cbSize = sizeof(SHELLEXECUTEINFO);
   info.lpVerb = L"open";
   info.lpFile = appPathEx.c_str();
   info.nShow = SW_SHOWMAXIMIZED;
   info.fMask = SEE_MASK_DOENVSUBST |
                SEE_MASK_FLAG_NO_UI;

   BOOL ok = ShellExecuteEx(&info);
1

There are 1 best solutions below

0
On

MSDN: ShowWindow:

As noted in the discussion of the nCmdShow parameter, the nCmdShow value is ignored in the first call to ShowWindow if the program that launched the application specifies startup information in the structure.

But many programmers don't know about this feature, so it's a bug in these applications.