void CAimComboCtrl::OnPaint () { CRect rect; CPaintDC dc (this); GetClientRect (&rect); m_rectBtn = rect; m_rectBtn.left = rect.right - 13; m_rectText = rect; m_rectText.right = rect.right - 13; m_rectText.DeflateRect (2, 1); dc.FillSolidRect (rect, ::GetSysColor (COLOR_WINDOW)); dc.FillSolidRect (m_rectBtn, ::GetSysColor (COLOR_BTNFACE)); dc.DrawIcon (m_rectBtn.CenterPoint () - CSize (5, 5), theApp.LoadIcon (IDI_PIC_DOWNARROW)); dc.DrawEdge (m_rectBtn, BDR_RAISEDINNER, BF_RECT); CDC dcMem; dcMem.CreateCompatibleDC (&dc); CBitmap *pOld = dcMem.GetCurrentBitmap (); dcMem.SelectObject (m_pbmpImage); dc.SetBkMode (TRANSPARENT); //dc.SetROP2 (R2_NOP); //dc.SetStretchBltMode (STRETCH_HALFTONE); //dc.StretchBlt (m_rectText.left, m_rectText.top, m_rectText.Width(), m_rectText.Height (), &dcMem, 0, 0, // 16, 16, SRCCOPY); dcMem.SelectObject (pOld); dcMem.DeleteDC (); Paint (dc); }
void CPartialGroupBox::Draw3dLine(CPaintDC & dc, LPCRECT lpRect, COLORREF clrTopLeft, COLORREF /*clrBottomRight*/) { int x = lpRect->left; int y = lpRect->top; int cx = lpRect->right - lpRect->left; //int cy = lpRect->bottom - lpRect->top; dc.FillSolidRect(x, y, cx - 1, 1, clrTopLeft); //dc.FillSolidRect(x, y, 1, cy - 1, clrTopLeft); //dc.FillSolidRect(x + cx, y, -1, cy, clrBottomRight); //dc.FillSolidRect(x, y + cy, cx, -1, clrBottomRight); }
void CChildView::OnPaint() { CPaintDC *dc; CDC *pdc; CRgn ur; ur.CreateRectRgn(0, 0, 0, 0); GetUpdateRgn(&ur); CRect cr; GetClientRect(&cr); if (theApp.m_bStarted && !theApp.m_map.IsEmpty()) { // pdc = &dc; m_MemDC.SelectClipRgn(&ur); pdc = &m_MemDC; theApp.m_map.DrawMap(*pdc, &cr, &ur); CRect r; // r = cr; ur.GetRgnBox(r); // r.InflateRect(1, 1); if (r.left < 0) r.left = 0; if (r.top < 0) r.top = 0; dc = new CPaintDC(this); // device context for painting dc->BitBlt(r.left, r.top, r.Width(), r.Height(), &m_MemDC, r.left, r.top, SRCCOPY); } else { dc = new CPaintDC(this); // device context for painting if (theApp.m_bStarted) { dc->SetTextAlign(TA_CENTER); CPoint cp = cr.CenterPoint(); CString s; s.Format("There are no maps in '%s'", theApp.m_map.m_sMapsPath); dc->ExtTextOut(cp.x, cp.y - dc->GetOutputTextExtent("W").cy/2, ETO_OPAQUE, &cr, s, NULL); } else { dc->FillSolidRect(cr, 0); } } delete dc; }
void CAfficheMesPol::AxeGraph(CPaintDC &dc) { dc.FillSolidRect(PosGrX(0),PosGrY(255),PosGrX(255)-20,PosGrY(0)-40,RGB(255,255,255)); CPen PenAxe(PS_SOLID,1,RGB(0,0,0)); dc.SelectObject(&PenAxe); dc.MoveTo(PosGrX(0),PosGrY(0)); dc.LineTo(PosGrX(0),PosGrY(255)); dc.MoveTo(PosGrX(0),PosGrY(0)); dc.LineTo(PosGrX(255),PosGrY(0)); for(int i=5;i<255;i+=5) { dc.MoveTo(PosGrX(0),PosGrY(i)); dc.LineTo(PosGrX(3),PosGrY(i)); dc.MoveTo(PosGrX(i),PosGrY(0)); dc.LineTo(PosGrX(i),PosGrY(3)); } DeleteObject(&PenAxe); }
void CSeparator::DrawTextImpl(CPaintDC &dc, CString text, CRect clientRect) { auto &g = Globals::Instance(); HFONT hOldFont = dc.SelectFont(g.sep.font); dc.SetTextColor(g.sep.textColor); dc.SetBkColor(g.bkColor); const int margin = 0; CSize textSize; dc.GetTextExtent(text, -1, &textSize); CRect textRect(clientRect); textRect.left = margin; textRect.right = textRect.left + textSize.cx + 2 * 3; dc.FillSolidRect(textRect, g.bkColor); textRect.InflateRect(-3, 0); dc.DrawText(text, -1, textRect, DT_VCENTER | DT_CENTER | DT_SINGLELINE); dc.SelectFont(hOldFont); }
void PreviousImagesView::DrawEmptyView(CPaintDC& dc) { DWORD dwColor = ::GetSysColor(COLOR_APPWORKSPACE); dc.FillSolidRect(&dc.m_ps.rcPaint, dwColor); // output "no image" string CRect rcClient; GetClientRect(&rcClient); HFONT oldFont = dc.SelectFont(GetFont()); dc.SetBkColor(dwColor); dc.SetTextColor(GetSysColor(COLOR_WINDOWTEXT)); CString cszText = m_manager.ImagesAvail() ? _T("<Loading image...>") : _T("<No images available>"); // add DT_SINGLELINE to center both vertically and horizontally dc.DrawText(cszText, cszText.GetLength(), rcClient, DT_CENTER | DT_VCENTER | DT_SINGLELINE); dc.SelectFont(oldFont); }
void CLeftPanelDlgBar::OnPaint() { CPaintDC dc (this); // device context for painting CDC dcMem; dcMem.CreateCompatibleDC (&dc); CBrush brush (::GetSysColor (COLOR_3DFACE)); CMDIChildWnd* pChild = ((CMDIFrameWnd*) AfxGetMainWnd ())->MDIGetActive (); CRect r; GetClientRect (&r); if (pChild == NULL) { dc.FillRect (&r, &brush); goto __end; } CCdCoverCreator2Doc* pDoc = (CCdCoverCreator2Doc*) pChild->GetActiveDocument (); if (pDoc == NULL) { // look whether the last doc is still valid POSITION pos = AfxGetApp ()->GetFirstDocTemplatePosition (); CDocTemplate* pDocTmpl = AfxGetApp ()->GetNextDocTemplate (pos); bool bIsValid = false; for (pos = pDocTmpl->GetFirstDocPosition (); pos; ) if (pDocTmpl->GetNextDoc (pos) == m_pLastDoc) { bIsValid = true; break; } if (bIsValid) pDoc = m_pLastDoc; else m_pLastDoc = NULL; } else m_pLastDoc = pDoc; if (pDoc == NULL) { dc.FillRect (&r, &brush); goto __end; } CRect rect; GetClientRect (rect); rect.DeflateRect (5, 5, 5, 5); if (pDoc->m_pStyle != NULL) { CCdCoverCreator2View* pView = (CCdCoverCreator2View*) pChild->GetActiveView (); if (pView == NULL) goto __end; int nHeight = (rect.Width () / 5) * 4; CRenderDC rdc (&dc, nHeight, pView->GetDocument ()->m_pStyle); m_y[Cover] = 5; m_y[Back] = m_y[Cover] + rdc.GetHeight (Cover) + 10; m_y[Inlay] = m_y[Back] + rdc.GetHeight (Back) + 10; m_y[Label] = m_y[Inlay] + rdc.GetHeight (Inlay) + 10; m_y[Booklet] = m_y[Label] + rdc.GetHeight (Label) + 10; if (m_bRedraw) { CLabelRenderer renderer (pDoc->m_pTracks, pDoc->m_pDataCDInfo, reinterpret_cast<CBackgroundInfo**> (&(pDoc->m_pBackground)), pDoc->m_listFloatingObjects, *(pDoc->m_pStyle)); for (int i = 0; i < NUM_RENDER_TYPES - 1; i++) { if ((RenderType) i == Booklet) continue; CRect rectBmp (0, 0, rdc.GetWidth ((RenderType) i) + 5, /*nHeight*/(m_y[i + 1] - m_y[i]) + 5); m_Bitmap[i].DeleteObject (); m_Bitmap[i].CreateCompatibleBitmap (&dc, rectBmp.right, rectBmp.bottom); // render dcMem.SelectObject (&m_Bitmap[i]); dcMem.FillRect (rectBmp, &brush); renderer.Render (CRenderDC (&dcMem, nHeight, pDoc->m_pStyle), (RenderType) i, true); } m_bRedraw = false; } // draw the bitmaps int x[] = { (rect.Width () - rdc.GetWidth (Cover)) / 2 + 5, (rect.Width () - rdc.GetWidth (Back)) / 2 + 5, (rect.Width () - rdc.GetWidth (Inlay)) / 2 + 5, (rect.Width () - rdc.GetWidth (Label)) / 2 + 5, (rect.Width () - rdc.GetWidth (Cover)) / 2 + 5 }; dc.SetViewportOrg (x[Booklet], m_y[Booklet]); DrawBooklet (&dc, rdc.GetWidth (Cover), rdc.GetWidth (Cover) / 2, pDoc, pView->GetRenderType ()); dc.SetViewportOrg (0, 0); CBrush* pOldBrush = dc.GetCurrentBrush (); for (int i = 0; i < NUM_RENDER_TYPES; i++) { CRect rectArea (rect.left, m_y[i], rect.right, m_y[i] + ((RenderType) i == Booklet ? rdc.GetWidth (Cover) / 2 : rdc.GetHeight ((RenderType) i))); if ((RenderType) i != Booklet) { dcMem.SelectObject (m_Bitmap[i]); if (pDoc->m_pStyle->m_bHasRenderType[i]) dc.SelectStockObject (WHITE_BRUSH); else { dc.SetTextColor (RGB (0xff, 0xff, 0xff)); dc.SetBkColor (RGB (0x7f, 0x7f, 0x7f)); dc.SelectObject (dc.GetHalftoneBrush ()); } //dc.BitBlt (x[i], m_y[i], rdc.GetWidth ((RenderType) i) + 5, /*nHeight*/(m_y[i + 1] - m_y[i]) + 5, &dcMem, 0, 0, MERGECOPY); dc.BitBlt (x[i], m_y[i], rectArea.Width (), rectArea.Height () + 4, &dcMem, 0, 0, MERGECOPY); } // marker Mark (&dc, rectArea, pView->GetRenderType () != (RenderType) i); } dc.SelectObject (pOldBrush); } __end: #ifdef PEROUTKA_FEDORISIN CBitmap* pOldBmp = (CBitmap*) dcMem.SelectObject (m_bmpLogo); dc.FillSolidRect (0, r.bottom - 32, 148, 32, RGB (0xff, 0xff, 0xff)); dc.BitBlt ((148 - 80) / 2, r.bottom - 32, 80, 32, &dcMem, 0, 0, SRCCOPY); // dcMem.SelectObject (pOldBmp); #endif dcMem.DeleteDC (); brush.DeleteObject (); }