diff --git a/ui_windows.h b/ui_windows.h index 5e93594e..ef79a0db 100644 --- a/ui_windows.h +++ b/ui_windows.h @@ -41,6 +41,11 @@ struct uiSizingSys { int baseX; int baseY; LONG internalLeading; + + // This is the window handle to pass to the hWndInsertAfter parameter of SetWindowPos(). + // You should set this to your own window handle when done. + // Controls made with uiWindowsMakeControl() do this for you; you only need to do this if you are implementing uiControlResize() yourself. + HWND InsertAfter; }; // Use these in your preferredSize() implementation with baseX and baseY. #define uiWindowsDlgUnitsToX(dlg, baseX) MulDiv((dlg), baseX, 4) diff --git a/windows/container.c b/windows/container.c index e2106656..cf457582 100644 --- a/windows/container.c +++ b/windows/container.c @@ -147,6 +147,9 @@ static HRESULT resize(uiContainer *cc, RECT *r) if (ReleaseDC(c->hwnd, dc) == 0) return logLastError("error releasing DC in resize()"); + // the first control gets the topmost z-order and thus the first tab stop + sys.InsertAfter = HWND_TOP; + d.xPadding = uiWindowsDlgUnitsToX(winXPadding, sys.baseX); d.yPadding = uiWindowsDlgUnitsToY(winYPadding, sys.baseY); d.sys = &sys; @@ -316,8 +319,9 @@ static void containerResize(uiControl *cc, intmax_t x, intmax_t y, intmax_t widt { struct container *c = (struct container *) (cc->Internal); - if (MoveWindow(c->hwnd, x, y, width, height, TRUE) == 0) + if (SetWindowPos(c->hwnd, d->sys->InsertAfter, x, y, width, height, SWP_NOACTIVATE | SWP_NOOWNERZORDER) == 0) logLastError("error resizing uiContainer in containerResize()"); + d->sys->InsertAfter = c->hwnd; // under some circumstances this might not be sufficient // example: check the Spaced checkbox; inside boxes will have been resized already before they get a chance to update their padded SendMessageW(c->hwnd, msgUpdateChild, 0, 0); diff --git a/windows/newcontrol.c b/windows/newcontrol.c index 0539ad32..cbfb8fed 100644 --- a/windows/newcontrol.c +++ b/windows/newcontrol.c @@ -55,8 +55,9 @@ static void singleResize(uiControl *c, intmax_t x, intmax_t y, intmax_t width, i { struct singleHWND *s = (struct singleHWND *) (c->Internal); - if (MoveWindow(s->hwnd, x, y, width, height, TRUE) == 0) + if (SetWindowPos(s->hwnd, d->sys->InsertAfter, x, y, width, height, SWP_NOACTIVATE | SWP_NOOWNERZORDER) == 0) logLastError("error moving control in singleResize()"); + d->sys->InsertAfter = s->hwnd; } static int singleVisible(uiControl *c)