From d05e121bf1bccfbe96fb0b3b5c4b5316e721f4ae Mon Sep 17 00:00:00 2001 From: Nishi Date: Sat, 2 May 2026 21:51:51 +0900 Subject: [PATCH] win32 fix --- examples/basic/subwindow.c | 4 +++- src/backend/gdi.c | 16 ++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/examples/basic/subwindow.c b/examples/basic/subwindow.c index 1225f41f0..c18efdf45 100644 --- a/examples/basic/subwindow.c +++ b/examples/basic/subwindow.c @@ -1,5 +1,7 @@ #include +#define Shift 16 + static void resize(MwWidget handle, void* user, void* client) { MwWidget f = MwSubWindowGetFrame(handle); MwVaApply(user, @@ -32,7 +34,7 @@ int main() { sprintf(buf, "Sub window %d", i); - sw = MwVaCreateWidget(MwSubWindowClass, "swnd", w, i * 32, i * 32, 128, 128, + sw = MwVaCreateWidget(MwSubWindowClass, "swnd", w, i * Shift, i * Shift, 128, 128, MwNtitle, buf, NULL); diff --git a/src/backend/gdi.c b/src/backend/gdi.c index db6090d9e..a0454becb 100644 --- a/src/backend/gdi.c +++ b/src/backend/gdi.c @@ -302,7 +302,7 @@ static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) { if(parent == NULL) r->gdi.get_darktheme = 1; r->gdi.force_render = 0; r->gdi.grabbed = 0; - 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.hWnd = CreateWindow("milsko", "Milsko", parent == NULL ? (WS_OVERLAPPEDWINDOW) : (WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS), 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; @@ -328,6 +328,8 @@ static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) { InvalidateRect(r->gdi.hWnd, NULL, FALSE); } + SetWindowPos(r->gdi.hWnd, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); + return r; } @@ -372,10 +374,17 @@ static void MwLLPolygonImpl(MwLL handle, MwPoint* points, int points_count, MwLL static void MwLLLineImpl(MwLL handle, MwPoint* points, MwLLColor color) { HPEN pen = CreatePen(PS_SOLID, 1, RGB(color->common.red, color->common.green, color->common.blue)); + RECT rc; + + rc.left = points[1].x; + rc.top = points[1].y; + rc.right = rc.left + 1; + rc.bottom = rc.top + 1; SelectObject(handle->gdi.hDC, pen); MoveToEx(handle->gdi.hDC, points[0].x, points[0].y, NULL); LineTo(handle->gdi.hDC, points[1].x, points[1].y); + FillRect(handle->gdi.hDC, &rc, color->gdi.brush); DeleteObject(pen); } @@ -428,12 +437,11 @@ static void MwLLGetXYWHImpl(MwLL handle, int* x, int* y, unsigned int* w, unsign } static void MwLLSetXYImpl(MwLL handle, int x, int y) { - SetWindowPos(handle->gdi.hWnd, NULL, x, y, 0, 0, SWP_NOSIZE); - InvalidateRect(handle->gdi.hWnd, NULL, FALSE); + SetWindowPos(handle->gdi.hWnd, NULL, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER); } static void MwLLSetWHImpl(MwLL handle, int w, int h) { - SetWindowPos(handle->gdi.hWnd, NULL, 0, 0, w, h, SWP_NOMOVE); + SetWindowPos(handle->gdi.hWnd, NULL, 0, 0, w, h, SWP_NOMOVE | SWP_NOZORDER); InvalidateRect(handle->gdi.hWnd, NULL, FALSE); }