Dacă se utilizează mai mult de un monitor la deschiderea clientului, împărtășesc aranjamentul care va asigura că se deschide întotdeauna pe orice monitor pe care a fost rulat în loc de monitorul principal.
Cod:
UserInterface/PythonApplication.cpp
cauta:
bAnotherWindow = true;
adauga sub:
HWND hForegroundWnd = GetForegroundWindow();
HMONITOR hActiveMonitor = NULL;
// Get monitor from foreground window
if (hForegroundWnd)
hActiveMonitor = MonitorFromWindow(hForegroundWnd, MONITOR_DEFAULTTOPRIMARY);
else // Fallback to primary monitor
hActiveMonitor = MonitorFromWindow(NULL, MONITOR_DEFAULTTOPRIMARY);
---
cauta:
if (bAnotherWindow)
{
RECT rc;
GetClientRect(&rc);
int windowWidth = rc.right - rc.left;
int windowHeight = (rc.bottom - rc.top);
CMSApplication::SetPosition(GetScreenWidth() - windowWidth, GetScreenHeight() - 60 - windowHeight);
}
schimba:
// Get monitor info
MONITORINFO monitorInfo;
monitorInfo.cbSize = sizeof(MONITORINFO);
GetMonitorInfo(hActiveMonitor, &monitorInfo);
RECT workArea = monitorInfo.rcWork;
uint32_t workAreaWidth = (workArea.right - workArea.left);
uint32_t workAreaHeight = (workArea.bottom - workArea.top);
uint32_t windowWidth = m_pySystem.GetWidth() + GetSystemMetrics(SM_CXBORDER) * 2 + GetSystemMetrics(SM_CXDLGFRAME) * 2 + GetSystemMetrics(SM_CXFRAME) * 2;
uint32_t windowHeight = m_pySystem.GetHeight() + GetSystemMetrics(SM_CYBORDER) * 2 + GetSystemMetrics(SM_CYDLGFRAME) * 2 + GetSystemMetrics(SM_CYFRAME) * 2 + GetSystemMetrics(SM_CYCAPTION);
// Calculate position relative to active monitor's work area
uint32_t x = workArea.left + (workAreaWidth / 2 - windowWidth / 2);
uint32_t y = workArea.top + (workAreaHeight / 2 - windowHeight / 2);
SetPosition(x, y);