2

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);
  • 4
    I think you would have to class this as a bug in those applications, for not sanity checking the parameters they use to show their window. Presumably you'd get the same effect from a shortcut set to Maximize, so I don't think they could argue it's a fault with your program as such. – Jonathan Potter Jan 18 '14 at 00:59
  • I agree with @JonathanPotter - if you look at e.g. Calculator.exe with Spy++, you can examine the window styles and see that it doesn't have `WS_MAXIMIZEBOX`, so it's almost certainly *designed* not to be maximized. – Roger Rowland Jan 18 '14 at 06:50

1 Answers1

0

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.

qwm
  • 1,005
  • 8
  • 10