diff --git a/windows/container.c b/windows/container.c index 8cc438c0..e2fac8b9 100644 --- a/windows/container.c +++ b/windows/container.c @@ -319,8 +319,7 @@ static void containerResize(uiControl *cc, intmax_t x, intmax_t y, intmax_t widt { struct container *c = (struct container *) (cc->Internal); - if (SetWindowPos(c->hwnd, d->Sys->InsertAfter, x, y, width, height, SWP_NOACTIVATE | SWP_NOOWNERZORDER) == 0) - logLastError("error resizing uiContainer in containerResize()"); + moveAndReorderWindow(c->hwnd, d->Sys->InsertAfter, x, y, width, height); 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 diff --git a/windows/newcontrol.c b/windows/newcontrol.c index 0e237793..53477b78 100644 --- a/windows/newcontrol.c +++ b/windows/newcontrol.c @@ -55,8 +55,7 @@ static void singleResize(uiControl *c, intmax_t x, intmax_t y, intmax_t width, i { struct singleHWND *s = (struct singleHWND *) (c->Internal); - if (SetWindowPos(s->hwnd, d->Sys->InsertAfter, x, y, width, height, SWP_NOACTIVATE | SWP_NOOWNERZORDER) == 0) - logLastError("error moving control in singleResize()"); + moveAndReorderWindow(s->hwnd, d->Sys->InsertAfter, x, y, width, height); d->Sys->InsertAfter = s->hwnd; } diff --git a/windows/tab.c b/windows/tab.c index 51f7cead..538624f3 100644 --- a/windows/tab.c +++ b/windows/tab.c @@ -171,8 +171,7 @@ static void resizeTab(struct tab *t, LONG width, LONG height) p = ptrArrayIndex(t->pages, struct tabPage *, n); binHWND = (HWND) uiControlHandle(uiControl(p->bin)); - if (MoveWindow(binHWND, r.left, r.top, r.right - r.left, r.bottom - r.top, TRUE) == 0) - logLastError("error resizing uiTab page in resizeTab()"); + moveWindow(binHWND, r.left, r.top, r.right - r.left, r.bottom - r.top); } // and finally, because we have to resize parents, we have to handle resizes and updates diff --git a/windows/uipriv_windows.h b/windows/uipriv_windows.h index 560deec0..1911c1b2 100644 --- a/windows/uipriv_windows.h +++ b/windows/uipriv_windows.h @@ -56,6 +56,8 @@ extern DWORD getStyle(HWND); extern void setStyle(HWND, DWORD); extern DWORD getExStyle(HWND); extern void setExStyle(HWND, DWORD); +extern void moveWindow(HWND, intmax_t, intmax_t, intmax_t, intmax_t); +extern void moveAndReorderWindow(HWND, HWND, intmax_t, intmax_t, intmax_t, intmax_t); // text.c extern WCHAR *toUTF16(const char *); diff --git a/windows/util.c b/windows/util.c index caac4dd8..da9dfeac 100644 --- a/windows/util.c +++ b/windows/util.c @@ -115,3 +115,17 @@ void setExStyle(HWND hwnd, DWORD exstyle) { SetWindowLongPtrW(hwnd, GWL_EXSTYLE, (LONG_PTR) exstyle); } + +#define swpflags (SWP_NOACTIVATE | SWP_NOOWNERZORDER) + +void moveWindow(HWND hwnd, intmax_t x, intmax_t y, intmax_t width, intmax_t height) +{ + if (SetWindowPos(hwnd, NULL, x, y, width, height, swpflags | SWP_NOZORDER) == 0) + logLastError("error moving window in moveWindow()"); +} + +void moveAndReorderWindow(HWND hwnd, HWND insertAfter, intmax_t x, intmax_t y, intmax_t width, intmax_t height) +{ + if (SetWindowPos(hwnd, insertAfter, x, y, width, height, swpflags) == 0) + logLastError("error moving and reordering window in moveAndReorderWindow()"); +} diff --git a/windows/window.c b/windows/window.c index c6459ee8..c1d77a5b 100644 --- a/windows/window.c +++ b/windows/window.c @@ -47,8 +47,7 @@ static LRESULT CALLBACK windowWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARA if (GetClientRect(w->hwnd, &r) == 0) logLastError("error getting window client rect for resize in windowWndProc()"); binhwnd = (HWND) uiControlHandle(uiControl(w->bin)); - if (MoveWindow(binhwnd, r.left, r.top, r.right - r.left, r.bottom - r.top, TRUE) == 0) - logLastError("error resizing uiWindow box in windowWndProc()"); + moveWindow(binhwnd, r.left, r.top, r.right - r.left, r.bottom - r.top); return 0; case WM_CLOSE: if ((*(w->onClosing))(uiWindow(w), w->onClosingData))