在设备内容中,会保存设备的属性.比如画线的颜色,字体等等.基本上是下面这张表.程序可以任意更改和取得这些属性的值.
设备内容属性 |
默认值 |
修改该值的函数 |
取得该值的函数 |
Mapping Mode |
MM_TEXT |
SetMapMode |
GetMapMode |
Window Origin |
(0, 0) |
SetWindowOrgEx OffsetWindowOrgEx |
GetWindowOrgEx |
Viewport Origin |
(0, 0) |
SetViewportOrgEx OffsetViewportOrgEx |
GetViewportOrgEx |
Window Extents |
(1, 1) |
SetWindowExtEx SetMapMode ScaleWindowExtEx |
GetWindowExtEx |
Viewport Extents |
(1, 1) |
SetViewportExtEx SetMapMode ScaleViewportExtEx |
GetViewportExtEx |
Pen |
BLACK_PEN |
SelectObject |
SelectObject |
Brush |
WHITE_BRUSH |
SelectObject |
SelectObject |
Font |
SYSTEM_FONT |
SelectObject |
SelectObject |
Bitmap |
None |
SelectObject |
SelectObject |
Current Position |
(0, 0) |
MoveToEx LineTo PolylineTo PolyBezierTo |
GetCurrentPositionEx |
Background Mode |
OPAQUE |
SetBkMode |
GetBkMode |
Background Color |
White |
SetBkColor |
GetBkColor |
Text Color |
Black |
SetTextColor |
GetTextColor |
Drawing Mode |
R2_COPYPEN |
SetROP2 |
GetROP2 |
Stretching Mode |
BLACKONWHITE |
SetStretchBltMode |
GetStretchBltMode |
Polygon Fill Mode |
ALTERNATE |
SetPolyFillMode |
GetPolyFillMode |
Intercharacter Spacing |
0 |
SetTextCharacterExtra |
GetTextCharacterExtra |
Brush Origin |
(0, 0) |
SetBrushOrgEx |
GetBrushOrgEx |
Clipping Region |
None |
SelectObject SelectClipRgn IntersectClipRgn OffsetClipRgn ExcludeClipRect SelectClipPath |
GetClipBox |
在BeginPaint和EndPaint之间可以修改系统默认的属性,但是属性在EndPaint之后会失效.
若不想让他失效的话.在wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
CS_OWNDC风格只影响GetDC和BeginPaint获得的设备内容,不影响其它函数(如GetWindowDC)获得的设备内容。
不推荐使用这个宏.
可以使用
idSaved = SaveDC (hdc) ; RestoreDC (hdc, idSaved) ; //或者 SaveDC (hdc) ; RestoreDC (hdc, -1) ;