mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 08:25:03 +00:00
[ATL] Fix window position to fit in screen area (#4512)
Clicking "Edit compatibility modes" button in the "Compatibility" tab opens a window centered on the parent window. If we move the parent window to one of the screen edges and then click this button again, the new window will appear off screen. Adjust position of created window, so now it would be completely visible. CORE-17089 Reviewed-by: Mark Jansen <mark.jansen@reactos.org> Reviewed-by: Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
This commit is contained in:
parent
d7f75a88ea
commit
e215a088f9
1 changed files with 30 additions and 2 deletions
|
@ -320,9 +320,37 @@ public:
|
|||
int wndCenterHeight = wndCenterRect.bottom - wndCenterRect.top;
|
||||
int wndWidth = wndRect.right - wndRect.left;
|
||||
int wndHeight = wndRect.bottom - wndRect.top;
|
||||
int xPos = wndCenterRect.left + ((wndCenterWidth - wndWidth + 1) >> 1);
|
||||
int yPos = wndCenterRect.top + ((wndCenterHeight - wndHeight + 1) >> 1);
|
||||
|
||||
if (!(::GetWindowLong(hWndCenter, GWL_STYLE) & WS_CHILD))
|
||||
{
|
||||
MONITORINFO mi;
|
||||
mi.cbSize = sizeof(mi);
|
||||
HMONITOR hMonitor = MonitorFromWindow(hWndCenter, MONITOR_DEFAULTTOPRIMARY);
|
||||
GetMonitorInfo(hMonitor, &mi);
|
||||
|
||||
if (xPos + wndWidth > mi.rcWork.right)
|
||||
{
|
||||
xPos = mi.rcWork.right - wndWidth;
|
||||
}
|
||||
else if (xPos < mi.rcWork.left)
|
||||
{
|
||||
xPos = mi.rcWork.left;
|
||||
}
|
||||
|
||||
if (yPos + wndHeight > mi.rcWork.bottom)
|
||||
{
|
||||
yPos = mi.rcWork.bottom - wndHeight;
|
||||
}
|
||||
if (yPos < mi.rcWork.top)
|
||||
{
|
||||
yPos = mi.rcWork.top;
|
||||
}
|
||||
}
|
||||
return ::MoveWindow(m_hWnd,
|
||||
wndCenterRect.left + ((wndCenterWidth - wndWidth + 1) >> 1),
|
||||
wndCenterRect.top + ((wndCenterHeight - wndHeight + 1) >> 1),
|
||||
xPos,
|
||||
yPos,
|
||||
wndWidth, wndHeight, TRUE);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue