when centering a dialog to it's parent, shift as necessary to stay completely on the parent's screen

svn: r3362
This commit is contained in:
Matthew Flatt 2006-06-15 01:47:29 +00:00
parent 5875e0b1ce
commit f4ce1a8d31

View File

@ -84,7 +84,34 @@ void wxbDialogBox::Centre(int direction)
if (direction & wxVERTICAL)
y = (int)((display_height - height)/2);
SetSize(x+x_offset, y+y_offset, width, height);
x += x_offset;
y += y_offset;
if (frame) {
/* Stay completely on the frame's screen: */
HWND fw;
fw = frame->GetHWND();
if (fw) {
HMONITOR hm;
hm = MonitorFromWindow(fw, MONITOR_DEFAULTTOPRIMARY);
if (hm) {
MONITORINFO mi;
mi.cbSize = sizeof(mi);
if (GetMonitorInfo(hm, &mi)) {
if (x + width > mi.rcWork.right)
x = mi.rcWork.right - width;
if (x < mi.rcWork.left)
x = mi.rcWork.left;
if (y + height > mi.rcWork.bottom)
y = mi.rcWork.bottom - height;
if (y < mi.rcWork.top)
y = mi.rcWork.top;
}
}
}
}
SetSize(x, y, width, height);
}