void CPlayerSeekBar::CreateThumb(bool bEnabled, CDC& parentDC) { auto& pThumb = bEnabled ? m_pEnabledThumb : m_pDisabledThumb; pThumb = std::unique_ptr<CDC>(new CDC()); if (pThumb->CreateCompatibleDC(&parentDC)) { COLORREF white = GetSysColor(COLOR_WINDOW), shadow = GetSysColor(COLOR_3DSHADOW), light = GetSysColor(COLOR_3DHILIGHT), bkg = GetSysColor(COLOR_BTNFACE); CRect r(GetThumbRect()); r.MoveToXY(0, 0); CRect ri(GetInnerThumbRect(bEnabled, r)); CBitmap bmp; VERIFY(bmp.CreateCompatibleBitmap(&parentDC, r.Width(), r.Height())); VERIFY(pThumb->SelectObject(bmp)); pThumb->Draw3dRect(&r, light, 0); r.DeflateRect(0, 0, 1, 1); pThumb->Draw3dRect(&r, light, shadow); r.DeflateRect(1, 1, 1, 1); CBrush b(bkg); pThumb->FrameRect(&r, &b); r.DeflateRect(0, 1, 0, 1); pThumb->FrameRect(&r, &b); r.DeflateRect(1, 1, 0, 0); pThumb->Draw3dRect(&r, shadow, bkg); if (bEnabled) { r.DeflateRect(1, 1, 1, 2); CPen whitePen(PS_INSIDEFRAME, 1, white); CPen* old = pThumb->SelectObject(&whitePen); pThumb->MoveTo(r.left, r.top); pThumb->LineTo(r.right, r.top); pThumb->MoveTo(r.left, r.bottom); pThumb->LineTo(r.right, r.bottom); pThumb->SelectObject(old); pThumb->SetPixel(r.CenterPoint().x, r.top, 0); pThumb->SetPixel(r.CenterPoint().x, r.bottom, 0); } } else { ASSERT(FALSE); } }
void CPlayerSeekBar::CreateThumb(bool bEnabled, CDC& parentDC) { auto& pThumb = bEnabled ? m_pEnabledThumb : m_pDisabledThumb; pThumb = std::unique_ptr<CDC>(new CDC()); if (pThumb->CreateCompatibleDC(&parentDC)) { COLORREF white = GetSysColor(COLOR_WINDOW), shadow = GetSysColor(COLOR_3DSHADOW), light = GetSysColor(COLOR_3DHILIGHT), bkg = GetSysColor(COLOR_BTNFACE); CRect r(GetThumbRect()); r.MoveToXY(0, 0); CRect ri(GetInnerThumbRect(bEnabled, r)); CBitmap bmp; VERIFY(bmp.CreateCompatibleBitmap(&parentDC, r.Width(), r.Height())); VERIFY(pThumb->SelectObject(bmp)); pThumb->Draw3dRect(&r, light, 0); r.DeflateRect(0, 0, 1, 1); pThumb->Draw3dRect(&r, light, shadow); r.DeflateRect(1, 1, 1, 1); if (bEnabled) { pThumb->ExcludeClipRect(ri); ri.InflateRect(0, 1, 0, 1); pThumb->FillSolidRect(ri, white); pThumb->SetPixel(ri.CenterPoint().x, ri.top, 0); pThumb->SetPixel(ri.CenterPoint().x, ri.bottom - 1, 0); } pThumb->ExcludeClipRect(ri); ri.InflateRect(1, 1, 1, 1); pThumb->Draw3dRect(&ri, shadow, bkg); pThumb->ExcludeClipRect(ri); CBrush b(bkg); pThumb->FillRect(&r, &b); } else { ASSERT(FALSE); } }
void CPlayerSeekBar::OnPaint() { CPaintDC dc(this); COLORREF dark = GetSysColor(COLOR_GRAYTEXT), white = GetSysColor(COLOR_WINDOW), shadow = GetSysColor(COLOR_3DSHADOW), light = GetSysColor(COLOR_3DHILIGHT), bkg = GetSysColor(COLOR_BTNFACE); // Thumb { auto& pThumb = m_bEnabled ? m_pEnabledThumb : m_pDisabledThumb; if (!pThumb) { CreateThumb(m_bEnabled, dc); ASSERT(pThumb); } CRect r(GetThumbRect()); CRect ri(GetInnerThumbRect(m_bEnabled, r)); CRgn rg, rgi; VERIFY(rg.CreateRectRgnIndirect(&r)); VERIFY(rgi.CreateRectRgnIndirect(&ri)); ExtSelectClipRgn(dc, rgi, RGN_DIFF); VERIFY(dc.BitBlt(r.TopLeft().x, r.TopLeft().y, r.Width(), r.Height(), pThumb.get(), 0, 0, SRCCOPY)); ExtSelectClipRgn(dc, rg, RGN_XOR); m_lastThumbRect = r; } const CRect channelRect(GetChannelRect()); // Chapters if (m_bHasDuration) { CAutoLock lock(&m_csChapterBag); if (m_pChapterBag) { for (DWORD i = 0; i < m_pChapterBag->ChapGetCount(); i++) { REFERENCE_TIME rtChap; if (SUCCEEDED(m_pChapterBag->ChapGet(i, &rtChap, nullptr))) { long chanPos = channelRect.left + ChannelPointFromPosition(rtChap); CRect r(chanPos, channelRect.top, chanPos + 1, channelRect.bottom); if (r.right < channelRect.right) { r.right++; } ASSERT(r.right <= channelRect.right); dc.FillSolidRect(&r, dark); dc.ExcludeClipRect(&r); } else { ASSERT(FALSE); } } } } // Channel { dc.FillSolidRect(&channelRect, m_bEnabled ? white : bkg); CRect r(channelRect); r.InflateRect(1, 1); dc.Draw3dRect(&r, shadow, light); dc.ExcludeClipRect(&r); } // Background { CRect r; GetClientRect(&r); dc.FillSolidRect(&r, bkg); } }
void CPlayerSeekBar::OnPaint() { CPaintDC dc(this); // device context for painting bool fEnabled = m_fEnabled && m_start < m_stop; COLORREF white = GetSysColor(COLOR_WINDOW), shadow = GetSysColor(COLOR_3DSHADOW), light = GetSysColor(COLOR_3DHILIGHT), bkg = GetSysColor(COLOR_BTNFACE); // thumb { CRect r = GetThumbRect(), r2 = GetInnerThumbRect(); CRect rt = r, rit = r2; dc.Draw3dRect(&r, light, 0); r.DeflateRect(0, 0, 1, 1); dc.Draw3dRect(&r, light, shadow); r.DeflateRect(1, 1, 1, 1); CBrush b(bkg); dc.FrameRect(&r, &b); r.DeflateRect(0, 1, 0, 1); dc.FrameRect(&r, &b); r.DeflateRect(1, 1, 0, 0); dc.Draw3dRect(&r, shadow, bkg); if(fEnabled) { r.DeflateRect(1, 1, 1, 2); CPen white(PS_INSIDEFRAME, 1, white); CPen* old = dc.SelectObject(&white); dc.MoveTo(r.left, r.top); dc.LineTo(r.right, r.top); dc.MoveTo(r.left, r.bottom); dc.LineTo(r.right, r.bottom); dc.SelectObject(old); dc.SetPixel(r.CenterPoint().x, r.top, 0); dc.SetPixel(r.CenterPoint().x, r.bottom, 0); } dc.SetPixel(r.CenterPoint().x+5, r.top-4, bkg); { CRgn rgn1, rgn2; rgn1.CreateRectRgnIndirect(&rt); rgn2.CreateRectRgnIndirect(&rit); ExtSelectClipRgn(dc, rgn1, RGN_DIFF); ExtSelectClipRgn(dc, rgn2, RGN_OR); } } // channel { CRect r = GetChannelRect(); dc.FillSolidRect(&r, fEnabled ? white : bkg); r.InflateRect(1, 1); dc.Draw3dRect(&r, shadow, light); dc.ExcludeClipRect(&r); } // background { CRect r; GetClientRect(&r); CBrush b(bkg); dc.FillRect(&r, &b); } // Do not call CDialogBar::OnPaint() for painting messages }