Skip to content

Commit d70219c

Browse files
authored
Improve CVideoModeManager::GetCurrentAdapterRect
1 parent 9e62309 commit d70219c

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

Client/core/Graphics/CVideoModeManager.cpp

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -671,11 +671,29 @@ bool CVideoModeManager::GetRequiredDisplayResolution(int& iOutWidth, int& iOutHe
671671
///////////////////////////////////////////////////////////////
672672
bool CVideoModeManager::GetCurrentAdapterRect(LPRECT pOutRect)
673673
{
674-
MONITORINFOEX monitorInfo;
674+
if (!pOutRect)
675+
return false;
676+
677+
// Initialize to safe defaults
678+
pOutRect->left = 0;
679+
pOutRect->top = 0;
680+
pOutRect->right = 1024;
681+
pOutRect->bottom = 768;
682+
683+
if (!m_hCurrentMonitor)
684+
return false;
685+
686+
MONITORINFOEX monitorInfo{};
675687
monitorInfo.cbSize = sizeof(MONITORINFOEX);
676-
BOOL bResult = GetMonitorInfo(m_hCurrentMonitor, &monitorInfo);
677-
*pOutRect = monitorInfo.rcMonitor;
678-
return bResult != 0;
688+
689+
BOOL bResult = GetMonitorInfoA(m_hCurrentMonitor, &monitorInfo);
690+
if (bResult)
691+
{
692+
*pOutRect = monitorInfo.rcMonitor;
693+
return true;
694+
}
695+
696+
return false;
679697
}
680698

681699
///////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)