//--------------------------------------------------------------- // Purpose: //--------------------------------------------------------------- BOOL CEntityDialog::OnInitDialog() { if( !CDialogEx::OnInitDialog() ) return FALSE; //Create copy of editable entity m_oldEntity = GetActiveDocument()->GetSelectedEntity(0); m_newEntity = m_oldEntity->Clone(); Assert( m_oldEntity && m_newEntity ); GetActiveDocument()->GetEntityList()->ReplaceEntity( m_oldEntity, m_newEntity ); GetActiveDocument()->SelectSingleEntity( m_newEntity ); m_dialogClassInfo.SetEditEntity(m_newEntity); //Get Tab Control CTabCtrl *pTabCtrl = (CTabCtrl*)GetDlgItem(IDC_TAB1); //Create Tab Content dialog and adjust m_dialogClassInfo.Create(IDD_ENTITY_CLASS_INFO, pTabCtrl); TCITEM tcItem; tcItem.mask = TCIF_TEXT | TCIF_PARAM; tcItem.pszText = _T("Class Info"); tcItem.lParam = (LPARAM)&m_dialogClassInfo; pTabCtrl->InsertItem(0, &tcItem); RECT wndrect; GetClientRect(&wndrect); wndrect.top -= 15; wndrect.bottom -= 30; pTabCtrl->AdjustRect( FALSE, &wndrect ); pTabCtrl->MoveWindow( &wndrect ); CRect rect; pTabCtrl->GetItemRect(0, &rect); m_dialogClassInfo.SetWindowPos(NULL, rect.left, rect.bottom + 1, wndrect.right-wndrect.left-10, wndrect.bottom-wndrect.top-30, /*SWP_NOSIZE |*/ SWP_NOZORDER ); m_dialogClassInfo.ShowWindow(SW_SHOW); return TRUE; }
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); } } }
BOOL CResizableSheet::ArrangeLayoutCallback(LAYOUTINFO &layout) const { if (layout.nCallbackID != m_nCallbackID) // we only added 1 callback return CResizableLayout::ArrangeLayoutCallback(layout); // set layout info for active page layout.hWnd = (HWND)::SendMessage(m_hWnd, PSM_GETCURRENTPAGEHWND, 0, 0); if (!::IsWindow(layout.hWnd)) return FALSE; // set margins if (IsWizard()) // wizard mode { // use pre-calculated margins layout.marginTopLeft = m_sizePageTL; layout.marginBottomRight = m_sizePageBR; } else // tab mode { CTabCtrl* pTab = GetTabControl(); ASSERT(pTab != NULL); // get tab position after resizing and calc page rect CRect rectPage, rectSheet; GetTotalClientRect(&rectSheet); if (!GetAnchorPosition(pTab->m_hWnd, rectSheet, rectPage)) return FALSE; // no page yet // temporarily resize the tab control to calc page size CRect rectSave; pTab->GetWindowRect(rectSave); ::MapWindowPoints(NULL, m_hWnd, (LPPOINT)&rectSave, 2); pTab->SetRedraw(FALSE); pTab->MoveWindow(rectPage, FALSE); pTab->AdjustRect(FALSE, &rectPage); pTab->MoveWindow(rectSave, FALSE); pTab->SetRedraw(TRUE); // set margins layout.marginTopLeft = rectPage.TopLeft() - rectSheet.TopLeft(); layout.marginBottomRight = rectPage.BottomRight() - rectSheet.BottomRight(); } // set anchor types layout.anchorTopLeft = TOP_LEFT; layout.anchorBottomRight = BOTTOM_RIGHT; // use this layout info return TRUE; }
BOOL CResizableSheetEx::CalcSizeExtra(HWND /*hWndChild*/, CSize sizeChild, CSize &sizeExtra) { CTabCtrl* pTab = GetTabControl(); if (!pTab) return FALSE; // get margins of tabcontrol CRect rectMargins; if (!GetAnchorMargins(pTab->m_hWnd, sizeChild, rectMargins)) return FALSE; // get margin caused by tabcontrol CRect rectTabMargins(0,0,0,0); // get tab position after resizing and calc page rect CRect rectPage, rectSheet; GetTotalClientRect(&rectSheet); if (!GetAnchorPosition(pTab->m_hWnd, rectSheet, rectPage)) return FALSE; // no page yet // temporarily resize the tab control to calc page size CRect rectSave; pTab->GetWindowRect(rectSave); ::MapWindowPoints(NULL, m_hWnd, (LPPOINT)&rectSave, 2); pTab->SetRedraw(FALSE); pTab->MoveWindow(rectPage, FALSE); pTab->AdjustRect(TRUE, &rectTabMargins); pTab->MoveWindow(rectSave, FALSE); pTab->SetRedraw(TRUE); // add non-client size ::AdjustWindowRectEx(&rectTabMargins, GetStyle(), !(GetStyle() & WS_CHILD) && ::IsMenu(GetMenu()->GetSafeHmenu()), GetExStyle()); // compute extra size sizeExtra = rectMargins.TopLeft() + rectMargins.BottomRight() + rectTabMargins.Size(); return TRUE; }
void CuDlgCacheTab::OnSize(UINT nType, int cx, int cy) { CDialog::OnSize(nType, cx, cy); CTabCtrl* pTab = (CTabCtrl*)GetDlgItem (IDC_TAB1); if (!(pTab && IsWindow (pTab->m_hWnd))) return; CRect rDlg, r; GetClientRect (rDlg); pTab->MoveWindow (rDlg); if (!m_pCurrentPage) return; pTab->GetClientRect (r); pTab->AdjustRect (FALSE, r); m_pCurrentPage->MoveWindow(r); m_pCurrentPage->ShowWindow(SW_SHOW); }
void CXTPColorDialog::CalculateRects() { CRect rcBtnOK; CRect rcBtnCancel; CRect rcTabCtrl; CRect rcItem; // get the tab control size. CTabCtrl* pTabCtrl = GetTabControl(); pTabCtrl->GetWindowRect(&rcTabCtrl); ScreenToClient(&rcTabCtrl); // get the size of the first tab item. pTabCtrl->GetItemRect(0, &rcItem); // get the OK button size. CButton* pBtnOK = (CButton*)GetDlgItem(IDOK); pBtnOK->GetWindowRect(&rcBtnOK); ScreenToClient(&rcBtnOK); // get the Cancel button size. CButton* pBtnCancel = (CButton*)GetDlgItem(IDCANCEL); pBtnCancel->GetWindowRect(&rcBtnCancel); ScreenToClient(&rcBtnCancel); rcBtnCancel.OffsetRect(-15, 0); // resize the tab control rcTabCtrl.right = rcBtnCancel.left - 5; rcTabCtrl.bottom = rcBtnCancel.top - 15; pTabCtrl->MoveWindow(&rcTabCtrl); // reposition the OK button. rcBtnOK = rcBtnCancel; rcBtnOK.top = rcTabCtrl.top + rcItem.Height() + 1; rcBtnOK.bottom = rcBtnOK.top + rcBtnCancel.Height(); pBtnOK->MoveWindow(&rcBtnOK); // reposition the Cancel button. rcBtnCancel = rcBtnOK; rcBtnCancel.top = rcBtnOK.bottom + 5; rcBtnCancel.bottom = rcBtnCancel.top + rcBtnOK.Height(); pBtnCancel->MoveWindow(&rcBtnCancel); // reposition the hex display if (::IsWindow(m_wndHexEdit.m_hWnd)) { CRect rcWnd; rcWnd = rcBtnCancel; rcWnd.top = rcBtnCancel.bottom + 5; rcWnd.bottom = rcWnd.top + 18; m_wndHexEdit.MoveWindow(&rcWnd); } // reposition the eye dropper. if (::IsWindow(m_wndEyeDropper.m_hWnd)) { CRect rcWnd; m_wndEyeDropper.GetWindowRect(&rcWnd); CSize size = rcWnd.Size(); rcWnd.right = rcBtnOK.right; rcWnd.left = rcBtnOK.right - size.cx; rcWnd.bottom = rcTabCtrl.bottom; rcWnd.top = rcTabCtrl.bottom - size.cy; m_wndEyeDropper.MoveWindow(&rcWnd); } // resize the property sheet. CXTPWindowRect rcWindow(this); ClientToScreen(&rcTabCtrl); rcWindow.bottom = rcTabCtrl.bottom + 10; rcWindow.right -= 15; MoveWindow(&rcWindow); }
//**************************************************************************************** BOOL CBCGPropertySheet::OnInitDialog() { BOOL bResult = CPropertySheet::OnInitDialog(); BOOL bReposButtons = FALSE; const int nVertMargin = 5; const int nHorzMargin = 5; CWnd* pWndNavigator = InitNavigationControl (); CRect rectClient; GetClientRect (rectClient); if (m_wndTab.GetSafeHwnd () != NULL) { CTabCtrl* pTab = GetTabControl (); ASSERT_VALID (pTab); CRect rectTab; pTab->GetWindowRect (rectTab); ScreenToClient (rectTab); rectTab.InflateRect (2, 0); if (pTab->GetItemCount () > 0) { CRect rectTabsNew; m_wndTab.GetTabsRect (rectTabsNew); CRect rectTabsOld; pTab->GetItemRect (0, rectTabsOld); const int nOldHeight = rectTabsOld.Height (); const int nNewHeight = rectTabsNew.Height (); if (nNewHeight > nOldHeight) { rectClient.bottom += nNewHeight - nOldHeight + nVertMargin; rectTab.bottom += nNewHeight - nOldHeight; SetWindowPos (NULL, -1, -1, rectClient.Width (), rectClient.Height (), SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE); } } m_wndTab.MoveWindow (rectTab); pTab->ModifyStyle (WS_TABSTOP, 0); pTab->ShowWindow (SW_HIDE); if (pTab->GetItemCount () > 0) { m_wndTab.SetActiveTab (0); } bReposButtons = TRUE; } else if (pWndNavigator != NULL) { CTabCtrl* pTab = GetTabControl (); ASSERT_VALID (pTab); pTab->ModifyStyle (WS_TABSTOP, 0); CRect rectTabItem; pTab->GetItemRect (0, rectTabItem); pTab->MapWindowPoints (this, &rectTabItem); const int nTabsHeight = rectTabItem.Height () + nVertMargin; SetWindowPos (NULL, -1, -1, rectClient.Width () + m_nBarWidth, rectClient.Height () - nTabsHeight + 4 * nVertMargin, SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE); GetClientRect (rectClient); pTab->MoveWindow (m_nBarWidth, -nTabsHeight, rectClient.right, rectClient.bottom - 2 * nVertMargin); CRect rectTab; pTab->GetWindowRect (rectTab); ScreenToClient (rectTab); CRect rectNavigator = rectClient; rectNavigator.right = rectNavigator.left + m_nBarWidth; rectNavigator.bottom = rectTab.bottom; rectNavigator.DeflateRect (1, 1); pWndNavigator->SetWindowPos (&wndTop, rectNavigator.left, rectNavigator.top, rectNavigator.Width (), rectNavigator.Height (), SWP_NOACTIVATE); SetActivePage (GetActivePage ()); bReposButtons = TRUE; } if (bReposButtons) { int ids[] = { IDOK, IDCANCEL, ID_APPLY_NOW, IDHELP }; int nTotalButtonsWidth = 0; for (int iStep = 0; iStep < 2; iStep++) { for (int i = 0; i < sizeof (ids) / sizeof (ids [0]); i++) { CWnd* pButton = GetDlgItem (ids[i]); if (pButton != NULL) { if (ids [i] == IDHELP && (m_psh.dwFlags & PSH_HASHELP) == 0) { continue; } if (ids [i] == ID_APPLY_NOW && (m_psh.dwFlags & PSH_NOAPPLYNOW)) { continue; } CRect rectButton; pButton->GetWindowRect (rectButton); ScreenToClient (rectButton); if (iStep == 0) { // Align buttons at the bottom pButton->SetWindowPos (&wndTop, rectButton.left, rectClient.bottom - rectButton.Height () - nVertMargin, -1, -1, SWP_NOSIZE | SWP_NOACTIVATE); nTotalButtonsWidth = rectButton.right; } else { // Right align the buttons pButton->SetWindowPos (&wndTop, rectButton.left + rectClient.right - nTotalButtonsWidth - nHorzMargin, rectButton.top, -1, -1, SWP_NOSIZE | SWP_NOACTIVATE); } } } } } return bResult; }
void CComPropertySheet::OnActivated(CPropertyPage* pPage) { if(!pPage) return; CRect bounds(30000,30000,-30000,-30000); CRect wr, cr; GetWindowRect(wr); GetClientRect(cr); CSize ws = wr.Size(), cs = cr.Size(); CRect twr, tcr; CTabCtrl* pTC = (CTabCtrl*)GetDlgItem(AFX_IDC_TAB_CONTROL); pTC->GetWindowRect(twr); pTC->GetClientRect(tcr); CSize tws = twr.Size(), tcs = tcr.Size(); if(CWnd* pChild = pPage->GetWindow(GW_CHILD)) { pChild->ModifyStyle(WS_CAPTION|WS_THICKFRAME, 0); pChild->ModifyStyleEx(WS_EX_DLGMODALFRAME, WS_EX_CONTROLPARENT); for(CWnd* pGrandChild = pChild->GetWindow(GW_CHILD); pGrandChild; pGrandChild = pGrandChild->GetNextWindow()) { if(!(pGrandChild->GetStyle()&WS_VISIBLE)) continue; CRect r; pGrandChild->GetWindowRect(&r); pChild->ScreenToClient(r); bounds |= r; } } bounds |= CRect(0,0,0,0); bounds.SetRect(0, 0, bounds.right + max(bounds.left, 4), bounds.bottom + max(bounds.top, 4)); CRect r = CRect(CPoint(0,0), bounds.Size()); pTC->AdjustRect(TRUE, r); r.SetRect(twr.TopLeft(), twr.TopLeft() + r.Size()); ScreenToClient(r); pTC->MoveWindow(r); pTC->ModifyStyle(TCS_MULTILINE, TCS_SINGLELINE); CSize diff = r.Size() - tws; if(!bounds.IsRectEmpty()) { if(CWnd* pChild = pPage->GetWindow(GW_CHILD)) pChild->MoveWindow(bounds); CRect r = twr; pTC->AdjustRect(FALSE, r); ScreenToClient(r); pPage->MoveWindow(CRect(r.TopLeft(), bounds.Size())); } int _afxPropSheetButtons[] = { IDOK, IDCANCEL, ID_APPLY_NOW, IDHELP }; for(int i = 0; i < countof(_afxPropSheetButtons); i++) { if(CWnd* pWnd = GetDlgItem(_afxPropSheetButtons[i])) { pWnd->GetWindowRect(r); ScreenToClient(r); pWnd->MoveWindow(CRect(r.TopLeft() + diff, r.Size())); } } MoveWindow(CRect(wr.TopLeft(), ws + diff)); Invalidate(); }