From cd0cce2779597abe87ee6d28623eae65c608e737 Mon Sep 17 00:00:00 2001 From: NishiOwO Date: Tue, 25 Nov 2025 01:49:17 +0000 Subject: [PATCH] mhm git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@805 b9cfdab3-6d41-4d17-bbe4-086880011989 --- include/Mw/LowLevel/GDI.h | 1 + src/backend/gdi.c | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/include/Mw/LowLevel/GDI.h b/include/Mw/LowLevel/GDI.h index f65763e..a316779 100644 --- a/include/Mw/LowLevel/GDI.h +++ b/include/Mw/LowLevel/GDI.h @@ -18,6 +18,7 @@ struct _MwLLGDI { HWND hWnd; HDC hDC; HCURSOR cursor; + HICON icon; int grabbed; }; diff --git a/src/backend/gdi.c b/src/backend/gdi.c index c1d53a9..5f692ec 100644 --- a/src/backend/gdi.c +++ b/src/backend/gdi.c @@ -201,6 +201,8 @@ static LRESULT CALLBACK wndproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) { } else if(msg == WM_SETCURSOR) { if(LOWORD(lp) != HTCLIENT) return DefWindowProc(hWnd, msg, wp, lp); if(u->ll->gdi.cursor != NULL) SetCursor(u->ll->gdi.cursor); + } else if(msg == WM_SETICON) { + return u->ll.gdi.icon; } else if(msg == WM_USER) { InvalidateRect(hWnd, NULL, FALSE); UpdateWindow(hWnd); @@ -240,6 +242,7 @@ static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) { r->gdi.hWnd = CreateWindow("milsko", "Milsko", parent == NULL ? (WS_OVERLAPPEDWINDOW) : (WS_CHILD | WS_VISIBLE), x == MwDEFAULT ? CW_USEDEFAULT : x, y == MwDEFAULT ? CW_USEDEFAULT : y, width, height, parent == NULL ? NULL : parent->gdi.hWnd, 0, wc.hInstance, NULL); r->gdi.hInstance = wc.hInstance; r->gdi.cursor = NULL; + r->gdi.icon = NULL; u->ll = r; u->min_set = 0; @@ -273,6 +276,7 @@ static void MwLLDestroyImpl(MwLL handle) { DestroyWindow(handle->gdi.hWnd); if(handle->gdi.cursor != NULL) DestroyCursor(handle->gdi.cursor); + if(handle->gdi.icon != NULL) DestroyIcon(handle->gdi.icon); free(handle); } @@ -509,11 +513,8 @@ static void MwLLSetIconImpl(MwLL handle, MwLLPixmap pixmap) { ii.hbmMask = pixmap->gdi.hMask2; ii.hbmColor = pixmap->gdi.hBitmap; - ico = CreateIconIndirect(&ii); - - SetClassLongPtr(handle->gdi.hWnd, GCLP_HICON, (LPARAM)ico); - - DestroyIcon(ico); + if(handle->gdi.icon != NULL) DestroyCursor(handle->gdi.icon); + handle->gdi.icon o = CreateIconIndirect(&ii); } static void MwLLForceRenderImpl(MwLL handle) {