From cdc67e80ac78d08aee04bbc55ece650579beba6c Mon Sep 17 00:00:00 2001 From: Jonas Kümmerlin Date: Fri, 19 Jun 2020 16:48:18 +0200 Subject: add functions for centering a toplevel window on the monitor --- alf/alfcompat.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'alf/alfcompat.cpp') 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; -- cgit v1.2.3