void CCJControlBar::OnWindowPosChanged(WINDOWPOS FAR* lpwndpos) { CControlBar::OnWindowPosChanged(lpwndpos); // Find on which side are we docked m_nDockBarID = GetParent()->GetDlgCtrlID(); if (m_bInRecalcNC == FALSE) { m_bInRecalcNC = TRUE; // Force recalc the non-client area SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED); m_bInRecalcNC = FALSE; } if (m_bButtons) { ASSERT(m_ImageList); if (IsFloating()) { m_btnClose.ShowWindow(SW_HIDE); m_btnMinim.ShowWindow(SW_HIDE); return; } else { m_btnClose.ShowWindow(SW_SHOW); m_btnMinim.ShowWindow(SW_SHOW); } CRect rcClose(GetButtonRect()); CRect rcMinim(GetButtonRect()); if (IsHorzDocked()) { rcMinim.OffsetRect(0,14); m_btnMinim.SetIcon(m_ImageList->ExtractIcon(2),CSize(13,13)); } else { rcClose.OffsetRect(14,0); m_btnMinim.SetIcon(m_ImageList->ExtractIcon(1),CSize(13,13)); } m_btnClose.MoveWindow(rcClose); m_btnMinim.MoveWindow(rcMinim); } Invalidate(); }
void CCtrlMessageBar::DoNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp) { m_nMessageBarHeight = 0; if (m_bShowMessageBar && bCalcValidRects && ! m_sMessageBarText.IsEmpty()) { int nHeight = 15; int nHeightMin = 0; int nLeftOffset = 2; CFont* pFont = m_pCtrlMessageBarThis->GetFont(); CDC* pDC = m_pCtrlMessageBarThis->GetDC(); if (m_nMessageBarImage != -1 && m_imlMessageBar.m_hImageList != NULL) { IMAGEINFO ii; m_imlMessageBar.GetImageInfo(m_nMessageBarImage, &ii); nHeightMin = abs(ii.rcImage.bottom - ii.rcImage.top); nLeftOffset += abs(ii.rcImage.right - ii.rcImage.left) + 2 + 2; nHeightMin += 2; } if (m_bMessageBarCloseButton) { CFont font; font.CreatePointFont(CLOSE_BUTTON_FONT_SIZE, CLOSE_BUTTON_FONT, pDC); CFont* pFontOld2 = pDC->SelectObject(&font); CRect rcClose(0, 0, 1, 1); pDC->DrawText(CLOSE_BUTTON_CHAR, rcClose, DT_CALCRECT | CLOSE_BUTTON_DRAW_FLAGS); nHeightMin = max(nHeightMin, rcClose.Height() + 1 + 1); nLeftOffset += rcClose.Width() + 2 + 2; pDC->SelectObject(pFontOld2); } if (pDC != NULL) { CFont* pFontOld = pDC->SelectObject(pFont); CRect rc; m_pCtrlMessageBarThis->GetClientRect(&rc); rc.left += nLeftOffset; nHeight = pDC->DrawText(m_sMessageBarText, rc, DT_CALCRECT | (m_bWrapMessageBarText ? s_dwDrawTextFlagsWrap : s_dwDrawTextFlags)); pDC->SelectObject(pFontOld); } nHeight += 2; nHeight = max(nHeight, nHeightMin); nHeight += 2; lpncsp->rgrc[0].top += nHeight; m_nMessageBarHeight = nHeight; } }
CRect CCtrlMessageBar::GetCloseButtonRect(CRect& rc) const { // given the message bar rect, return the close button rect if (! m_bMessageBarCloseButton) return CRect(rc.right, rc.top, rc.right, rc.top); CRect rcClose(rc); CDC* pDC = m_pCtrlMessageBarThis->GetDC(); CFont font; font.CreatePointFont(CLOSE_BUTTON_FONT_SIZE, CLOSE_BUTTON_FONT, pDC); CFont* pFontOld = pDC->SelectObject(&font); pDC->DrawText(CLOSE_BUTTON_CHAR, rcClose, DT_CALCRECT | CLOSE_BUTTON_DRAW_FLAGS); pDC->SelectObject(pFontOld); rcClose.bottom += 1 + 1; rcClose.right += 2 + 2; // line up the top-right of the close button with the top-right of the message bar rcClose.OffsetRect(rc.right - rcClose.right, 0); // adjust the message bar text area rc.right = rcClose.left - 2; return rcClose; }