W message loop:
case WM_SHOWWINDOW: CenterDialog(hDlg,GetParent(hDlg)); break;
no i implementacja:
void CenterDialog(HWND hDlg, HWND Parent)
{
RECT ParentRect,DlgRect;
GetWindowRect(Parent,&ParentRect);
GetWindowRect(hDlg,&DlgRect);
SetWindowPos(hDlg,HWND_TOP,
ParentRect.left+(ParentRect.right-ParentRect.left-(DlgRect.right-DlgRect.left))/2,
ParentRect.top+(ParentRect.bottom-ParentRect.top-(DlgRect.bottom-DlgRect.top))/2,
0,0,SWP_NOZORDER | SWP_NOSIZE );
};
Jak chcesz na srodku ekranu to daj jako parent desktop. I wsjo
.