void CChatSelector::OnSize(UINT nType, int cx, int cy) { CClosableTabCtrl::OnSize(nType, cx, cy); CRect rect; GetClientRect(&rect); AdjustRect(FALSE, rect); CRect rClose; ::GetWindowRect(m_hwndCloseBtn, &rClose); ::SetWindowPos(m_hwndCloseBtn, NULL, rect.right-7-rClose.Width(), rect.bottom-7-rClose.Height(), rClose.Width(), rClose.Height(), SWP_NOZORDER); CRect rSend; ::GetWindowRect(m_hwndSendBtn, &rSend); ::SetWindowPos(m_hwndSendBtn, NULL, rect.right-7-rClose.Width()-7-rSend.Width(), rect.bottom-7-rSend.Height(), rSend.Width(), rSend.Height(), SWP_NOZORDER); CRect rMessage; ::GetWindowRect(m_hwndMessageBox, &rMessage); ::SetWindowPos(m_hwndMessageBox, NULL, rect.left+7, rect.bottom-9-rMessage.Height(), rect.right-7-rClose.Width()-7-rSend.Width()-21, rMessage.Height(), SWP_NOZORDER); CRect rcChat; GetChatSize(rcChat); TCITEM item; item.mask = TCIF_PARAM; int i = 0; while (GetItem(i++, &item)){ CChatItem* ci = (CChatItem*)item.lParam; ci->log->SetWindowPos(NULL, rcChat.left, rcChat.top, rcChat.Width(), rcChat.Height(), SWP_NOZORDER); } }
void ShapeTabCtrl::ActivateTabDialogs() { int nSel = GetCurSel(); char s[100]; sprintf(s, "%d\n", nSel); OutputDebugString(s); if(m_Dialog[nSel]->m_hWnd) m_Dialog[nSel]->ShowWindow(SW_HIDE); CRect l_rectClient; CRect l_rectWnd; GetClientRect(l_rectClient); AdjustRect(FALSE,l_rectClient); GetWindowRect(l_rectWnd); GetParent()->ScreenToClient(l_rectWnd); l_rectClient.OffsetRect(l_rectWnd.left,l_rectWnd.top); for(int i= 0; i<m_nPageCount; i++) m_Dialog[i]->SetWindowPos(&wndTop, l_rectClient.left, l_rectClient.top, l_rectClient.Width(), l_rectClient.Height(), SWP_HIDEWINDOW); m_Dialog[nSel]->SetWindowPos(&wndTop, l_rectClient.left, l_rectClient.top, l_rectClient.Width(), l_rectClient.Height(), SWP_SHOWWINDOW); m_Dialog[nSel]->ShowWindow(SW_SHOW); }
BOOL CToolTipCtrlX::OnTTShow(NMHDR *pNMHDR, LRESULT *pResult) { //DebugLog(_T("OnTTShow: rcScreen: %d,%d-%d,%d: styles=%08x exStyles=%08x"), m_rcScreen, GetStyle(), GetWindowLong(m_hWnd, GWL_EXSTYLE)); // Win98/Win2000: The only chance to resize a tooltip window is to do it within the TTN_SHOW notification. if (theApp.m_ullComCtrlVer <= MAKEDLLVERULL(5,81,0,0)) { NMTTCUSTOMDRAW nmttcd = {0}; nmttcd.uDrawFlags = DT_NOPREFIX | DT_CALCRECT | DT_EXTERNALLEADING | DT_EXPANDTABS | DT_WORDBREAK; nmttcd.nmcd.hdr = *pNMHDR; nmttcd.nmcd.dwDrawStage = CDDS_PREPAINT; nmttcd.nmcd.hdc = ::GetDC(pNMHDR->hwndFrom); CustomPaint(&nmttcd); ::ReleaseDC(pNMHDR->hwndFrom, nmttcd.nmcd.hdc); CRect rcWnd(nmttcd.nmcd.rc); AdjustRect(&rcWnd); // Win98/Win2000: We have to explicitly ensure that the tooltip window remains within the visible desktop window. EnsureWindowVisible(m_rcScreen, rcWnd); // Win98/Win2000: The only chance to resize a tooltip window is to do it within the TTN_SHOW notification. // Win98/Win2000: Must *not* specify 'SWP_NOZORDER' - some of the tooltip windows may get drawn behind(!) the application window! ::SetWindowPos(pNMHDR->hwndFrom, NULL, rcWnd.left, rcWnd.top, rcWnd.Width(), rcWnd.Height(), SWP_NOACTIVATE /*| SWP_NOZORDER*/); *pResult = TRUE; // Windows API: Suppress default positioning return TRUE; // MFC API: Suppress further routing of this message } // If the TTN_SHOW notification is not sent to the subclassed tooltip control, we would loose the // exact positioning of in-place tooltips which is performed by the tooltip control by default. // Thus it is important that we tell MFC (not the Windows API in that case) to further route this message. *pResult = FALSE; // Windows API: Perform default positioning return FALSE; // MFC API. Perform further routing of this message (to the subclassed tooltip control) }
static bool DrawRect( gui_window *wnd, gui_rect *rect, gui_attr attr, bool fill, bool outline, char draw_char ) { SAREA area; gui_coord coord; if( ( rect->width == 0 ) || ( rect->height == 0 ) || ( (wnd->flags & CONTENTS_INVALID) == 0 ) ) { return( false ); } coord.x = rect->x; coord.y = rect->y; GUIScaleToScreenR( &coord ); area.col = coord.x; area.row = coord.y; coord.x = rect->width; coord.y = rect->height; GUIScaleToScreenR( &coord ); area.width = coord.x; area.height = coord.y; if( AdjustRect( wnd, &area ) ) { if( fill ) { uivfill( &wnd->screen, area, wnd->colours[attr], draw_char ); } if( outline ) { uidrawbox( &wnd->screen, &area, wnd->colours[attr], NULL ); } } return( true ); }
void CChatSelector::OnSize(UINT nType, int cx, int cy) { CClosableTabCtrl::OnSize(nType, cx, cy); CRect rcRect; GetClientRect(&rcRect); AdjustRect(false, rcRect); rcRect.left += 3; rcRect.top += 4; rcRect.right -= 3; rcRect.bottom -= 3; if (GetItemCount() > 0) rcRect.top -= 20; chatout.SetWindowPos(NULL, rcRect.left, rcRect.top, rcRect.Width(), rcRect.Height(), SWP_NOZORDER); TCITEM tcitem; CChatItem *pChatItem; int i = 0; tcitem.mask = TCIF_PARAM; while (GetItem(i++, &tcitem)) { pChatItem = (CChatItem*)tcitem.lParam; pChatItem->m_pLog->SetWindowPos(NULL, rcRect.left, rcRect.top + 20, rcRect.Width(), rcRect.Height() - 20, SWP_NOZORDER); } }
bool GUIDrawLine( gui_window *wnd, gui_point *start, gui_point *end, gui_line_styles style, gui_ord thickness, gui_attr attr ) { gui_point my_start; gui_point my_end; SAREA area; char to_use; /* unused parameters */ (void)style; (void)thickness; my_start = *start; my_end = *end; GUIScaleToScreenRPt( &my_start ); GUIScaleToScreenRPt( &my_end ); area.row = my_start.y; area.height = my_end.y - my_start.y + 1; area.col = my_start.x; area.width = my_end.x - my_start.x + 1; if( my_start.x == my_end.x ) { to_use = DRAW( VERT_FRAME ); } else { if( my_start.y == my_end.y ) { to_use = DRAW( HOR_FRAME ); } else { return( false ); } } if( AdjustRect( wnd, &area ) ) { uivfill( &wnd->screen, area, wnd->colours[attr], to_use ); } return( true ); }
/*************************************************** OnLClicked - overloaded CUGCellType::OnLClicked The handling of the OnLClicked event in the check box cell type is the most important for this cell type. Here is where the desired user actions are evaluated and if necessary the check state is updated. This function determines if the user clicked the left mouse button over the check area on the cell if he did, than the state of the check is changed. **See CUGCellType::OnLClicked for more details about this function Params: col - column that was clicked in row - row that was clicked in rect - rectangle of the cell that was clicked in point - point where the mouse was clicked Return: TRUE - if the event was processed FALSE - if the event was not ***************************************************/ BOOL CUGCheckBoxType::OnLClicked(int col,long row,int updn,RECT *rect,POINT *point) { int top, checkSize; CRect tempRect(0,0,0,0); m_ctrl->GetCellIndirect( col, row, &m_cell ); int style = 0; bool isDisabled = false; if( m_cell.IsPropertySet( UGCELL_CELLTYPEEX_SET )) { style = m_cell.GetCellTypeEx(); isDisabled = (style & UGCT_CHECKBOXDISABLED) > 0; } // If the cell is read only, user should not be // allowed to change the state of the check. if ( m_cell.GetReadOnly() || isDisabled) { return FALSE; } if( updn ) { // calculate height of the cell, based on // given rect parameter. checkSize = rect->bottom - rect->top - (UGCT_CHECKSIZE / 2); // the check box will never be smaller than // UGCT_CHECKSIZE if( checkSize > UGCT_CHECKSIZE ) checkSize = UGCT_CHECKSIZE; top = (rect->bottom - rect->top - checkSize) / 2; tempRect = *rect; AdjustRect ( &tempRect, m_cell.GetAlignment(), m_cell.GetCellTypeEx(), top, checkSize ); // determine if the user clicked within the check box area if(!tempRect.PtInRect ( *point )) return FALSE; int style = 0; if(m_cell.IsPropertySet(UGCELL_CELLTYPEEX_SET)) style = m_cell.GetCellTypeEx(); int val; val = (int)m_cell.GetNumber(); m_cell.SetNumber((val + 1) % ((style & UGCT_CHECKBOX3STATE) ? 3 : 2)); // set the new check state to the data source m_ctrl->SetCell(col,row,&m_cell); // notify the CUGCtrl derived class that the check state was changed OnCellTypeNotify(m_ID,col,row,UGCT_CHECKBOXSET,(long)m_cell.GetNumber()); // redraw the cell to reflect the changes. m_ctrl->RedrawCell(col,row); return TRUE; } return FALSE; }
void CMonitorWnd::UpdateWnd() { if(!IsWindowVisible() || IsIconic()) { return; } CRect rectContainer; GetClientRect(&rectContainer); GetShowRect(&rectContainer); // rectContainer.DeflateRect(1,1); if(m_bAutoAdjustPos) { AdjustRect(&rectContainer); } if(m_bMultiScreen) { CRect rect; int nCount = m_PageList.GetCount(); int i = 0; for(POSITION pos = m_PageList.GetHeadPosition(); pos != NULL; i++) { CWnd *pWnd = m_PageList.GetNext(pos); rect = rectContainer; CalcPageRect(&rect, i, nCount); rect.DeflateRect(WINDOW_PAGE_SPACE, WINDOW_PAGE_SPACE, WINDOW_PAGE_SPACE, WINDOW_PAGE_SPACE); // 窗口之间的间隔 pWnd->MoveWindow(&rect); pWnd->ShowWindow(SW_SHOW); } } else { for(POSITION pos = m_PageList.GetHeadPosition(); pos!=NULL;) { CWnd *pWnd = m_PageList.GetNext(pos); if(pWnd == m_pActivePage) { CRect rect = rectContainer; rect.DeflateRect(WINDOW_PAGE_SPACE, WINDOW_PAGE_SPACE, WINDOW_PAGE_SPACE, WINDOW_PAGE_SPACE); pWnd->MoveWindow(&rect); pWnd->ShowWindow(SW_SHOW); } else { pWnd->MoveWindow(rectContainer.right+1, rectContainer.bottom+1, 1, 1); // pWnd->ShowWindow(SW_HIDE); } } } if(m_bDrawActive && m_PageList.GetCount() > 1) { DrawActivePage(TRUE); } }
CRect CRegisterTabs::GetPageRect() { CWindow parentWin = GetParent(); CRect pageRect; GetWindowRect(&pageRect); parentWin.ScreenToClient(&pageRect); AdjustRect(FALSE, &pageRect); return pageRect; }
void CSkinText::SetText(LPCTSTR newVal) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); // TODO: 在此添加属性处理程序代码 CSkinBase::SetText(newVal); if (m_bAdjustEnable) AdjustRect(NULL); }
void CChatSelector::GetChatSize(CRect& rcChat) { CRect rcClient; GetClientRect(&rcClient); AdjustRect(FALSE, rcClient); rcChat.left = rcClient.left + 4; rcChat.top = rcClient.top + 4; rcChat.right = rcClient.right - 4; rcChat.bottom = rcClient.bottom - 4; }
void CWebWindow::SetBrowserRect(CRect r) { if(!m_bChild) { r.OffsetRect(m_rWindow.left - m_rBrowser.left, m_rWindow.top - m_rBrowser.top); r.InflateRect(0, 0, m_rWindow.Width() - m_rBrowser.Width(), m_rWindow.Height() - m_rBrowser.Height()); AdjustRect(r); SetWindowPos(NULL, r.left, r.top, r.Width(), r.Height(), SWP_NOZORDER); } }
void CMDITabsDialogBar::OnPaint() { CPaintDC dc(this); // device context for painting // prepare dc HGDIOBJ hOldFont = dc.SelectObject(g_PaintManager->m_FontBoldBC); DRAWITEMSTRUCT dis; dis.CtlType = ODT_TAB; dis.CtlID = GetDlgCtrlID(); dis.hwndItem = GetSafeHwnd(); dis.hDC = dc.GetSafeHdc(); dis.itemAction = ODA_DRAWENTIRE; // draw the rest of the border CRect rClient, rPage; GetClientRect(&dis.rcItem); rPage = dis.rcItem; AdjustRect(FALSE, rPage); dis.rcItem.top = rPage.top - 2; DrawMainBorder(&dis); // paint the tabs first and then the borders int nTab = GetItemCount(); int nSel = GetCurSel(); if (!nTab) // no pages added return; while (nTab--) { if (nTab != nSel) { dis.itemID = nTab; dis.itemState = 0; VERIFY(GetItemRect(nTab, &dis.rcItem)); DrawItem(&dis); //DrawItemBorder(&dis); } } // now selected tab if (nSel != -1) { dis.itemID = nSel; dis.itemState = ODS_SELECTED; VERIFY(GetItemRect(nSel, &dis.rcItem)); DrawItem(&dis); //DrawItemBorder(&dis); } dc.SelectObject(hOldFont); }
void CSkinText::SetadjustEnable(VARIANT_BOOL newVal) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); // TODO: 在此添加属性处理程序代码 m_bAdjustEnable = (newVal != 0); if (m_bAdjustEnable){ AdjustRect(NULL); } InvalidateRect(); }
BOOL COFSNcDlg2::LoadWindow(IXMLDOMNode *pXmlRoot, CRect &r, CRect &rMin, CRect &rMax) { ASSERT(pXmlRoot != NULL); CComPtr<IXMLDOMNode> pWindow = NULL; CComBSTR bs, bsBgPath; LoadSkins skin; long nErrorCode = 0; IStreamPtr pStream = NULL; CPaintDC dc(this); WCHAR *szNULL = L"\0x00"; pXmlRoot->selectSingleNode(CComBSTR(L"Window"), &pWindow); if(pWindow) { // Load window size bs.Empty(); SelectChildNode(pWindow, CComBSTR(L"XLen"), NULL, &bs); if(bs.m_str != NULL) r.right = r.left + wcstol(bs.m_str, &szNULL, 10); bs.Empty(); SelectChildNode(pWindow, CComBSTR(L"YLen"), NULL, &bs); if(bs.m_str != NULL) r.bottom = r.top + wcstol(bs.m_str, &szNULL, 10); // Load min size LoadRect(pWindow, _T("MinSize"), rMin); // Load max size LoadRect(pWindow, _T("MaxSize"), rMax); // Load regions for corners DeleteObject(m_rgnTL); DeleteObject(m_rgnTR); DeleteObject(m_rgnBL); DeleteObject(m_rgnBR); m_rgnTL = m_rgnTR = m_rgnBL = m_rgnBR = NULL; LoadRegion(pWindow, _T("TL"), &m_rgnTL); LoadRegion(pWindow, _T("TR"), &m_rgnTR); LoadRegion(pWindow, _T("BL"), &m_rgnBL); LoadRegion(pWindow, _T("BR"), &m_rgnBR); CenterRect(r); AdjustRect(r); // Try Fix Focus behavior [7/23/2002] SetWindowPos(NULL, r.left, r.top, r.Width(), r.Height(), SWP_NOZORDER|SWP_NOACTIVATE); // Load background image m_bBackgroundPicture = (LoadPictures(pWindow) > 0); //pWindow->Release(); } return TRUE; }
/////////////////////////////////////////////////// // call this function to page wnds,when // the window is resized. void CBSWndContainer::UpdateWnd() { if(!IsWindowVisible()||IsIconic()) return; ///////////////////// //计算显示总区域 //得到窗口的设备坐标 CRect rtContainer; GetClientRect(&rtContainer); GetShowRect(&rtContainer); rtContainer.DeflateRect(1,1); //调整Container位置 if(m_bAutoAdjustPos) AdjustRect(&rtContainer); ///////////////////// // if(m_bMultiScreen) { //多屏状态 CRect rt; int nCount=m_PageList.GetCount(); int i=0; for(POSITION pos=m_PageList.GetHeadPosition();pos!=NULL;) { CWnd *p=m_PageList.GetNext(pos); rt=rtContainer; CalcPageRect(&rt,i,nCount); rt.DeflateRect(WINDOW_SPACE,WINDOW_SPACE,WINDOW_SPACE,WINDOW_SPACE); //窗口之间的间隔 p->MoveWindow(&rt); p->ShowWindow(SW_SHOW); i++; } if( m_bDrawActive && m_PageList.GetCount()>1 ) DrawActivePage(TRUE); } else { //单屏状态 for(POSITION pos=m_PageList.GetHeadPosition();pos!=NULL;) { CWnd *p=m_PageList.GetNext(pos); if(p==m_pActivePage) p->MoveWindow(&rtContainer); else { if(m_bFullScreen) p->MoveWindow(0,0,1,1); else p->MoveWindow(rtContainer.right+1,rtContainer.bottom+1,1,1); } } } }
void CWebWindow::CreateAutoKiller(LPCTSTR szSettingsURL, CWnd *pMessageParent, CWnd *pParent, long x, long y, long cx, long cy, LPCTSTR title, LPCTSTR url, BOOL bModal, BOOL bTopMost, BOOL bResizable, UINT DialogTypeId, BOOL bBrowserRect, BOOL bShowToolbar, BOOL bMaximazed) { m_bChild = FALSE; m_bAutoKill = TRUE; m_pMessageParent = pMessageParent; m_bResizable = bResizable; m_strURL = url; m_strSkinSettings = szSettingsURL; m_bBrowserRect = bBrowserRect; m_bShowToolbar = bShowToolbar; CRect r = CRect(CPoint(x,y), CSize(cx,cy)); AdjustRect(r); m_InitialRect = r; if(!Create(IDD, pParent)) { TRACE0("Warning: failed to create CWebWindow.\n"); return ; } m_strTitle = title; SetTitle(m_strTitle); // Set default title if(url != NULL) { CComVariant varUrl = url; m_browser.Navigate2(&varUrl, NULL, NULL, NULL, NULL); } if(DialogTypeId) { EnableSaveRestore(GetString(IDS_OFSMESSENGER),GetString(DialogTypeId)); } if(bTopMost) this->SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); if(url != NULL) { if(bMaximazed) ShowWindow(SW_SHOWMAXIMIZED); else ShowWindow(SW_SHOWNORMAL); SetForegroundWindow(); } else { m_rTarget.SetRectEmpty(); m_bPositionSet = FALSE; m_bSizeSet = FALSE; } }
//---------------------------------------------------------------------------------------------------------- void CXPTabCtrl::OnPaint() { if(!IsExtendedTabTheamedXP()) // if it is not XP or it is not Themes, behave as default { Default(); return; } CPaintDC dc(this); // device context for painting CRect rcClip; rcClip.SetRectEmpty(); dc.GetClipBox(rcClip); // 1st paint the tab body CRect rcPage,rcItem,rcClient; GetClientRect(&rcPage); rcClient=rcPage; AdjustRect(FALSE,rcPage); switch(m_eTabOrientation) { case e_tabTop: rcClient.top =rcPage.top -2; break; case e_tabBottom: rcClient.bottom=rcPage.bottom+3; break; case e_tabLeft: rcClient.left =rcPage.left -1; break; case e_tabRight: rcClient.right =rcPage.right +3; break; default: ASSERT(FALSE); return; } UINT uiVertBottm; uiVertBottm =(m_eTabOrientation&1)? 8:0; // 8=bottom uiVertBottm|=(m_eTabOrientation&2)?16:0; // 16=vertical UINT uiFlags=1|uiVertBottm; // 1=body DrawThemesXpTabItem(&dc, -1, rcClient,uiFlags); // TABP_PANE=9,0,'TAB' int nTab=GetItemCount(); // paint the tabs first and then the borders if(!nTab) return; // no tab pages added // 2nd paint the inactive tabs CRect ; TCHITTESTINFO hti; hti.flags=0; ::GetCursorPos(&hti.pt); ScreenToClient(&hti.pt); int ixHot=HitTest(&hti); int ixSel=GetCurSel(); for(int ixTab=0; ixTab<nTab; ixTab++) { if(ixTab==ixSel) continue; VERIFY(GetItemRect(ixTab, &rcItem)); if(m_eTabOrientation==e_tabLeft) rcItem.right++; uiFlags=uiVertBottm|(ixTab==ixHot?4:0); // 4= hot DrawThemesXpTabItem(&dc,ixTab,rcItem,uiFlags); } // 3rd paint the active selected tab VERIFY(GetItemRect(ixSel, &rcItem)); // now selected tab rcItem.InflateRect(2,2); if(m_eTabOrientation==e_tabTop) rcItem.bottom--; uiFlags=uiVertBottm|2; // 2= selected DrawThemesXpTabItem(&dc, ixSel, rcItem,uiFlags); }
void CXTPPropertyPageTabNavigator::SizeToPage(AFX_SIZEPARENTPARAMS* pLayout, CSize szClient, CRect& rcPage) { CRect rcTabControl(0, 0, szClient.cx, szClient.cy); rcTabControl.DeflateRect(m_rcNavigatorMargin); rcPage = rcTabControl; AdjustRect(FALSE, &rcPage); rcPage.DeflateRect(m_rcPageMargin); AfxRepositionWindow(pLayout, m_hWnd, CRect(m_rcNavigatorMargin.TopLeft(), rcTabControl.Size())); m_brushPage.DeleteObject(); }
// ウィンドウの位置とサイズを設定する inline void WINAPI tapetums::UWnd::Bounds ( INT32 x, INT32 y, INT32 w, INT32 h ) { AdjustRect(m_hwnd, &w, &h); ::SetWindowPos ( m_hwnd, nullptr, x, y, w, h, SWP_NOZORDER | SWP_FRAMECHANGED ); }
void CTabControl::TabResize( int cx, int cy ) { CRect rc(0, 0, cx, cy); MoveWindow( 0, 0, cx, cy, TRUE ); GetClientRect( &rc ); AdjustRect( FALSE, &rc ); rc.InflateRect( -5, -5, -5, -5 ); TABITEMS::iterator it = m_TabItems.begin(); for( int i=0; it!=m_TabItems.end(); it++, i++ ){ (*it)->MoveWindow( &rc, TRUE ); } }
// ウィンドウのサイズを設定する inline void WINAPI tapetums::UWnd::Resize ( INT32 w, INT32 h ) { AdjustRect(m_hwnd, &w, &h); ::SetWindowPos ( m_hwnd, nullptr, 0, 0, w, h, SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED ); }
void CInputOutputTabCtrl::ActivateTabDialogs() { int sel = GetCurSel(); if(sel < 0 || sel > m_numTabs) error("CInputOutputTabCtrl#ActivateTabDialogs(): Unknown selection id."); else { CRect rectClient; GetClientRect(rectClient); AdjustRect(FALSE, rectClient); for(int i = 0; i < m_numTabs; i++) m_wnds[i]->SetWindowPos(&wndTop, rectClient.left, rectClient.top, rectClient.Width(), rectClient.Height(), i == sel ? SWP_SHOWWINDOW : SWP_HIDEWINDOW); } Invalidate(); }
void CXTPTabCtrlButtons::OnWindowPosChanged(WINDOWPOS* lpwndpos) { CWnd::OnWindowPosChanged(lpwndpos); static BOOL bOnWindowPosChanged = FALSE; if (m_bShow && !bOnWindowPosChanged) { if (m_pTabCtrl->GetItemCount() == 0) return; bOnWindowPosChanged = TRUE; CRect rc = AdjustRect(); SetWindowPos(&CWnd::wndTop, rc.left, rc.top, rc.Width(), rc.Height(), SWP_SHOWWINDOW); bOnWindowPosChanged = FALSE; } }
void CXTPTabCtrlButtons::Refresh() { if (!m_hWnd) return; if (m_bShow) { CRect rc = AdjustRect(); SetWindowPos(&CWnd::wndTop, rc.left, rc.top, rc.Width(), rc.Height(), m_pTabCtrl->GetItemCount() > 0 ? SWP_SHOWWINDOW : SWP_HIDEWINDOW); CPoint point; GetCursorPos(&point); ScreenToClient(&point); OnMouseMove(0, point); } Invalidate(FALSE); }
// Get the minimum size. BOOL ClsLTab::OnGetMinSize( ClsSize& szMinSize ) { // Adjust an empty rectangle to include the // tab and frame sizes. ClsRect rc( 0, 0, 0, 0 ); AdjustRect( TRUE, rc ); // We need two pixels of extra room on the tab-side. We need // this because the TCM_ADJUSTRECT message creates a rectangle // which is two pixels closer to the tabs than to the other // rectangle sides. DWORD dwStyle = GetStyle(); if (( dwStyle & TCS_BUTTONS ) != TCS_BUTTONS ) { // When we are vertical we grow two pixels // wider. Otherwise we grow two pixels higher. if ( dwStyle & TCS_VERTICAL ) rc.Right() += 2; else rc.Bottom() += 2; } // The size of the resulting rectangle is the // total size of the tabs including frames etc. szMinSize = rc.Size(); // Iterate the members. ClsTMember *pMember; int cx = 0, cy = 0; for ( pMember = m_Members.GetFirst(); pMember; pMember = m_Members.GetNext( pMember )) { // Initialize structure. ClsSize sz( 0, 0 ); // Get dimensions. if ( pMember->m_pMember->OnGetMinSize( sz )) { // Any larger values? if ( sz.CX() > cx ) cx = sz.CX(); if ( sz.CY() > cy ) cy = sz.CY(); } } // Store values. szMinSize.Add( cx, cy ); return TRUE; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // CChatSelector message handlers /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void CChatSelector::Init() { CRect rcRect; GetClientRect(&rcRect); AdjustRect(false, rcRect); rcRect.DeflateRect(7, 7); ModifyStyle(0, WS_CLIPCHILDREN); chatout.Create(WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_HSCROLL | WS_VSCROLL | ES_MULTILINE | ES_READONLY | ES_NOHIDESEL, rcRect, this, IDC_CHATOUT); chatout.ModifyStyleEx(0, WS_EX_STATICEDGE, SWP_FRAMECHANGED); chatout.SetFont(&g_App.m_pMDlg->m_fontDefault); chatout.SetTitle(GetResString(IDS_MESSAGES)); chatout.m_dwFlags |= (HTC_ISLIMITED | HTC_ISWORDWRAP); chatout.AppendText(CLIENT_NAME, RGB(153,51,102), CLR_DEFAULT, HTC_LINK); chatout.AppendText(_T(" Version ") CURRENT_VERSION_LONG _T(" - ") + GetResString(IDS_CHAT_WELCOME) + _T('\n'), RGB(153,51,102)); VERIFY((m_Timer = SetTimer(20, 1500, 0))); }
void CChatSelector::GetChatSize(CRect& rcChat) { CRect rcClose, rcSend, rcMessage; ::GetWindowRect(m_hwndCloseBtn, &rcClose); ::GetWindowRect(m_hwndSendBtn, &rcSend); ::GetWindowRect(m_hwndMessageBox, &rcMessage); int iTop = rcClose.Height() > rcSend.Height() ? rcClose.Height() : rcSend.Height(); if (iTop < rcMessage.Height()) iTop = rcMessage.Height(); CRect rcClient; GetClientRect(&rcClient); AdjustRect(FALSE, rcClient); rcChat.left = rcClient.left + 7; rcChat.top = rcClient.top + 7; rcChat.right = rcChat.left + rcClient.right - 18; rcChat.bottom = rcChat.top + rcClient.Height() - 7 - iTop - 14; }
// Size the ctrl covers of the child windows of this control and in turn // size the child window controls. void TZNoteBook::PostMoveCtrl( ) { #if 0 #ifdef DEBUG_ALL TraceLineS( "TZNoteBook::PostMoveCtrl", "" ); #endif CRect rect; GetClientRect( rect ); // TraceRect( "TZNoteBook::PostMoveCtrl ClientRect", rect ); AdjustRect( FALSE, &rect ); // TraceRect( "TZNoteBook::PostMoveCtrl Adjusted ClientRect", rect ); // Get the rect in client coords TZPainterCtrl *pCtrl; pCtrl = this; while ( pCtrl ) pCtrl = pCtrl->AdjustCtrlRect( rect, TRUE ); // TraceRect( "TZNoteBook::PostMoveCtrl Client Coords", rect ); for ( zSHORT nPos = 0; nPos < m_pPainterWindow->m_nCtrlCnt; nPos++ ) { pCtrl = m_pPainterWindow->m_CtrlList[ nPos ]; if ( pCtrl->m_pCtrlParent == this ) { if ( pCtrl->m_pCtrlCover ) pCtrl->m_pCtrlCover->SetWindowPos( 0, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_NOZORDER | SWP_NOREDRAW ); // pCtrl->m_pCtrlCover->MoveWindow( rect, TRUE ); // pCtrl->m_pWndCtrl->MoveWindow( rect, TRUE ); } } #endif }
void CXTPPropertyPageTabNavigator::PageToSize(AFX_SIZEPARENTPARAMS* pLayout, CSize szPage, CRect& rcPage, CSize& szClient) { CRect rcTabControl(0, 0, szPage.cx, szPage.cy); CClientDC dc(this); GetPaintManager()->RepositionTabControl(this, &dc, rcTabControl); AdjustRect(TRUE, &rcTabControl); rcTabControl.InflateRect(m_rcPageMargin); szClient = CSize(rcTabControl.Width() + m_rcNavigatorMargin.left + m_rcNavigatorMargin.right, rcTabControl.Height() + m_rcNavigatorMargin.top + m_rcNavigatorMargin.bottom); rcPage = CRect(CPoint(m_rcNavigatorMargin.left - rcTabControl.left, m_rcNavigatorMargin.top - rcTabControl.top), szPage); AfxRepositionWindow(pLayout, m_hWnd, CRect(m_rcNavigatorMargin.TopLeft(), rcTabControl.Size())); GetPaintManager()->RepositionTabControl(this, &dc, CRect(0, 0, rcTabControl.Width(), rcTabControl.Height())); }