Tổng quan về lập trình GDI

10 704 3
  • Loading ...
1/10 trang

Thông tin tài liệu

Ngày đăng: 27/08/2012, 10:01

Tổng quan về lập trình GDI 1 Giơi thiêu , . 2005. 2 , . p 1 - . 2 - . 3 - . 4 - . 3 ơp cơ ban 3.1 lơp DC . . . CPaintDC 1 ( OnPaint) CClientDC ( OnPaint) CWindowDC CMetaFileDC CDC - sau CDC* pDC = GetDC (); // Do some drawing ReleaseDC (pDC); CPaintDC - void CMyView::OnPaint() { CPaintDC dc(this); dc.TextOut(0, 0, "for the display, not the printer"); OnDraw(&dc); // stuff that's common to display and // printer 1 menu } CClientDC - void CMainWindow::OnLButtonDown (UINT nFlags, CPoint point) { CRect rect; GetClientRect (&rect); CClientDC dc (this); dc.MoveTo (rect.left, rect.top); dc.LineTo (rect.right, rect.bottom); dc.MoveTo (rect.right, rect.top); dc.LineTo (rect.left, rect.bottom); } CWindowDC - . 3.2 ơ ng , . CBitmap - . . CBrush - . CFont - c, . CPen - , . CPalette - . CRgn - , . 4 4.1 o project . 4.2 X  COLORREF SetPixel(int x, int y, COLORREF color)  COLORREF SetPixel(POINT point, COLORREF color)  COLORREF GetPixel(int x, int y)  COLORREF GetPixel(POINT point) 4.3 n thă ương cong xxxTo. MoveTo LineTo Polyline PolylineTo v Arc ArcTo PolyBezier PolyBezierTo . (100, 200) void CTestGDIView::OnDraw(CDC* pDC) { . pDC->MoveTo(10, 10); pDC->LineTo(200, 200); } #include <math.h> #define SEGMENTS 100 #define PI 3.14159 void CTestGDIView::OnDraw(CDC* pDC) { . CRect rect; GetClientRect (&rect); int nWidth = rect.Width (); int nHeight = rect.Height (); CPoint aPoint[SEGMENTS]; for (int i=0; i<SEGMENTS; i++) { aPoint[i].x = (i * nWidth) / SEGMENTS; aPoint[i].y = (int) ((nHeight / 2) * (1 - (sin ((2 * PI * i) / SEGMENTS)))); } pDC->Polyline (aPoint, SEGMENTS); } void CTestGDIView::OnDraw(CDC* pDC) { . POINT aPoint1[4] = { 120,100,120,200,250,150,500,40 }; POINT aPoint2[4] = { 120,100,50,350,250,200,500,40 }; pDC->PolyBezier (aPoint1, 4); pDC->PolyBezier (aPoint2, 4); } 4.4 ư nhâ Chord Ellipse Pie Polygon Rectangle RoundRect void CTestGDIView::OnDraw(CDC* pDC) { . pDC->Ellipse (0, 0, 150, 200); pDC->Rectangle (50, 50, 100, 150); } 4.5 n pen . CPen( int nPenStyle, int nWidth, COLORREF crColor ); CPen( int nPenStyle, int nWidth, const LOGBRUSH* pLogBrush, int nStyleCount = 0, const DWORD* lpStyle = NULL ); V void CTestGDIView::OnDraw(CDC* pDC) { . CPen pen (PS_DASH, 4, RGB (255, 0, 0)); CPen* pOldPen = pDC->SelectObject (&pen); // pOldPen lưu pDC->Ellipse (50, 50, 300, 200); } 4.6 n brush CBrush( COLORREF crColor ); CBrush( int nIndex, COLORREF crColor ); explicit CBrush( CBitmap* pBitmap ); void CTestGDIView::OnDraw(CDC* pDC) { . CBrush brush (HS_DIAGCROSS, RGB (255, 0, 0)); pDC->SelectObject (&brush); pDC->Rectangle (0, 0, 100, 100); } . PolylineTo v Arc ArcTo PolyBezier PolyBezierTo . (100, 200) void CTestGDIView::OnDraw(CDC* pDC) { ... pDC->MoveTo(10, 10); pDC->LineTo(200,. #include <math.h> #define SEGMENTS 100 #define PI 3.14159 void CTestGDIView::OnDraw(CDC* pDC) { ... CRect rect; GetClientRect (&rect);
- Xem thêm -

Xem thêm: Tổng quan về lập trình GDI, Tổng quan về lập trình GDI, Tổng quan về lập trình GDI

Gợi ý tài liệu liên quan cho bạn