TEMPLATE void CDialogMinTrayBtn<BASE>::MinTrayBtnDraw() { if (!MinTrayBtnIsVisible()) return; CDC *pDC= GetWindowDC(); if (!pDC) return; // panic! if (IsWindowsClassicStyle()) { CBrush black(GetSysColor(COLOR_BTNTEXT)); CBrush gray(GetSysColor(COLOR_GRAYTEXT)); CBrush gray2(GetSysColor(COLOR_BTNHILIGHT)); // button if (m_bMinTrayBtnUp) pDC->DrawFrameControl(MinTrayBtnGetRect(), DFC_BUTTON, DFCS_BUTTONPUSH); else pDC->DrawFrameControl(MinTrayBtnGetRect(), DFC_BUTTON, DFCS_BUTTONPUSH | DFCS_PUSHED); // dot CRect btn = MinTrayBtnGetRect(); btn.DeflateRect(2,2); UINT caption = MinTrayBtnGetSize().cy + (CAPTION_BUTTONSPACE * 2); UINT pixratio = (caption >= 14) ? ((caption >= 20) ? 2 + ((caption - 20) / 8) : 2) : 1; UINT pixratio2 = (caption >= 12) ? 1 + (caption - 12) / 8: 0; UINT dotwidth = (1 + pixratio * 3) >> 1; UINT dotheight = pixratio; CRect dot(CPoint(0,0), CPoint(dotwidth, dotheight)); CSize spc((1 + pixratio2 * 3) >> 1, pixratio2); dot -= dot.Size(); dot += btn.BottomRight(); dot -= spc; if (!m_bMinTrayBtnUp) dot += CPoint(1,1); if (m_bMinTrayBtnEnabled) { pDC->FillRect(dot, &black); } else { pDC->FillRect(dot + CPoint(1,1), &gray2); pDC->FillRect(dot, &gray); } } else {
template <class BASE> void CDialogMinTrayBtn<BASE>::MinTrayBtnDraw() { if (!MinTrayBtnIsVisible()) return; CDC *pDC = GetWindowDC(); if (pDC == NULL) return; CRect rcBtn = MinTrayBtnGetRect(); UINT uiState; if (IsWindowsClassicStyle()) { // Button uiState = DFCS_BUTTONPUSH; if (!m_bMinTrayBtnUp) uiState |= DFCS_PUSHED; pDC->DrawFrameControl(rcBtn, DFC_BUTTON, uiState); // Dot rcBtn.DeflateRect(2,2); UINT iCptWdth = MinTrayBtnGetSize().cy + (CAPTION_BUTTONSPACE << 1); UINT iPixRatio1 = iCptWdth >= 20 ? 2 + ((iCptWdth - 20) >> 3) : (iCptWdth >= 14 ? 2 : 1); UINT iPixRatio2 = iCptWdth >= 12 ? 1 + ((iCptWdth - 12) >> 3) : 0; CRect rcDot(CPoint(0, 0), CPoint((1 + iPixRatio1 * 3) >> 1, iPixRatio1)); CSize szSpc((1 + iPixRatio2 * 3) >> 1, iPixRatio2); rcDot += rcBtn.BottomRight() - rcDot.Size() - szSpc; if (!m_bMinTrayBtnUp) rcDot += CPoint(1, 1); int iColor = COLOR_BTNTEXT; if (!m_bMinTrayBtnEnabled) { iColor = COLOR_GRAYTEXT; pDC->FillSolidRect(rcDot + CPoint(1, 1), GetSysColor(COLOR_BTNHILIGHT)); } pDC->FillSolidRect(rcDot, GetSysColor(iColor)); } else {
if (!m_bMinTrayBtnUp) dot += CPoint(1,1); if (m_bMinTrayBtnEnabled) { pDC->FillRect(dot, &black); } else { pDC->FillRect(dot + CPoint(1,1), &gray2); pDC->FillRect(dot, &gray); } } else { // VisualStylesXP CRect btn = MinTrayBtnGetRect(); int iState; if (!m_bMinTrayBtnEnabled) iState = TRAYBS_DISABLED; else if (GetStyle() & WS_DISABLED) iState = MINBS_NORMAL; else if (m_bMinTrayBtnHitTest) iState = (m_bMinTrayBtnCapture) ? MINBS_PUSHED : MINBS_HOT; else iState = MINBS_NORMAL; // inactive if (!m_bMinTrayBtnActive) iState += 4; // inactive state TRAYBS_Ixxx if (m_bmMinTrayBtnBitmap.m_hObject && _TransparentBlt) {