Reputation: 18171
I start my MFC dialog form on very top of windows.
BOOL StatusDlg::OnInitDialog()
{
...
SetWindowPos(&this->wndTopMost,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
...
}
Now it placed on left upper corner, and I need to place in the middle of screen center.
According MSDN :
BOOL WINAPI SetWindowPos(
_In_ HWND hWnd,
_In_opt_ HWND hWndInsertAfter,
_In_ int X,
_In_ int Y,
_In_ int cx,
_In_ int cy,
_In_ UINT uFlags
);
I can use X and Y coordinates, but in this case I suppose I need to know monitor resolution. I have feeling that somewhere should be function or flag JUST_SET_WINDOW_IN_CENTER. What is easy way to place window in the center?
Upvotes: 0
Views: 4398
Reputation: 3636
The easy way:
BOOL CAboutDlg::OnInitDialog()
{
CDialog::OnInitDialog();
CenterWindow();
return TRUE;
}
Upvotes: 5