void CExtChildResizablePropertySheet::_TrickSyncActviveChild() { CPropertyPage * pWnd = CPropertySheet::GetActivePage(); CTabCtrl * pTabCtrl = CPropertySheet::GetTabControl(); if( pWnd != NULL && pWnd->GetSafeHwnd() != NULL && ::IsWindow( pWnd->GetSafeHwnd() ) && pTabCtrl != NULL && pTabCtrl->GetSafeHwnd() != NULL && ::IsWindow( pTabCtrl->GetSafeHwnd() ) ) { if( !m_bTabStylesInitialized ) { m_bTabStylesInitialized = true; DWORD dwStylesRemove = 0L; DWORD dwStylesAdd = 0L; if( m_bInitTabSingleLine ) { dwStylesRemove |= TCS_MULTILINE; dwStylesAdd |= TCS_SINGLELINE; } if( m_bInitTabButtons ) { dwStylesAdd |= TCS_BUTTONS; if( m_bInitTabButtonsFlat ) dwStylesAdd |= TCS_FLATBUTTONS; } if( dwStylesRemove != 0 || dwStylesAdd != 0 ) pTabCtrl->ModifyStyle( dwStylesRemove, dwStylesAdd, SWP_FRAMECHANGED ); if( m_bInitTabButtons && m_bInitTabButtonsFlat && m_bInitTabSeparatorsFlat ) pTabCtrl->SetExtendedStyle( TCS_EX_FLATSEPARATORS, TCS_EX_FLATSEPARATORS ); } RECT lpRect; GetClientRect(&lpRect); // dirty fix of the access vialation bug of // the tab control with single item when item's // width/height is same as tab control width/height __try { pTabCtrl->AdjustRect(FALSE, &lpRect); } __except( EXCEPTION_EXECUTE_HANDLER ) { lpRect.right ++; lpRect.bottom ++; __try { pTabCtrl->AdjustRect(FALSE, &lpRect); } __except( EXCEPTION_EXECUTE_HANDLER ) { } } pWnd->MoveWindow(&lpRect, TRUE); } }
BOOL CMainTabDlg::OnInitDialog() { CRect r; TC_ITEM item; CString strTab; UINT nTabID[3]= {IDS_TAB_MAIN_CONFIGURE,IDS_TAB_MAIN_HISTORY,IDS_TAB_MAIN_PREFERENCES}; CDialog::OnInitDialog(); memset (&item, 0, sizeof (item)); item.mask = TCIF_TEXT|TCIF_IMAGE; item.cchTextMax = 32; item.iImage = -1; CTabCtrl * ptab = (CTabCtrl * )GetDlgItem(IDC_TAB1); ASSERT(ptab); ptab->GetWindowRect (r); ScreenToClient (r); m_dlgPadding.cx = r.left; m_dlgPadding.cy = r.top; CButton* pButton1= (CButton*)GetDlgItem(IDC_BUTTON1); ASSERT (pButton1); pButton1->GetWindowRect (r); ScreenToClient (r); m_buttonPadding.cx = r.right; m_buttonPadding.cy = r.bottom; int nTab = 2; #if defined (OIDSK) nTab = 2; #endif for (int i=0; i<nTab; i++) { strTab.LoadString (nTabID [i]); item.pszText = (LPTSTR)(LPCTSTR)strTab; ptab->InsertItem (i, &item); } if (m_pCurDlg) m_pCurDlg->ShowWindow (SW_HIDE); CTabCtrl* pTab = (CTabCtrl*) GetDlgItem(IDC_TAB1); int nsel = pTab->GetCurSel(); switch (nsel) { case PANE_CONFIG: if (!m_pConfigDlg) { m_pConfigDlg = new CConfigDlg(pTab); m_pConfigDlg->Create(IDD_CONFIG,pTab); } m_pCurDlg= m_pConfigDlg; break; case PANE_HISTORY: if (!m_pHistDlg) { m_pHistDlg = new CHistDlg(pTab); m_pHistDlg->Create(IDD_HISTORY,pTab); } m_pCurDlg= m_pHistDlg; break; case PANE_PREFERENCES: if (!m_pPrefDlg) { m_pPrefDlg = new CPrefDlg(pTab); m_pPrefDlg->Create(IDD_PREFERENCES,pTab); } m_pCurDlg= m_pPrefDlg; break; } if (m_pCurDlg) { CRect r; pTab->GetClientRect (r); pTab->AdjustRect (FALSE, r); m_pCurDlg->MoveWindow(r); m_pCurDlg->ShowWindow(SW_SHOW); } SHOSTINFO CurInfo; VCBFGetHostInfos(&CurInfo); CStatic* pStatic = (CStatic*)GetDlgItem(IDC_STATIC_NAME_INSTALL); pStatic->SetWindowText((LPCTSTR)CurInfo.ii_installation_name); pStatic = (CStatic*)GetDlgItem(IDC_STATIC_INSTALL); pStatic->SetWindowText((LPCTSTR)CurInfo.ii_installation); pStatic = (CStatic*)GetDlgItem(IDC_STATIC_IISYSTEM_NAME); pStatic->SetWindowText((LPCTSTR)CurInfo.ii_system_name); pStatic = (CStatic*)GetDlgItem(IDC_STATIC_II_SYSTEM); pStatic->SetWindowText((LPCTSTR)CurInfo.ii_system); pStatic = (CStatic*)GetDlgItem(IDC_STATIC_HOST); pStatic->SetWindowText((LPCTSTR)CurInfo.host); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
void CuDlgCacheTab::DisplayPage (CACHELINEINFO* pData) { CString csButtonTitle; CWnd* pParent1 = GetParent (); // View (CvDbmsCacheViewRight) ASSERT_VALID (pParent1); CWnd* pParent2 = pParent1->GetParent (); // SplitterWnd ASSERT_VALID (pParent2); CWnd* pParent3 = pParent2->GetParent (); // Frame (CfDbmsCacheFrame) ASSERT_VALID (pParent3); CWnd* pParent4 = pParent3->GetParent (); // Modeless Dialog (CuDlgDbmsCache) ASSERT_VALID (pParent4); CWnd* pParent5 = pParent4->GetParent (); // CTabCtrl ASSERT_VALID (pParent5); CWnd* pParent6 = pParent5->GetParent (); // CConfRightDlg ASSERT_VALID (pParent6); CButton* pButton1 = (CButton*)((CConfRightDlg*)pParent6)->GetDlgItem (IDC_BUTTON1); CButton* pButton2 = (CButton*)((CConfRightDlg*)pParent6)->GetDlgItem (IDC_BUTTON2); CuCacheCheckListCtrl* pList = GetCacheListCtrl(); CTabCtrl* pTab = (CTabCtrl*)GetDlgItem(IDC_TAB1); if (m_pCurrentPage) { // // Try to save (and validate) the data that has been changed // in the old page before displaying a new page. m_pCurrentPage->SendMessage(WMUSRMSG_CBF_PAGE_VALIDATE, (WPARAM)0, (LPARAM)0); m_pCurrentPage->ShowWindow (SW_HIDE); m_pCurrentPage = NULL; } if (!(pTab && IsWindow (pTab->m_hWnd))) return; UINT nState = 0; int i, nCurSel = -1, nCount = pList->GetItemCount(); for (i=0; i<nCount; i++) { nState = pList->GetItemState (i, LVIS_SELECTED); if (nState & LVIS_SELECTED) { nCurSel = i; break; } } if (nCurSel == -1) return; if (!pData) return; try { if (!VCBFllInitCacheParms(pData)) return; int nSel = pTab->GetCurSel(); switch (nSel) { case 0: csButtonTitle.LoadString(IDS_BUTTON_EDIT_VALUE); pButton1->SetWindowText (csButtonTitle); csButtonTitle.LoadString(IDS_BUTTON_RESTORE); pButton2->SetWindowText (csButtonTitle); if (!m_pCacheParameter) { m_pCacheParameter = new CuDlgDbmsCacheParameter (pTab); m_pCacheParameter->Create (IDD_DBMS_PAGE_CACHE_PARAMETER, pTab); } m_pCurrentPage = m_pCacheParameter; break; case 1: csButtonTitle.LoadString(IDS_BUTTON_EDIT_VALUE); pButton1->SetWindowText (csButtonTitle); csButtonTitle.LoadString(IDS_BUTTON_RECALCULATE); pButton2->SetWindowText (csButtonTitle); if (!m_pCacheDerived) { m_pCacheDerived = new CuDlgDbmsCacheDerived (pTab); m_pCacheDerived->Create (IDD_DBMS_PAGE_CACHE_DERIVED, pTab); } m_pCurrentPage = m_pCacheDerived; break; default: break; } if (m_pCurrentPage) { CRect r; pTab->GetClientRect (r); pTab->AdjustRect (FALSE, r); m_pCurrentPage->SendMessage (WMUSRMSG_CBF_PAGE_UPDATING, 0, 0); m_pCurrentPage->MoveWindow(r); m_pCurrentPage->ShowWindow(SW_SHOW); } } catch (CeVcbfException e) { // // Catch critical error TRACE1 ("CuDlgCacheTab::DisplayPage has caught exception: %s\n", e.m_strReason); CMainFrame* pMain = (CMainFrame*)AfxGetMainWnd(); pMain->CloseApplication (FALSE); } catch (CMemoryException* e) { VCBF_OutOfMemoryMessage (); e->Delete(); } catch (...) { TRACE0 ("Other error occured ...\n"); } }
void CMainTabDlg::OnSize(UINT nType, int cx, int cy) { CDialog::OnSize(nType, cx, cy); CTabCtrl * pTab = (CTabCtrl *) GetDlgItem(IDC_TAB1); CRect rDlg; GetClientRect (rDlg); if (pTab && IsWindow(pTab->m_hWnd)) { // // Move the buttons to the right place. CButton* pB1 = (CButton*) GetDlgItem(IDC_BUTTON2); // Close; CButton* pB2 = (CButton*) GetDlgItem(IDC_BUTTON1); // Help CButton* pB3 = (CButton*) GetDlgItem(IDC_BUTTON3); int ibY = 0; CRect r, newRect; pB1->GetClientRect (r); newRect.top = rDlg.bottom - 10 - r.Height(); newRect.right = rDlg.right - m_dlgPadding.cx; newRect.left = newRect.right - r.Width(); newRect.bottom = newRect.top + r.Height(); pB1->MoveWindow (newRect); newRect.right = newRect.left - 10; newRect.left = newRect.right - r.Width(); pB2->MoveWindow (newRect); newRect.right = newRect.left - 10; newRect.left = newRect.right - r.Width(); pB3->MoveWindow (newRect); ibY = newRect.top; // // Move the static Text Header II_SYSTEM // to the right place. CStatic* pStatic = (CStatic*)GetDlgItem(IDC_STATIC_II_SYSTEM); pStatic->GetWindowRect (r); ScreenToClient (r); r.right = rDlg.right - m_dlgPadding.cx; pStatic->MoveWindow (r); // // Move the Tab Control to the right place. pStatic->GetWindowRect (r); ScreenToClient (r); r.top = r.bottom + 10; r.bottom = ibY - 10; r.left = m_dlgPadding.cx; r.right = rDlg.right - m_dlgPadding.cx; pTab->MoveWindow(r); if (m_pCurDlg) { CRect r; pTab->GetClientRect (r); pTab->AdjustRect (FALSE, r); m_pCurDlg->MoveWindow(r); } } }