centre on screen the dialogs without epxlicit position

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12682 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2001-11-25 14:59:25 +00:00
parent 835074fe0a
commit 4c53c74335

View File

@@ -252,8 +252,12 @@ bool wxTopLevelWindowMSW::CreateDialog(const wxChar *dlgTemplate,
// move the dialog to its initial position without forcing repainting // move the dialog to its initial position without forcing repainting
int x, y, w, h; int x, y, w, h;
if ( MSWGetCreateWindowCoords(pos, size, x, y, w, h) ) if ( !MSWGetCreateWindowCoords(pos, size, x, y, w, h) )
{ {
x =
w = (int)CW_USEDEFAULT;
}
// we can't use CW_USEDEFAULT here as we're not calling CreateWindow() // we can't use CW_USEDEFAULT here as we're not calling CreateWindow()
// and passing CW_USEDEFAULT to MoveWindow() results in resizing the // and passing CW_USEDEFAULT to MoveWindow() results in resizing the
// window to (0, 0) size which breaks quite a lot of things, e.g. the // window to (0, 0) size which breaks quite a lot of things, e.g. the
@@ -270,17 +274,17 @@ bool wxTopLevelWindowMSW::CreateDialog(const wxChar *dlgTemplate,
if ( x == (int)CW_USEDEFAULT ) if ( x == (int)CW_USEDEFAULT )
{ {
// well, where should we put it? maybe centre it on screen? // centre it on the screen - what else can we do?
x = wxSize sizeDpy = wxGetDisplaySize();
y = 0;
x = (sizeDpy.x - w) / 2;
y = (sizeDpy.y - h) / 2;
} }
if ( !::MoveWindow(GetHwnd(), x, y, w, h, FALSE) ) if ( !::MoveWindow(GetHwnd(), x, y, w, h, FALSE) )
{ {
wxLogLastError(wxT("MoveWindow")); wxLogLastError(wxT("MoveWindow"));
} }
}
//else: leave it at default position
if ( !title.empty() ) if ( !title.empty() )
{ {