Hiding an MFC dialog box

后端 未结 3 1463
再見小時候
再見小時候 2021-02-06 12:50

Ok so I am using this code to hide the taskbar icon of a dialog based MFC application(VC++). The taskbar icon and the dialog box hide whenever I click on the cross or the close

3条回答
  •  庸人自扰
    2021-02-06 13:25

    I think Paul DiLascia recommended the following. This is for modal dialogs only.

    The following code can be put in OnInitDialog to move the dialog off-screen. You will need to implement a method for moving it back on-screen when appropriate.

    CRect DialogRect;
    GetWindowRect(&DialogRect);
    int DialogWidth = DialogRect.Width();
    int DialogHeight = DialogRect.Height();
    MoveWindow(0-DialogWidth, 0-DialogHeight, DialogWidth, DialogHeight);
    

    The answer from l33t looks good and is probably better but this is an alternative.

提交回复
热议问题