diff options
| author | Jonas Kümmerlin <jonas@kuemmerlin.eu> | 2020-06-19 16:48:18 +0200 |
|---|---|---|
| committer | Jonas Kümmerlin <jonas@kuemmerlin.eu> | 2020-06-19 16:48:18 +0200 |
| commit | cdc67e80ac78d08aee04bbc55ece650579beba6c (patch) | |
| tree | 13089be9354afbd6573ed001403dbdcf3423054e /alf/alfcompat.cpp | |
| parent | 253b9857e7b4317275b50795ddc53508e1cbd181 (diff) | |
add functions for centering a toplevel window on the monitor
Diffstat (limited to 'alf/alfcompat.cpp')
| -rw-r--r-- | alf/alfcompat.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/alf/alfcompat.cpp b/alf/alfcompat.cpp index 7b30eac..45f5f4a 100644 --- a/alf/alfcompat.cpp +++ b/alf/alfcompat.cpp @@ -492,6 +492,37 @@ ALF_Compat_fallbackLoadIconWithScaleDown(HINSTANCE hinst, return E_NOTIMPL; } +static BOOL WINAPI +ALF_Compat_fallbackGetMonitorInfoA(HMONITOR monitor, MONITORINFO *lpmi) +{ + if (monitor != (HMONITOR)0x12340042 || !lpmi || lpmi->cbSize != sizeof(MONITORINFO)) + return FALSE; + + lpmi->rcMonitor.left = 0; + lpmi->rcMonitor.top = 0; + lpmi->rcMonitor.right = GetSystemMetrics(SM_CXSCREEN); + lpmi->rcMonitor.bottom = GetSystemMetrics(SM_CYSCREEN); + SystemParametersInfoA(SPI_GETWORKAREA, 0, &lpmi->rcWork, 0); + lpmi->dwFlags = MONITORINFOF_PRIMARY; + return TRUE; +} + +static HMONITOR WINAPI ALF_Compat_fallbackMonitorFromPoint(POINT pt, DWORD flags) +{ + (void)pt; + (void)flags; + + return (HMONITOR)0x12340042; // like multimon.h +} + +static HMONITOR WINAPI ALF_Compat_fallbackMonitorFromWindow(HWND window, DWORD flags) +{ + (void)window; + (void)flags; + + return (HMONITOR)0x12340042; // like multimon.h +} + static BOOL CALLBACK ALF_Compat_DrawDisabledText_DrawStateProc(HDC hdc, @@ -603,6 +634,9 @@ void ALF_LoadCompatFunctions(void) LOAD_FUNC(user32, AdjustWindowRectExForDpi); LOAD_FUNC(user32, GetSystemMetricsForDpi); LOAD_FUNC(user32, SystemParametersInfoForDpi); + LOAD_FUNC(user32, GetMonitorInfoA); + LOAD_FUNC(user32, MonitorFromPoint); + LOAD_FUNC(user32, MonitorFromWindow); *((FARPROC*)&ALF_Compat_TrackMouseEvent) = GetProcAddress(_alf_dll_comctl32, "_TrackMouseEvent"); if (!ALF_Compat_TrackMouseEvent) @@ -761,3 +795,6 @@ HRESULT (WINAPI *ALF_Compat_GetThemeTransitionDuration)(HTHEME,int,int,int,int,D HRESULT (WINAPI *ALF_Compat_GetThemeColor)(HTHEME,int,int,int,COLORREF*) = NULL; HRESULT (WINAPI *ALF_Compat_GetThemeMargins)(HTHEME,HDC,int,int,int,const RECT *,MARGINS *) = NULL; HRESULT (WINAPI *ALF_Compat_LoadIconWithScaleDown)(HINSTANCE,PCWSTR,int,int,HICON *) = NULL; +BOOL (WINAPI *ALF_Compat_GetMonitorInfoA)(HMONITOR,MONITORINFO *) = NULL; +HMONITOR (WINAPI *ALF_Compat_MonitorFromPoint)(POINT,DWORD) = NULL; +HMONITOR (WINAPI *ALF_Compat_MonitorFromWindow)(HWND,DWORD) = NULL; |
