WinGdi.h Windef.h
Object:
DC、Bitmap、Brush、Clipping、Colors、Font、Pen
一、DC
HDC hdc;
GetClientRect(hWnd,&rc); // RECT rc;
hdc = BeginPaint(hWnd,&ps); // POINTSTRUCT ps;
PEN hPen,hPenOld;
hPen = ExtCreatePen(PS_COSMETIC,1,&lb,0,NULL); // LOGBRUSH lb;
hPenOld = SelectObject(hdc,hPen);
MoveToEx(hdc,intX,intY,NULL);
LineTo(hdc,intX,intY);
SelectObject(hdc,hPenOld);
DeleteObject(hPen);
以上是一般的GDI开发过程.
1:根据句柄取得HDC;
2:定义Pen、Brush、Font、Bitmap等。这里要注意它们的创建参数.
3:保存原来的Pen、Brush、Font、Bitmap,并载入新的Pen、Brush、Font、Bitmap;
4:开如画图。开以用的函数有:MoveTo()、LineTo()、Rect...
5:恢复Pen、Brush、Font、Bitmap.
6:删除Pen、Brush、Font、Bitmap