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:
parent
5875e0b1ce
commit
f4ce1a8d31
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user