How can we center our MFC Dialog on the center of the screen ?

MFC provides one function named CenterWindow(); for accomplishing this task.
But CenterWindow() centers a window relative to its parent. You can set the position relative to the screen by calling another function before CenterWindow().
ie CWnd::GetDesktopWindow()

the code snippet is just like.

BOOL CTest11Dlg::OnInitDialog()
{
CDialog::OnInitDialog();
CWnd* pWnd = GetDesktopWindow();
CenterWindow(pWnd);
return TRUE
}

🙂

There is no limit to what you can imagine!
for https://vctipsplusplus.wordpress.com/
BijU

Advertisements