//获取行数 int SiTabCtl_GetRowCount(void) { int row = TabCtrl_GetRowCount(hwnd_tab_ctl); if(row == 0) row = 1; return row; }
void UpdateStrings() { // Update window title PropSheet_SetTitle(g_cfgwnd, 0, l10n->title); // Update tab titles HWND tc = PropSheet_GetTabControl(g_cfgwnd); int numrows_prev = TabCtrl_GetRowCount(tc); wchar_t *titles[] = { l10n->tab_general, l10n->tab_input, l10n->tab_blacklist, l10n->tab_advanced, l10n->tab_about }; int i; for (i=0; i < ARRAY_SIZE(titles); i++) { TCITEM ti; ti.mask = TCIF_TEXT; ti.pszText = titles[i]; TabCtrl_SetItem(tc, i, &ti); } // Modify UI if number of rows have changed int numrows = TabCtrl_GetRowCount(tc); if (numrows_prev != numrows) { HWND page = PropSheet_GetCurrentPageHwnd(g_cfgwnd); if (page != NULL) { int diffrows = numrows-numrows_prev; WINDOWPLACEMENT wndpl = { sizeof(WINDOWPLACEMENT) }; // Resize window GetWindowPlacement(g_cfgwnd, &wndpl); wndpl.rcNormalPosition.bottom += 18*diffrows; SetWindowPlacement(g_cfgwnd, &wndpl); // Resize tabcontrol GetWindowPlacement(tc, &wndpl); wndpl.rcNormalPosition.bottom += 18*diffrows; SetWindowPlacement(tc, &wndpl); // Move button HWND button = GetDlgItem(g_cfgwnd, IDOK); GetWindowPlacement(button, &wndpl); int height = wndpl.rcNormalPosition.bottom-wndpl.rcNormalPosition.top; wndpl.rcNormalPosition.top += 18*diffrows; wndpl.rcNormalPosition.bottom = wndpl.rcNormalPosition.top+height; SetWindowPlacement(button, &wndpl); // Re-select tab PropSheet_SetCurSel(g_cfgwnd, page, 0); // Invalidate region GetWindowPlacement(g_cfgwnd, &wndpl); InvalidateRect(g_cfgwnd, &wndpl.rcNormalPosition, TRUE); } } }
void TabBar::reSizeTo(RECT & rc2Ajust) { RECT rowRect; int rowCount, tabsHight; // Important to do that! // Otherwise, the window(s) it contains will take all the resouce of CPU // We don't need to resize the contained windows if they are even invisible anyway display(rc2Ajust.right > 10); RECT rc = rc2Ajust; Window::reSizeTo(rc); // Do our own calculations because TabCtrl_AdjustRect doesn't work // on vertical or multi-lined tab controls rowCount = TabCtrl_GetRowCount(_hSelf); TabCtrl_GetItemRect(_hSelf, 0, &rowRect); int larger = _isVertical ? rowRect.right : rowRect.bottom; int smaller = _isVertical ? rowRect.left : rowRect.top; int marge = 0; LONG_PTR style = ::GetWindowLongPtr(_hSelf, GWL_STYLE); if (rowCount == 1) { style &= ~TCS_BUTTONS; } else // (rowCount >= 2) { style |= TCS_BUTTONS; marge = (rowCount - 2) * 3; // in TCS_BUTTONS mode, each row has few pixels higher } ::SetWindowLongPtr(_hSelf, GWL_STYLE, style); tabsHight = rowCount * (larger - smaller) + marge; tabsHight += GetSystemMetrics(_isVertical ? SM_CXEDGE : SM_CYEDGE); if (_isVertical) { rc2Ajust.left += tabsHight; rc2Ajust.right -= tabsHight; } else { rc2Ajust.top += tabsHight; rc2Ajust.bottom -= tabsHight; } }
void TabBar::reSizeTo(RECT & rc2Ajust) { RECT RowRect; int RowCount, TabsLength; // Important to do that! // Otherwise, the window(s) it contains will take all the resouce of CPU // We don't need to resize the contained windows if they are even invisible anyway display(rc2Ajust.right > 10); RECT rc = rc2Ajust; Window::reSizeTo(rc); //TabCtrl_AdjustRect(_hSelf, FALSE, &rc2Ajust); // Do our own calculations because TabCtrl_AdjustRect doesn't work // on vertical or multi-lined tab controls RowCount = TabCtrl_GetRowCount(_hSelf); TabCtrl_GetItemRect(_hSelf, 0, &RowRect); if (_isTraditional) { TabCtrl_AdjustRect(_hSelf, FALSE, &rc2Ajust); } else if (_isVertical) { TabsLength = RowCount * (RowRect.right - RowRect.left); TabsLength += GetSystemMetrics(SM_CXEDGE); rc2Ajust.left += TabsLength + 5; rc2Ajust.right -= TabsLength + 10; rc2Ajust.top += 5; rc2Ajust.bottom -= 10; } else { TabsLength = RowCount * (RowRect.bottom - RowRect.top); TabsLength += GetSystemMetrics(SM_CYEDGE); rc2Ajust.top += TabsLength + 5; rc2Ajust.bottom -= TabsLength + 10; rc2Ajust.left += 5; rc2Ajust.right -= 10; } }
int wxNotebook::GetRowCount() const { return TabCtrl_GetRowCount(GetHwnd()); }
// Get the number of rows int wxTabCtrl::GetRowCount() const { return (int) TabCtrl_GetRowCount( (HWND) GetHWND() ); }