void COXTabWorkspace::OnNcPaint() { // TODO: Add your message handler code here CWindowDC dc(this); CRect rectClient; GetClientRect(rectClient); CRect rectWindow; GetWindowRect(rectWindow); ScreenToClient(rectWindow); rectClient.OffsetRect(-rectWindow.left, -rectWindow.top); if(rectClient.top<rectClient.bottom && rectClient.top<rectClient.bottom) dc.ExcludeClipRect(rectClient); // Erase parts not drawn SendMessage(WM_ERASEBKGND, (WPARAM)dc.m_hDC); // Draw borders in non-client area rectWindow.OffsetRect(-rectWindow.left, -rectWindow.top); GetTabSkin()->DrawMDITabBorder(&dc, rectWindow, this); // Do not call CTabCtrl::OnNcPaint() for painting messages }
// Crucial function that calculates the size of MDIClient window. Called // by parent MDIFrame window void COXTabClientWnd::CalcWindowRect(LPRECT lpClientRect, UINT nAdjustType) { // TODO: Add your specialized code here and/or call the base class // Now do the laying out HDWP dwh=BeginDeferWindowPos(2); // Move tab window if(::IsWindow(m_tab.m_hWnd) && (m_tab.GetStyle()&WS_VISIBLE)==WS_VISIBLE) { // Get the size of the MDIClient the way it fits into the client area of // the tab control DWORD dwTabStyle=m_tab.GetStyle(); if((dwTabStyle&TCS_BUTTONS)==TCS_BUTTONS && (dwTabStyle&TCS_VERTICAL)==TCS_VERTICAL) { CRect rectTab=lpClientRect; CRect rect(lpClientRect->left,lpClientRect->top, lpClientRect->left+lpClientRect->bottom-lpClientRect->top, lpClientRect->top+lpClientRect->right-lpClientRect->left); // Move tab control ::SetWindowPos(m_tab.m_hWnd,NULL, rect.left,rect.top,rect.Width(), rect.Height(),SWP_NOZORDER|SWP_NOREDRAW); rect.DeflateRect(m_tab.GetOffset(),m_tab.GetOffset()); CRect rectCopy=rect; // Adjust the size of tab control lpClientRect->left+=m_tab.GetOffset(); lpClientRect->top+=m_tab.GetOffset(); lpClientRect->right-=m_tab.GetOffset(); lpClientRect->bottom-=m_tab.GetOffset(); if((dwTabStyle&TCS_RIGHT)==TCS_RIGHT) { m_tab.ModifyStyle(TCS_RIGHT|TCS_VERTICAL,0,SWP_NOREDRAW); m_tab.AdjustRect(FALSE,rect); m_tab.ModifyStyle(0,TCS_RIGHT|TCS_VERTICAL,SWP_NOREDRAW); } else { m_tab.ModifyStyle(TCS_VERTICAL,0,SWP_NOREDRAW); m_tab.AdjustRect(FALSE,rect); m_tab.ModifyStyle(0,TCS_VERTICAL,SWP_NOREDRAW); lpClientRect->left+=rect.top-rectCopy.top; } lpClientRect->top+=rect.left-rectCopy.left; lpClientRect->bottom=lpClientRect->top+rect.Width(); lpClientRect->right=lpClientRect->left+rect.Height(); // Move tab control dwh=::DeferWindowPos(dwh,m_tab.m_hWnd,NULL,rectTab.left, rectTab.top,rectTab.Width(), rectTab.Height(),SWP_NOZORDER); } else { CRect rectTab=lpClientRect; // Move tab control dwh=::DeferWindowPos(dwh,m_tab.m_hWnd,NULL,lpClientRect->left, lpClientRect->top, lpClientRect->right-lpClientRect->left, lpClientRect->bottom-lpClientRect->top, SWP_NOZORDER); // Adjust the size of tab control if(lpClientRect->bottom-lpClientRect->top>2*(int)m_tab.GetOffset()) { lpClientRect->top+=m_tab.GetOffset(); lpClientRect->bottom-=m_tab.GetOffset(); } else { lpClientRect->top=lpClientRect->bottom; } if(lpClientRect->right-lpClientRect->left>2*(int)m_tab.GetOffset()) { lpClientRect->left+=m_tab.GetOffset(); lpClientRect->right-=m_tab.GetOffset(); } else { lpClientRect->left=lpClientRect->right; } if((dwTabStyle&TCS_BUTTONS)==TCS_BUTTONS && (dwTabStyle&TCS_VERTICAL)!=TCS_VERTICAL && (dwTabStyle&TCS_BOTTOM)==TCS_BOTTOM) { int nTop=lpClientRect->top; m_tab.ModifyStyle(TCS_BOTTOM,0,SWP_NOREDRAW); m_tab.AdjustRect(FALSE,lpClientRect); m_tab.ModifyStyle(0,TCS_BOTTOM,SWP_NOREDRAW); lpClientRect->bottom-=lpClientRect->top-nTop; lpClientRect->top-=lpClientRect->top-nTop; } else { // This code is introduced because of severe bug in CTabCtrl MFC // class, which caused a crash. Crash will appear if only one tab // is present. This code will add temporarily one more tab and // hide tabs. // The number of tabs int nNumOfItems = m_tab.GetItemCount(); // Find the size of Tabs RECT itemRect; m_tab.GetItemRect(nNumOfItems-1, &itemRect); if (nNumOfItems == 1 && !m_bOneTabMode || nNumOfItems == 2 && m_bOneTabMode) { if( itemRect.right - itemRect.left + 50 < lpClientRect->right - lpClientRect->left ) { if( m_bOneTabMode == TRUE ) { m_tab.DeleteItem(nNumOfItems-1); m_bOneTabMode = FALSE; } m_tab.AdjustRect(FALSE,lpClientRect); } else { if( nNumOfItems == 1 ) { m_tab.InsertItem(nNumOfItems,_T("")); m_bOneTabMode = TRUE; } } } else m_tab.AdjustRect(FALSE,lpClientRect); } } if(lpClientRect->bottom<lpClientRect->top || lpClientRect->right<lpClientRect->left) ::memset(lpClientRect,0,sizeof(RECT)); ::ShowWindow(m_tab.m_hWnd,SW_SHOWNA); } //lpClientRect->left -= 5; //lpClientRect->right += 5; //lpClientRect->bottom += 5; GetTabSkin()->AdjustChildItemRect(lpClientRect, 5, &m_tab); // Move MDIClient window dwh=::DeferWindowPos(dwh,m_hWnd,NULL,lpClientRect->left,lpClientRect->top, lpClientRect->right-lpClientRect->left, lpClientRect->bottom-lpClientRect->top, SWP_NOZORDER); EndDeferWindowPos(dwh); CWnd::CalcWindowRect(lpClientRect, nAdjustType); }
void COXTabClientWnd::OnNcPaint() { GetTabSkin()->OnNcPaintTabClient(this); }
void COXSkinnedSpinCtrl::OnPaint() { GetTabSkin()->OnPaintSpinCtrl(this); }