Windows MessageBox ignoring WM_CLOSE

前端 未结 2 1958
别跟我提以往
别跟我提以往 2021-01-21 08:53

We\'ve got a legacy C Windows application which pops up a modal window via the MessageBox call when a fatal connection error occurs. Our network engineers may be running many of

2条回答
  •  鱼传尺愫
    2021-01-21 09:40

    Can be a tricky one this.

    Usually, to quit an windows application you have to quit the "Windows message loop". The easiest way to do this is to post a quit message, e.g. PostQuitMessage(retCode), where retCode is a value that your main message loop handler can process. Typically, zero, i.e. ignore.

    Typically, PostQuitMessage is posted in response to a WM_DESTROY message.

    It really depends on the legacy code, you have my sympathies, I am dealing with legacy code also. My code has a separate message loop and continually displays modal dialog boxes. Call EndDialog and calling PostQuitMessage(0) terminated my application correctly.

提交回复
热议问题