Search code examples
mfccdialog

Create a CDialog in the corner of the screen


I have an MFC application that creates a CDialog. I'd like this CDialog to not show up in the middle of the screen, but rather off to the side of the screen so its barely visible or even minimized would be good.

How can I do this?


Solution

  • Use SetWindowPos in your OnInitDialog() function, like so:

    BOOL CDlg::OnInitDialog()
    {
        CDialog::OnInitDialog();
        // (x,y) is the upper-left corner in screen coordinates
        SetWindowPos( NULL, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER );
        return TRUE;
    }