From 4839280b8291fc31bd3ea8669d7d0395c6914ba8 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Mon, 13 Apr 2015 10:15:36 -0400 Subject: [PATCH] Finally fixed the Tab content resizing. --- new/tab_windows.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/new/tab_windows.c b/new/tab_windows.c index b54039b..00fccb0 100644 --- a/new/tab_windows.c +++ b/new/tab_windows.c @@ -34,7 +34,8 @@ static BOOL onWM_NOTIFY(uiControl *c, NMHDR *nm, LRESULT *lResult) if (n != (LRESULT) (-1)) { // if we're changing to a real tab ShowWindow(uiParentHWND(t->pages[n]), SW_SHOW); // because we only resize the current child on resize, we'll need to trigger an update here - uiParentUpdate(t->pages[n]); + // don't call uiParentUpdate(); doing that won't size the content area (so we'll still have a 0x0 content area, for instance) + SendMessageW(uiControlHWND(c), msgUpdateChild, 0, 0); } *lResult = 0; return TRUE; @@ -89,6 +90,7 @@ static LRESULT CALLBACK tabSubProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l uiControl *c = (uiControl *) dwRefData; WINDOWPOS *wp = (WINDOWPOS *) lParam; LRESULT lResult; + RECT r; switch (uMsg) { case WM_WINDOWPOSCHANGED: @@ -99,6 +101,12 @@ static LRESULT CALLBACK tabSubProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l // we have the window rect width as part of the WINDOWPOS; resize resizeTab(c, wp->cx, wp->cy); return lResult; + case msgUpdateChild: + if (GetWindowRect(uiControlHWND(c), &r) == 0) + logLastError("error getting Tab window rect for synthesized resize message in tabSubProc()"); + // these are in screen coordinates, which match what WM_WINDOWPOSCHANGED gave us (thanks TODOTODOTODOTODOTODOTODOTODO) + resizeTab(c, r.right - r.left, r.bottom - r.top); + return 0; case WM_NCDESTROY: if ((*fv_RemoveWindowSubclass)(hwnd, tabSubProc, uIdSubclass) == FALSE) logLastError("error removing Tab resize handling subclass in tabSubProc()"); @@ -172,4 +180,10 @@ void uiTabAddPage(uiControl *c, const char *name, uiControl *child) if (SendMessageW(hwnd, TCM_INSERTITEM, (WPARAM) n, (LPARAM) (&item)) == (LRESULT) -1) logLastError("error adding tab to Tab in uiTabAddPage()"); uiFree(wname); + + // if this is the first tab, Windows will automatically show it /without/ sending a TCN_SELCHANGE notification + // (TODO verify that) + // so we need to manually resize the tab ourselves + // don't use uiUpdateParent() for the same reason as in the TCN_SELCHANGE handler + SendMessageW(uiControlHWND(c), msgUpdateChild, 0, 0); }