void CZoominTool::OnMouseMove(_CVIEW* pView, UINT nFlags, CPoint& point) { ::SetCursor(AfxGetApp()->LoadCursor(IDC_ZOOMIN)); CDC* pDC = NULL; pDC = pView->GetDC(); if (pDC == NULL) return; if (!c_bDown) { DeleteDC(pDC->m_hDC); return; } CRect oldRect(c_PtDown,c_PtOld); CRect newRect(c_PtDown,point); //CRect TrackRect; // TrackRect.SetRect(m_StartPoint,point); CPen Pen; if (!Pen.CreatePen(PS_SOLID, 1, RGB(0,0,0))) return; CPen *pOldPen = pDC->SelectObject(&Pen); //int oldDrawMode = m_pDC->SetROP2(R2_XORPEN); int oldDrawMode = pDC->SetROP2(R2_NOT); pDC->SelectStockObject(NULL_BRUSH); pDC->Rectangle(oldRect); pDC->Rectangle(newRect); pDC->SetROP2(oldDrawMode); pDC->SelectObject(pOldPen); Pen.DeleteObject(); DeleteDC(pDC->m_hDC); CDrawTool::OnMouseMove(pView, nFlags, point); }
void CZoominTool::OnLButtonUp(_CVIEW* pView, UINT nFlags, CPoint& point) { CDC* pDC = NULL; pDC = pView->m_pDC; if (pDC == NULL) return; CRect newRect(c_PtDown,point); CPen Pen; if (!Pen.CreatePen(PS_SOLID, 1, RGB(0,0,0))) return; CPen *pOldPen = pDC->SelectObject(&Pen); int oldDrawMode = pDC->SetROP2(R2_NOT); pDC->SelectStockObject(NULL_BRUSH); pDC->Rectangle(newRect); pDC->SetROP2(oldDrawMode); pDC->SelectObject(pOldPen); Pen.DeleteObject(); int cx = abs(point.x - c_PtDown.x); int cy = abs(point.y - c_PtDown.y); if (cx<5 && cy<5) { pView->m_Graphics.ZoomAtPoint(&c_PtDown,1.2); pView->Refresh(); } else { pView->m_Graphics.ZoomInAtExtent(&c_PtDown,&point); pView->Refresh(); } CDrawTool::OnLButtonUp(pView, nFlags, point); }
// 画测点标尺 void CGraphInstrumentList::DrawMarkPointNb(CDC* pDC, int iGridX) { int iStep = 1; if(iGridX <= 2 * m_iGridXMin) { iStep = 5; } CPen oPen; CPen* pOldPen; oPen.CreatePen(PS_SOLID, 2, RGB(255, 0, 0)); pOldPen = pDC->SelectObject(&oPen); int iPointNb; CString strPointNb; CRect oRect; for(unsigned int i = 0; i < m_uiColumnCount; i++) { if((((i + 1) % iStep) == 0) || (i == 0)) { iPointNb = GetPointNbByColumnIndex(i); strPointNb.Format("%d", iPointNb); oRect.left = i * iGridX - m_iGridXMin / 2; oRect.right = oRect.left + m_iGridXMax; oRect.top = -50; oRect.bottom = 0; } pDC->DrawText(strPointNb, &oRect, DT_LEFT); } pDC->SelectObject(pOldPen); }
void QuoteTableCtrlGeneralSort::OnDraw(CDC* pDC) { CHSGridCtrl::OnDraw(pDC); CRect rect, itemrect, rccvlient; GetClientRect(rccvlient); ClientToScreen(rccvlient); GetClientRect(rect); itemrect = rect; if (GetRowCount() <=0) return; int rowheight = GetRowHeight(0); itemrect.bottom = rowheight-1; COLORREF bkcolor = GetBkColor(); COLORREF textcolor = RGB(155,155,155); if (m_iColorFontProt) textcolor = m_iColorFontProt->GetQuoteTabTextColor(); CFont* pFont; CFont* pOldFont; BOOL bCreat = FALSE; if (m_iFont) pFont = (CFont*)m_iFont->GetQuoteColHeadFont(); else { pFont = new CFont(); VERIFY(pFont->CreateFont(16,0, 0,0,FW_NORMAL,FALSE,FALSE,0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,ANTIALIASED_QUALITY, DEFAULT_PITCH | FF_SWISS, _T("宋体"))); bCreat = TRUE; } pOldFont = pDC->SelectObject(pFont); pDC->SetBkColor( GetSysColor(COLOR_HIGHLIGHT) ); pDC->SetBkColor(bkcolor); pDC->SetTextColor(textcolor); pDC->SetBkColor(bkcolor); pDC->DrawText(m_pTableFlag->strTitle, &itemrect, DT_CENTER | DT_SINGLELINE | DT_NOPREFIX | DT_VCENTER); pDC->SelectObject(pOldFont); if (bCreat) pFont->DeleteObject(); CPen hPen; hPen.CreatePen(PS_SOLID ,1,RGB(200,0,0)); CPen* hOldPen = pDC->SelectObject(&hPen); pDC->MoveTo(CPoint(itemrect.left,itemrect.bottom)); pDC->LineTo(CPoint(itemrect.right, itemrect.bottom)); pDC->SelectObject(hOldPen); hPen.DeleteObject(); }
void CHeadCtrol::PaintDragLine(int pos, bool bOne ) //ÍÏקÏßÌõ { CDC* pDC = CWnd::FromHandle(m_hListWnd)->GetWindowDC(); int nRop = pDC->SetROP2(R2_NOTXORPEN); CRect lrect; CWnd::FromHandle(m_hListWnd)->GetClientRect( &lrect ); CPen pen; pen.CreatePen(0, 1, RGB(0, 0, 0)); CPen *pOP = pDC->SelectObject(&pen); if( posPre != -1 ) { pDC->MoveTo( posPre,0 ); pDC->LineTo( posPre,lrect.bottom ); } if( !bOne ) { pDC->MoveTo( pos,0 ); pDC->LineTo( pos,lrect.bottom ); } pDC->SetROP2(nRop); pDC->SelectObject(pOP); pen.DeleteObject(); ReleaseDC(pDC); posPre = pos; }
/// <param name="rect">bounding rectangle</param> /// <param name="fore">foreground text color</param> /// <param name="back">background color</param> /// <param name="font">font including face, point size, and style.</param> /// <param name="text">text string to display in the designated font.</param> /// <param name="cursor">cursor reticle.</param> void Canvas::DrawEditString(const rect_t &rect, const rect_t &box, color_t fore, color_t back, const Font& font, align_t align, const string_t &text, size_t cursor) { RECT rc = {0}; privateDrawString(box, fore, back, font, align, text); if (cursor == 0) { _dc.DrawText(_T("A"), 1, &rc, DT_CALCRECT|DT_SINGLELINE); rc.right = rc.left; } else _dc.DrawText(&text[0], cursor, &rc, DT_CALCRECT|DT_SINGLELINE); // zero height? if (rc.top == rc.bottom) rc.bottom = box.high; // yes: zap for cursor bar. // draw cursor CPen pen; pen.CreatePen(PS_SOLID, 1, fore); _dc.SelectPen(pen); // TODO: code to clip line segments. _dc.MoveTo(rc.right, rc.top); _dc.LineTo(rc.right, rc.bottom); BitBlt(rect.x, rect.y, rect.wide, rect.high, _dc, box.x, box.y, SRCCOPY); }
void CGroup1::Draw9(CDC* pDC, CSize& ScreenSize, int CameraX, int CameraY, // position on camera long x, long y, // position on screen long lFactorX, long lFactorY, long CameraFactor, COLORREF Pix, COLORREF PrevPix, DWORD) { long Diff = Pix - PrevPix; long R = GetRValue(Diff); long G = GetGValue(Diff); long B = GetBValue(Diff); COLORREF CurrColor = SelectColor(R, G, B); long lastX = min(x+lFactorX, ScreenSize.cx); long lastY = min(y+lFactorY, ScreenSize.cy); CRect r(x, y, lastX, lastY); CBrush b(RGB(0,0,0)); CPen pen; pen.CreatePen(PS_SOLID, 1, CurrColor); CPen* pOld = pDC->SelectObject(&pen); CBrush* pOldB = pDC->SelectObject(&b); pDC->MoveTo(R*3,G); pDC->LineTo(CameraX*3, B*3); b.DeleteObject(); pen.DeleteObject(); pDC->SelectObject(pOld); pDC->SelectObject(pOldB); }
void CLeftPanelDlgBar::Mark(CDC *pDC, CRect r, bool bErase) { m_rcCurMark = r; CPen pen (PS_SOLID, 1, bErase ? GetSysColor (COLOR_3DFACE) : RGB (0x6B, 0x8B, 0xBD)); CPen* pOldPen = pDC->SelectObject (&pen); CBrush* pOldBrush = (CBrush*) pDC->SelectStockObject (HOLLOW_BRUSH); // adjust marker rectangle r.left--; r.top--; r.right--; r.bottom += 3; // draw pDC->Rectangle (&r); // draw shade CPen penShadow (PS_GEOMETRIC | PS_ENDCAP_SQUARE, 2, bErase ? GetSysColor (COLOR_3DFACE) : RGB (0x51, 0x70, 0xA7)); pDC->SelectObject (&penShadow); pDC->MoveTo (r.right + 1, r.top + 1); POINT pt[2] = {r.right + 1, r.bottom, r.left + 1, r.bottom}; pDC->PolylineTo (pt, 2); // clean up pDC->SelectObject (pOldPen); pen.DeleteObject (); penShadow.DeleteObject (); pDC->SelectObject (pOldBrush); }
void CText::DrawHotPoints(CDC *pDC) { LOGPEN tLogPen; tLogPen.lopnColor=RGB(0,0,0); tLogPen.lopnStyle=PS_DOT; tLogPen.lopnWidth.x=1; CPen tPen; tPen.CreatePenIndirect(&tLogPen); CPen *pOldPen=(CPen *)pDC->SelectObject(&tPen); CBrush *pOldBrush=(CBrush *)pDC->SelectStockObject(NULL_BRUSH); pDC->SetROP2(R2_NOTXORPEN); long x1,y1,x2,y2; UPtoLP(Left()-DELTA,Top()-DELTA,&x1,&y1); UPtoLP(Right()+DELTA,Bottom()+DELTA,&x2,&y2); pDC->Rectangle(x1,y1,x2,y2); /* pDC->SelectStockObject(GRAY_BRUSH); pDC->SelectStockObject(NULL_PEN); pDC->SetROP2(R2_NOT); long x5,y5,x6,y6; UPtoLP((m_lx1+m_lx2)/2,m_ly1-DELTA,&x5,&y5); UPtoLP((m_lx1+m_lx2)/2,m_ly2+DELTA,&x6,&y6); DrawHotPoint(pDC,x5,y5); DrawHotPoint(pDC,x6,y6); */ pDC->SetROP2(R2_COPYPEN); pDC->SelectObject(pOldBrush); pDC->SelectObject(pOldPen); pDC->SelectObject(pOldBrush); }
void CBorderStyleEdit::DrawEditFrame( CDC* pDC ) { CRect rcItem; GetClientRect( &rcItem ); if( m_bNowEditing ) pDC->SetTextColor( m_dwActiveTextColor ); else pDC->SetTextColor( m_dwTextColor ); pDC->SetBkColor( m_dwBgColor ); if( m_bShowBorder ) { DWORD dwBorderColor = m_dwBorderColor; if( m_bWarning ) { dwBorderColor = (m_bBlink == TRUE ? RGB(255, 0, 0) : m_dwBorderColor); } rcItem.InflateRect( 1, 1, 1, 1 ); CBrush* pOldBrush = (CBrush*)pDC->SelectStockObject( NULL_BRUSH ); CPen BorderPen; BorderPen.CreatePen( PS_SOLID, m_nBorderWidth, dwBorderColor ); CPen* pOldPen = pDC->SelectObject( &BorderPen ); //pDC->Rectangle( rcItem ); pDC->SelectObject( pOldPen ); pDC->SelectObject( pOldBrush ); } }
void CColorBtnDlg::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpd) { CDC dc; CPen nullpen; CBrush brush; CPen *oldpen; CBrush *oldbrush; // Draw the wells using the current color table nullpen.CreateStockObject(NULL_PEN); brush.CreateSolidBrush(colors[nIDCtl-IDC_COLOR1]); dc.Attach(lpd->hDC); oldpen = dc.SelectObject(&nullpen); oldbrush = dc.SelectObject(&brush); lpd->rcItem.right++; lpd->rcItem.bottom++; dc.Rectangle(&lpd->rcItem); dc.SelectObject(oldpen); dc.SelectObject(oldbrush); dc.Detach(); CDialog::OnDrawItem(nIDCtl, lpd); }
void CSatelliteView::OnDraw(CDC* pDC) { CSatelliteDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); CRect rectClient; GetClientRect(&rectClient); double x,y; x=(rectClient.right-rectClient.left)/2; y=(rectClient.bottom-rectClient.top)/2; pDC->SelectStockObject(NULL_BRUSH); CPen newPen; CPen newPenx; CPen newPen_satellite; newPen.CreatePen(PS_SOLID,pDoc->m_widthDoc,pDoc->m_orbitColor); newPen_satellite.CreatePen(PS_SOLID,2,pDoc->m_satelliteColor); newPenx.CreatePen(PS_SOLID,pDoc->m_widthDocx,pDoc->m_orbitColor); CPen *poldPen; poldPen=pDC->SelectObject(&newPen); pDC->Ellipse(x-pDoc->m_radiiDoc,y-pDoc->m_radiiDoc,x+pDoc->m_radiiDoc,y+pDoc->m_radiiDoc); poldPen=pDC->SelectObject(&newPenx); pDC->Ellipse(x-pDoc->m_radiiDocx,y-pDoc->m_radiiDocx,x+pDoc->m_radiiDocx,y+pDoc->m_radiiDocx); poldPen=pDC->SelectObject(&newPen_satellite); pDC->Ellipse(x+pDoc->m_radiiDoc*cos(pDoc->m_angle)-15,y+pDoc->m_radiiDoc*sin(pDoc->m_angle)-15,x+pDoc->m_radiiDoc*cos(pDoc->m_angle)+15,y+pDoc->m_radiiDoc*sin(pDoc->m_angle)+15); pDC->Ellipse(x+pDoc->m_radiiDocx*cos(pDoc->m_angle)-15,y+pDoc->m_radiiDocx*sin(pDoc->m_angle)-15,x+pDoc->m_radiiDocx*cos(pDoc->m_angle)+15,y+pDoc->m_radiiDocx*sin(pDoc->m_angle)+15); // TODO: add draw code for native data here }
//畫圈 void MsrFlow::DrawACircle(CPoint point) { /* 在此畫出來的圈是以160*160大小 以中心點為參考點畫出來的 原函數是以左上角為參考點,在此修正誤差,將決定好的參考點 再往左往上各算一個半徑的距離,畫出來 */ //設定圈圈顏色=與背景相反顏色 COLORREF CircleColor; CircleColor = RGB(255,255,255)-BackGroundColor; //設定畫圈目標物位址 CWnd* pWndGrid = GetDlgItem(IDC_COLOR_PATTERN); CDC* pDC = pWndGrid->GetDC(); //設定畫筆 CPen aPen; aPen.CreatePen(PS_INSIDEFRAME,5,CircleColor); //設定暫存畫筆空間 CPen* pOldPen = pDC ->SelectObject(&aPen); //對圓修正誤差,從左上調到中心(開方形可繪區塊) CPoint StartDrawPoint(-80,-80); CPoint EndDrawPoint(80,80); CRect* pRect = new CRect(point+StartDrawPoint,point+EndDrawPoint); //畫下去(畫下圓形,起點0,0,終點0,0) CPoint Start(0,0); CPoint End(0,0); pDC->Arc(pRect,Start,End); //畫筆換回預設值 pDC->SelectObject(pOldPen); }
void DlgPalette::DrawCell(CDC *pDC, long index) { CRect rect; if (!GetCellRect(index, rect)) return; CBrush brush; if (m_editalpha){ brush.CreateSolidBrush(RGB(m_pal[index].rgbReserved, m_pal[index].rgbReserved , m_pal[index].rgbReserved )); }else{ brush.CreateSolidBrush(RGB(m_pal[index].rgbRed , m_pal[index].rgbGreen , m_pal[index].rgbBlue )); } CPen pen; if (index==m_selected) pen.CreatePen(PS_SOLID, 2, ::GetSysColor(COLOR_3DDKSHADOW)); else pen.CreatePen(PS_SOLID, 1, ::GetSysColor(COLOR_3DSHADOW)); CBrush* pOldBrush = (CBrush*) pDC->SelectObject(&brush); CPen* pOldPen = (CPen*) pDC->SelectObject(&pen); // Draw the cell colour pDC->Rectangle(rect); // restore DC and cleanup pDC->SelectObject(pOldBrush); pDC->SelectObject(pOldPen); brush.DeleteObject(); pen.DeleteObject(); }
void CTEditCtrlWnd::OnPaint() { CPaintDC dc(this); CString strWindow, strCurreny; CRect rcClient; GetClientRect(rcClient); dc.FillSolidRect(rcClient, m_clrFace); dc.SetBkMode(TRANSPARENT); /*dc.Draw3dRect(rcClient, m_clrBottomRight, m_clrTopLeft);*/ CPen pen; pen.CreatePen(PS_SOLID, 1, RGB(200, 200, 200)); CPen* pOldPen = (CPen*)dc.SelectObject(&pen); dc.Rectangle(rcClient); dc.SelectObject(pOldPen); pen.DeleteObject(); rcClient.DeflateRect(2, 2, 2, 2); GetWindowText(strWindow); strCurreny = GetCurrencyText(strWindow); strCurreny = strWindow; CFont *pOldFont = dc.SelectObject(&m_fontDefault); dc.DrawText(strCurreny, rcClient, DT_VCENTER | DT_SINGLELINE | DT_RIGHT); dc.SelectObject(pOldFont); }
// Draw a circle void CEllipse::Draw(CDC* pDC, CElement* pElement) { // Create a pen for this object and // initialize it to the object color and line width of m_PenWidth CPen aPen; if(!aPen.CreatePen(m_LineStyle, m_PenWidth, this==pElement ? SELECT_COLOR : m_Color)) { // Pen creation failed AfxMessageBox(_T("Pen creation failed drawing a circle"), MB_OK); AfxAbort(); } // Select the pen CPen* pOldPen = pDC->SelectObject(& aPen); // Select a null brush CBrush* pOldBrush = (CBrush*)pDC->SelectStockObject(NULL_BRUSH); // Now draw the circle pDC->Ellipse(m_EnclosingRect); pDC->SelectObject(pOldPen); // Restore the old pen pDC->SelectObject(pOldBrush); // Restore the old brush }
BOOL CStroke::DrawStrokeIn( CDC* pDC, int nRestricWidth, int nRestricHeight ) { CPen penStroke; if( !penStroke.CreatePen(PS_SOLID, m_nPenWidth, m_rgbPenColor)) return FALSE; CPen* pOldPen = pDC->SelectObject( &penStroke ); CPoint prev = m_pointArray[0]; pDC->MoveTo( m_pointArray[0] ); for( int i=1; i < m_pointArray.GetSize(); i++ ) { if (m_pointArray[i].x>nRestricWidth || m_pointArray[i].y > nRestricHeight) { prev = m_pointArray[i]; continue; } if (prev.x>nRestricWidth || prev.y > nRestricHeight) { pDC->MoveTo(m_pointArray[i]); } pDC->LineTo( m_pointArray[i] ); prev = m_pointArray[i]; } pDC->SelectObject( pOldPen ); return TRUE; }
void CThumbnail::OnPaint() { PAINTSTRUCT paintstruct; CDC* pDC; pDC=BeginPaint(&paintstruct); paintstruct.fErase=TRUE; CRect rect; GetClientRect(rect); // first draw scaled version of thumbnail underneath title bar CRButton* button; button=GETDLGITEM(IDJ_TITLE); CRect buttonrect; button->GetClientRect(buttonrect); rect.top+=buttonrect.bottom; // +1 prevents gaps int halfheight=rect.Height()/2+1; int offset=rect.Height()/8+1; int offset2=rect.Height()/16+1; DrawScaledBitmap(pDC,FIL_THUMBTOP,rect.left,rect.top-offset,rect.Width(),halfheight+offset2); DrawScaledBitmap(pDC,FIL_THUMBBOT,rect.left,rect.top+halfheight-offset2,rect.Width(),halfheight+offset2); // now draw the box in the appropriate position CRect rect2; m_pView->GetClientRect(rect2); m_boxSize=CSize((rect.right*rect2.right)/m_pView->m_size.cx, (rect.Height()*rect2.bottom)/m_pView->m_size.cy); if(m_LButtonDown==FALSE) { m_point=CPoint(((m_pView->m_scrollpoint.x*rect.right)/m_pView->m_size.cx)+(m_boxSize.cx/2), ((m_pView->m_scrollpoint.y*rect.Height())/m_pView->m_size.cy)+(m_boxSize.cy/2)+rect.top); m_point=m_point+offsetfix; //quick thumbnail fix } m_point.x=max(m_boxSize.cx/2,m_point.x); m_point.y=max((m_boxSize.cy/2)+rect.top,m_point.y); m_point.x=min(rect.right-(m_boxSize.cx/2),m_point.x); m_point.y=min(rect.bottom-(m_boxSize.cy/2),m_point.y); CPen pen; pen.CreatePen(PS_SOLID,2,RGB(255,0,0)); // red pen pDC->SelectObject(&pen); if (m_boxSize.cx<20) { pDC->MoveTo(m_point.x-10,m_point.y); pDC->LineTo(m_point.x-m_boxSize.cx/2,m_point.y); pDC->MoveTo(m_point.x+10,m_point.y); pDC->LineTo(m_point.x+m_boxSize.cx/2,m_point.y); } if (m_boxSize.cy<20) { pDC->MoveTo(m_point.x,m_point.y-10); pDC->LineTo(m_point.x,m_point.y-m_boxSize.cy/2); pDC->MoveTo(m_point.x,m_point.y+10); pDC->LineTo(m_point.x,m_point.y+m_boxSize.cy/2); } pDC->MoveTo(m_point.x-(m_boxSize.cx/2),m_point.y-(m_boxSize.cy/2)); pDC->LineTo(m_point.x+(m_boxSize.cx/2),m_point.y-(m_boxSize.cy/2)); pDC->LineTo(m_point.x+(m_boxSize.cx/2),m_point.y+(m_boxSize.cy/2)); pDC->LineTo(m_point.x-(m_boxSize.cx/2),m_point.y+(m_boxSize.cy/2)); pDC->LineTo(m_point.x-(m_boxSize.cx/2),m_point.y-(m_boxSize.cy/2)); EndPaint(&paintstruct); }
void CArc::Draw(CDC *pDC) { if(m_lStatus!=ST_NOMAL) return; LOGPEN tPen=m_pen; UPtoLP(m_pen.lopnWidth.x,m_pen.lopnWidth.y,&tPen.lopnWidth.x,&tPen.lopnWidth.y); CPen pen; pen.CreatePenIndirect(&tPen); CPen *pOldPen=pDC->SelectObject(&pen); long x1,y1,x2,y2,x3,y3,x4,y4; x1=m_lx1; y1=m_ly1; if(m_lx1>m_lx2){ m_lx1=m_lx2; m_lx2=x1; } if(m_ly1>m_ly2){ m_ly1=m_ly2; m_ly2=y1; } UPtoLP(m_lx1,m_ly1,&x1,&y1); UPtoLP(m_lx2,m_ly2,&x2,&y2); if(m_lx3==0 && m_ly3==0 && m_lx4==0 && m_ly4==0){ m_lx4=(m_lx2+m_lx1)/2; m_ly4=m_ly2+DELTA*2; m_lx3=m_lx2+DELTA*2; m_ly3=(m_ly1+m_ly2)/2; } UPtoLP(m_lx3,m_ly3,&x3,&y3); UPtoLP(m_lx4,m_ly4,&x4,&y4); pDC->Arc(x1,y1,x2,y2,x3,y3,x4,y4); pDC->SelectObject(pOldPen); }
void CEllipse::Draw(CDC *pDC) { if(m_lStatus!=ST_NOMAL) return; LOGPEN tPen=m_pen; UPtoLP(m_pen.lopnWidth.x,m_pen.lopnWidth.y,&tPen.lopnWidth.x,&tPen.lopnWidth.y); CPen pen; pen.CreatePenIndirect(&tPen); CPen *pOldPen=pDC->SelectObject(&pen); CBrush brush; brush.CreateBrushIndirect(&m_brush); CBrush *pOldBrush=pDC->SelectObject(&brush); pDC->SetBkMode(TRANSPARENT); long x1,y1,x2,y2; x1=m_lx1; y1=m_ly1; if(m_lx1>m_lx2){ m_lx1=m_lx2; m_lx2=x1; } if(m_ly1>m_ly2){ m_ly1=m_ly2; m_ly2=y1; } UPtoLP(m_lx1,m_ly1,&x1,&y1); UPtoLP(m_lx2,m_ly2,&x2,&y2); pDC->Ellipse(x1,y1,x2,y2); pDC->SelectObject(pOldPen); pDC->SelectObject(pOldBrush); }
void CReportEntityLine::Draw( CDC* dc, CRect rect ) /* ============================================================ Function : CReportEntityLine::Draw Description : Draws the object. Access : Public Return : void Parameters : CDC* dc - "CDC" to draw to CRect rect - True (zoomed) rectangle to draw to. Usage : Called from "CDiagramEditor::DrawObjects". ============================================================*/ { CPen pen; const float* table = Drawer::GetColorByIndex(GetBorderColor()); COLORREF clr = RGB((int)(table[0]*255.0f),(int)(table[1]*255.0f),(int)(table[2]*255.0f)); pen.CreatePen( PS_SOLID, GetBorderThickness(), clr ); dc->SelectObject( &pen ); dc->MoveTo( rect.TopLeft() ); dc->LineTo( rect.BottomRight() ); dc->SelectStockObject( BLACK_PEN ); }
LRESULT PeersToolbarSearchPrompt::onPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { CPaintDC dc(m_hWnd); CRect r; GetClientRect(r); CBrush brush; brush.CreateSolidBrush(m_backgroundColor); dc.FillRect(r, brush); CPen pen; pen.CreatePen(PS_SOLID, 1, RGB(132,0,0)); const HPEN oldPen = dc.SelectPen(pen); dc.MoveTo(r.left, r.top + 5); dc.LineTo(r.left, r.bottom - 5); dc.SelectPen(oldPen); const int len = GetWindowTextLength(); if (len > 0) { r.left += m_leftPadding + 1; AutoArray<TCHAR> caption(len + 1); GetWindowText(caption, len + 1); const HFONT oldFont = dc.SelectFont(WinUtil::boldFont); dc.SetBkMode(TRANSPARENT); dc.SetTextColor(RGB(255,255,255)); dc.DrawText(caption, len, r, DT_SINGLELINE | DT_VCENTER); dc.SelectFont(oldFont); } return 0; }
/// <param name="list">list of points</param> /// <param name="count">number of points</param> /// <param name="width">pen width for drawing line</param> /// <param name="color">pen color</param> /// <param name="fill">polygon fill color</param> void Canvas::DrawPolygon(const rect_t &rect, const rect_t &box, point_t list[], size_t count, meter_t width, color_t color, color_t fill) { CPen pen; CBrush brush; std::vector<POINT> pts; POINT pt = {0}; for (size_t i = 0; i < count; i++) { pt.x = list[i].x - box.x + rect.x; pt.y = list[i].y - box.y + rect.y; pts.push_back(pt); } CRgn region; region.CreateRectRgn(rect.x, rect.y, rect.x + rect.wide, rect.y + rect.high); SelectClipRgn(region); brush.CreateSolidBrush(fill); pen.CreatePen(PS_SOLID, width, color); HPEN hSavePen = SelectPen(pen); HBRUSH hSaveBrush = SelectBrush(brush); Polygon(&pts[0], pts.size()); SelectPen(hSavePen); SelectBrush(hSaveBrush); SelectClipRgn(NULL); }
//////////////////////////////////////////////////////////////////////////////// // // FUNCTION: DrawArrow // // DESCRIPTION: Draws drop down arrow, we could use DrawFrameControl - a bit too // messy // // NOTES: // // MAINTENANCE: // Name: Date: Version: Notes: // NT ALMOND 210100 1.0 Origin // //////////////////////////////////////////////////////////////////////////////// void CCoolBtn::DrawArrow(CDC* pDC,CPoint ArrowTip) { CPoint ptDest; CPen* pPen = pDC->GetCurrentPen(); LOGPEN logPen; pPen->GetLogPen(&logPen); pDC->SetPixel(ArrowTip, logPen.lopnColor); ArrowTip -= CPoint(1,1); pDC->MoveTo(ArrowTip); ptDest = ArrowTip; ptDest += CPoint(3,0); pDC->LineTo(ptDest); ArrowTip -= CPoint(1,1); pDC->MoveTo(ArrowTip); ptDest = ArrowTip; ptDest += CPoint(5,0); pDC->LineTo(ptDest); ArrowTip -= CPoint(1,1); pDC->MoveTo(ArrowTip); ptDest = ArrowTip; ptDest += CPoint(7,0); pDC->LineTo(ptDest); }
void CHSScrollBar::DrawBorder( CDC* pDC ) { CPen Pen; Pen.CreatePenIndirect(&m_logpen.GetPen(HsLOGPEN::hor)); CPen* pOldPen; pOldPen = pDC->SelectObject(&Pen); // 画上边框 pDC->MoveTo(m_rect.left, m_rect.top); pDC->LineTo(m_rect.right, m_rect.top); // 画下边框 pDC->MoveTo(m_rect.left, m_rect.bottom); pDC->LineTo(m_rect.right, m_rect.bottom); Pen.DeleteObject(); Pen.CreatePenIndirect(&m_logpen.GetPen(HsLOGPEN::ver)); pDC->SelectObject(&Pen); // 画左边框 pDC->MoveTo(m_rect.left, m_rect.top); pDC->LineTo(m_rect.left, m_rect.bottom); // 画右边框 pDC->MoveTo(m_rect.right, m_rect.top); pDC->LineTo(m_rect.right, m_rect.bottom); pDC->SelectObject(pOldPen); Pen.DeleteObject(); }
//----- OnSizeParent() ------------------------------------------------------ void BCTabBarCtrl::OnNcPaint() { CRect rectCLient, rectNC; GetWindowRect(rectNC); rectNC.OffsetRect(-rectNC.left, -rectNC.top); CWindowDC dc(this); CPen pen; DWORD dwSysGray = GetSysColor(COLOR_BTNFACE); dc.DrawEdge(rectNC, EDGE_ETCHED, BF_TOP); rectNC.DeflateRect(0, 2, 0, 0); CBrush brush(dwSysGray); dc.FrameRect(rectNC, &brush); for(int iIndx = 0; iIndx < 2; iIndx++) { rectNC.DeflateRect(1, 1, 1, 1); dc.FrameRect(rectNC, &brush); } rectNC.DeflateRect(0, 1, 0, 2); pen.DeleteObject(); pen.CreatePen(PS_GEOMETRIC | PS_SOLID, 1, dwSysGray); dc.SelectObject(&pen); dc.MoveTo(rectNC.left, rectNC.top); dc.LineTo(rectNC.right, rectNC.top); }
void CSplitterControl::DrawLine(CDC* pDC, int x, int y) { int nRop = pDC->SetROP2(R2_NOTXORPEN); CRect rcWnd; int d = 1; GetWindowRect(rcWnd); CPen pen; pen.CreatePen(0, 1, RGB(200, 200, 200)); CPen *pOP = pDC->SelectObject(&pen); if (m_nType == SPS_VERTICAL) { pDC->MoveTo(m_nX - d, rcWnd.top); pDC->LineTo(m_nX - d, rcWnd.bottom); pDC->MoveTo(m_nX + d, rcWnd.top); pDC->LineTo(m_nX + d, rcWnd.bottom); } else // m_nType == SPS_HORIZONTAL { pDC->MoveTo(rcWnd.left, m_nY - d); pDC->LineTo(rcWnd.right, m_nY - d); pDC->MoveTo(rcWnd.left, m_nY + d); pDC->LineTo(rcWnd.right, m_nY + d); } pDC->SetROP2(nRop); pDC->SelectObject(pOP); }
void KGClassButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { CClientDC dc(this); COLORREF color; CRect rect; CPen pen; GetClientRect(&rect); dc.FillRect(&rect, &CBrush(RGB(255, 255, 255))); if (m_nStateFlag) { color = RGB(255, 2, 2); } else { color = RGB(100, 100, 100); } pen.CreatePen(PS_SOLID, 2, color); dc.SelectObject(&pen); if (m_hButtonIcon) { dc.DrawIcon(rect.left, rect.top, m_hButtonIcon); } if (m_nSelFlag) { dc.MoveTo(rect.left, rect.top); dc.LineTo(rect.right, rect.top); dc.LineTo(rect.right, rect.bottom); dc.LineTo(rect.left, rect.bottom); dc.LineTo(rect.left, rect.top - 2); } }
// Draw a curve void CCurve::Draw(CDC* pDC, CElement* pElement) { // Create a pen for this object and // initialize it to the object color and line width of m_PenWidth CPen aPen; if(!aPen.CreatePen(m_LineStyle, m_PenWidth, this==pElement ? SELECT_COLOR : m_Color)) { // Pen creation failed AfxMessageBox(_T("Pen creation failed drawing a curve"), MB_OK); AfxAbort(); } // Select the pen CPen* pOldPen = pDC->SelectObject(& aPen); // Now draw the curve //pDC->MoveTo(m_Points[0]); pDC->MoveTo(m_APoints[0]); /* for(size_t i=1; i<m_Points.size(); ++i) { pDC->LineTo(m_Points[i]); } */ for(int i=1; i<m_APoints.GetSize(); ++i) { pDC->LineTo(m_APoints[i]); } pDC->SelectObject(pOldPen); // Restore the old pen }
// 画测线标尺和测点标尺 void CGraphInstrumentList::DrawMarkLineNb(CDC* pDC, int iGridY) { CPen oPen; CPen* pOldPen; oPen.CreatePen(PS_SOLID, 2, RGB(255, 0, 0)); pOldPen = pDC->SelectObject(&oPen); int iLineNb; CString strLineNb; CRect oRect; for(unsigned int i = 0; i < m_uiRowCount; i++) { iLineNb = GetLineNbByRowIndex(i); strLineNb.Format("%d", iLineNb); oRect.left = -50; oRect.right = 0; oRect.top = i * iGridY - m_iUnitHightMin / 2; oRect.bottom = oRect.top + m_iUnitHightMax; pDC->DrawText(strLineNb, &oRect, DT_LEFT | DT_VCENTER); } pDC->SelectObject(pOldPen); }