Tải bản đầy đủ (.pdf) (10 trang)

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

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (1.56 MB, 10 trang )


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

×