Made all instances of SetWindowPos() and MoveWindow() use the same wrapper functions so they can all use the same flags. Only the SetWindoPos() that sets the initial size of a uiWindow is unaffected (since that is a special case).

This commit is contained in:
Pietro Gagliardi 2015-05-07 17:40:13 -04:00
parent 3872b9777a
commit efbdf14d5f
6 changed files with 20 additions and 8 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -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

View File

@ -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 *);

View File

@ -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()");
}

View File

@ -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))