diff options
Diffstat (limited to 'win32/PlatWin.cxx')
| -rw-r--r-- | win32/PlatWin.cxx | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index b125bd86d..7854966d1 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -277,8 +277,6 @@ void LoadDpiForWindow() noexcept { HINSTANCE hinstPlatformRes {}; -HCURSOR reverseArrowCursor {}; - FormatAndMetrics *FamFromFontID(void *fid) noexcept { return static_cast<FormatAndMetrics *>(fid); } @@ -1857,8 +1855,24 @@ void FlipBitmap(HBITMAP bitmap, int width, int height) noexcept { } } -void LoadReverseArrowCursor() noexcept { +} + +HCURSOR LoadReverseArrowCursor(UINT dpi) noexcept { + HCURSOR reverseArrowCursor {}; + + bool created = false; HCURSOR cursor = ::LoadCursor({}, IDC_ARROW); + + if (dpi != uSystemDPI) { + const int width = SystemMetricsForDpi(SM_CXCURSOR, dpi); + const int height = SystemMetricsForDpi(SM_CYCURSOR, dpi); + HCURSOR copy = static_cast<HCURSOR>(::CopyImage(cursor, IMAGE_CURSOR, width, height, LR_COPYFROMRESOURCE | LR_COPYRETURNORG)); + if (copy) { + created = copy != cursor; + cursor = copy; + } + } + ICONINFO info; if (::GetIconInfo(cursor, &info)) { BITMAP bmp; @@ -1875,8 +1889,11 @@ void LoadReverseArrowCursor() noexcept { if (info.hbmColor) ::DeleteObject(info.hbmColor); } -} + if (created) { + ::DestroyCursor(cursor); + } + return reverseArrowCursor; } void Window::SetCursor(Cursor curs) { @@ -1900,8 +1917,6 @@ void Window::SetCursor(Cursor curs) { ::SetCursor(::LoadCursor(NULL,IDC_HAND)); break; case cursorReverseArrow: - ::SetCursor(reverseArrowCursor); - break; case cursorArrow: case cursorInvalid: // Should not occur, but just in case. ::SetCursor(::LoadCursor(NULL,IDC_ARROW)); @@ -2950,7 +2965,6 @@ void Platform::Assert(const char *c, const char *file, int line) { void Platform_Initialise(void *hInstance) { hinstPlatformRes = static_cast<HINSTANCE>(hInstance); LoadDpiForWindow(); - LoadReverseArrowCursor(); ListBoxX_Register(); } @@ -2983,8 +2997,6 @@ void Platform_Finalise(bool fromDllMain) { } } #endif - if (reverseArrowCursor) - ::DestroyCursor(reverseArrowCursor); ListBoxX_Unregister(); } |
