From f4ce1a8d31fb66f5689b00670350f190cb61285d Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Thu, 15 Jun 2006 01:47:29 +0000 Subject: [PATCH] when centering a dialog to it's parent, shift as necessary to stay completely on the parent's screen svn: r3362 --- src/wxwindow/src/base/wb_dialg.cxx | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/wxwindow/src/base/wb_dialg.cxx b/src/wxwindow/src/base/wb_dialg.cxx index e7ba247c16..7e0e0e42d3 100644 --- a/src/wxwindow/src/base/wb_dialg.cxx +++ b/src/wxwindow/src/base/wb_dialg.cxx @@ -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); }