Finally fixed the Tab content resizing.
This commit is contained in:
parent
2005f18624
commit
5a0a0d1584
|
@ -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
|
if (n != (LRESULT) (-1)) { // if we're changing to a real tab
|
||||||
ShowWindow(uiParentHWND(t->pages[n]), SW_SHOW);
|
ShowWindow(uiParentHWND(t->pages[n]), SW_SHOW);
|
||||||
// because we only resize the current child on resize, we'll need to trigger an update here
|
// 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;
|
*lResult = 0;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -89,6 +90,7 @@ static LRESULT CALLBACK tabSubProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l
|
||||||
uiControl *c = (uiControl *) dwRefData;
|
uiControl *c = (uiControl *) dwRefData;
|
||||||
WINDOWPOS *wp = (WINDOWPOS *) lParam;
|
WINDOWPOS *wp = (WINDOWPOS *) lParam;
|
||||||
LRESULT lResult;
|
LRESULT lResult;
|
||||||
|
RECT r;
|
||||||
|
|
||||||
switch (uMsg) {
|
switch (uMsg) {
|
||||||
case WM_WINDOWPOSCHANGED:
|
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
|
// we have the window rect width as part of the WINDOWPOS; resize
|
||||||
resizeTab(c, wp->cx, wp->cy);
|
resizeTab(c, wp->cx, wp->cy);
|
||||||
return lResult;
|
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:
|
case WM_NCDESTROY:
|
||||||
if ((*fv_RemoveWindowSubclass)(hwnd, tabSubProc, uIdSubclass) == FALSE)
|
if ((*fv_RemoveWindowSubclass)(hwnd, tabSubProc, uIdSubclass) == FALSE)
|
||||||
logLastError("error removing Tab resize handling subclass in tabSubProc()");
|
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)
|
if (SendMessageW(hwnd, TCM_INSERTITEM, (WPARAM) n, (LPARAM) (&item)) == (LRESULT) -1)
|
||||||
logLastError("error adding tab to Tab in uiTabAddPage()");
|
logLastError("error adding tab to Tab in uiTabAddPage()");
|
||||||
uiFree(wname);
|
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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue