How to stop Explorer starting my application maximized?

£可爱£侵袭症+ 提交于 2019-12-01 09:19:28

My first thought was to turn off STARTF_USESHOWWINDOW in the PEB if the parent wanted me to start maximized but that is too nasty and undocumented so I have not tried that yet.


Preventing any kind of size change (which is OK for my application since it is just a "modal" dialog) sort of works:

case WM_WINDOWPOSCHANGING:
  ((WINDOWPOS*)lp)->flags |= SWP_NOSIZE;
  return true;

The problem is that the window position is still set to 0 x 0 like a maximized window.


A better solution seems to be to detect and correct the problem after WM_INITDIALOG:

case WM_INITDIALOG:
  PostMessage(hDlg, WM_APP, 0, 0);
  break;
case WM_APP:
  if (IsZoomed(hDlg)) ShowWindow(hDlg, SW_SHOWNOACTIVATE);
  break;

I am the proud owner of several HP Stream 7 tablets and I would like to add my 2 cents here. Microsoft has made an arbitrary decision that devices with screen sizes smaller than 8 inches will behave differently than the norm. A lot of users are somewhat aware of this, but unaware that this is where your problem originates.

Windows determines a screen's size by reading the EDID information from the screen, which contains sizing information in it, in centimeters.

If no sizing information is present in the EDID, or the sizing information is below Microsoft's arbitrarily chosen 8 inch threshold, you get this apparent misbehavior which is at the very least, aggrivating to those who notice it and don't want it.

The solution is to override the default driver for the monitor in Device Manager with one that informs Windows that the screen is in fact, 8 inches or larger.

To do so, you need to first read the EDID information from the registry with a tool such as Deltacast's E-EDID Editor (free, last time I checked), and modify the size values and save the modified file someplace you can find it.

After you have modified your EDID file and saved it, download Monitor Asset Manager from EnTech (also free) and use it to create an INF file.

Once the INF file has been created, you need to restart Windows with the Advanced settings menu and choose to Disable Driver Signing Enforcement, since the INF file you created won't be digitally signed. Once disabled, open Device Manager in Windows and update the driver for the monitor using the INF file you created. You will need to confirm that you do in fact want to install the unsigned driver file.

Reboot and Windows will now behave normally with the one catch that, the onscreen keyboard will now appear a different size and will have more options available.

Sadly, Microsoft can change this behavior in the future, so there is no guarantee that through the same flawed decision making process they used to implement this in the first place, they won't force it down our throats again, using a much more difficult to counteract method.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!