GDI使用方法小结(一)

一:DC相关

CDC* GetDC();

HDC* GetSafeHdc();

int ReleaseDC(CDC* pDC);

DC相关的类有:CDC, CClientDC, CPaintDC, CwindowDC, CMetaFileDC, 其中OnPaint()和OnDraw()函数只能使用CPaintDC类

二:画笔创建函数

1、构造函数:CPen(int nPenStyle, int nWidth, COLORREF crColor);

2、HPEN CreatePen(int nPenStyle, int nWidth, COLORREF crColor);

3、HGDIOBJ GetStockObject(int fnObject);参数有BLACK_PEN,NULL_PEN,WHITE_PEN

4、HPEN CreatePenIndirect(const LOGPNE* logpen);

LOGPEN 的定义为:

typedef struct tagLOGPEN

{

   UINT lopnStyle;

   POINT lopnWidth;

   COLORREF lopnCOlor;

}LOGPEN 

三:画刷创建函数

1、构造函数:CBrush(int fnStyle, COLORREF crColor);

2、HBRUSH CreateHatchBrush(int fnStyle, COLORREF crColor);

3、HGDIOBJ GetStockObject(int fnObject);参数有BLACK_BRUSH,GRAY_BRUSH,DKGRAY_BRUSH,NULL_BRUSH等

4、HBRUSH CreateBrushIndirect(CONST LOGBRUSH* lplb);

四:字体创建函数

1、HFONT CreateFont(

int nHeight, int nWidth, int nEscapement,

int nOrientation, int fnWeight, DWORD fdwltalic,

DWORD fdwUnderline, DWORD fdwStrikeOut, DWORD fwdCharSet,

DWORD fdwOutputPrecision, DWORD fdwClipPrecision,

DWORD fdwQuality,DWORD fdwPitchAndFamily,LPCTSTR lpszFace);

2、HGDIOBJ GetStockObject(int fnObject);参数有ANSI_FIXED_FONT, ANSI_VAR_FONT, SYSTEM_FONT等

3、BOOL CreateFontIndirect(Const LOGFONT* lpLogFont);

五:点的创建

WIN API点结构:typedef struct tagPOINT{LONG x; LONG y;}POINT

MFC点类为:CPoint

1、构造函数:CPoint(int x,int y);

2、CPoint(POINT pt);

3、CPoint(SIZE sz)或CPoint(CSIZE sz)

4、CPoint(DWORD dw)其中双字节dw的高位表示横坐标,低位表示纵坐标

六:矩形的创建

WIN API矩形结构体为RECT, MFC矩形类为CRect。

1、CRect();构造一个空矩形

2、CRect(int l,int t, int r, int b);

3、CRect(const RECT& srcRect);

4、CRect(LPCRECT lpSrcRect);

5、CRect(POINT point, SIZE size);

6、CRect(POINT topLeft, POINT bottomRight);


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值