How to stop Explorer starting my application maximized?

前端 未结 2 809
借酒劲吻你
借酒劲吻你 2021-01-14 10:41

Explorer seems to always start my application with SW_MAXIMIZE (STARTF_USESHOWWINDOW is set in STARTUPINFO.dwFlags). I know that ShowWindow

2条回答
  •  青春惊慌失措
    2021-01-14 11:42

    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;
    

提交回复
热议问题