MantisBT - Soldat
View Issue Details
0000128SoldatJohnpublic2011-11-01 00:312015-04-18 19:19
Mr 
 
normalminoralways
acknowledgedopen 
x64Windows7
1.6.2 
 
0000128: Config.exe always starts up on the primary screen
See summary
Suggested fix:

Use the cursor position or last active window to determine the active screen. This is a commonly used technique.

POINT point = { 0 };
MONITORINFO mi = { sizeof(MONITORINFO), 0 };
HMONITOR hMonitor = 0;
RECT rcArea = { 0 };

GetCursorPos(&point);
hMonitor = MonitorFromPoint(point, MONITOR_DEFAULTTONEAREST);
// hMonitor = MonitorFromWindow(GetForegroundWindow(), MONITOR_DEFAULTTONEAREST);

if(GetMonitorInfo(hMonitor, &mi))
{
    rcArea.left = (mi.rcMonitor.right + mi.rcMonitor.left - current_form_width) /2;
    rcArea.top = (mi.rcMonitor.top + mi.rcMonitor.bottom - current_form_height) /2;
}
else
{
    SystemParametersInfo(SPI_GETWORKAREA, NULL, &rcArea, NULL);
    rcArea.left = (rcArea.right + rcArea.left - current_form_width) / 2;
    rcArea.top = (rcArea.top + rcArea.bottom - current_form_height) / 2;
}

rcArea.left and rcArea.top will now contain the optimal startup position of your window.
No tags attached.
related to 0000523confirmed  Start screen not centered, error and config.exe not saving fullscreen setting 
Issue History
2011-11-01 00:31MrNew Issue
2012-03-01 02:06ShoozzaStatusnew => acknowledged
2015-04-15 23:00homerofgodsNote Added: 0002418
2015-04-18 19:19homerofgodsRelationship addedrelated to 0000523
2020-08-27 11:23MMCategoryGUI => John

Notes
(0002418)
homerofgods   
2015-04-15 23:00   
<@Shoozza> is this still a thing?
<@Shoozza> i remember fixing that some time ago

Mr is it fixed?