win32 PatBlt

The PatBlt function paints the specified rectangle using the brush that is currently selected into the specified device context. The brush color and the surface color or colors are combined by using the specified raster operation.

BOOL PatBlt(
  __in  HDC hdc,
  __in  int nXLeft,
  __in  int nYLeft,
  __in  int nWidth,
  __in  int nHeight,
  __in  DWORD dwRop
);

Parameters

hdc [in]
A handle to the device context.

nXLeft [in]
The x-coordinate, in logical units, of the upper-left corner of the rectangle to be filled.

nYLeft [in]
The y-coordinate, in logical units, of the upper-left corner of the rectangle to be filled.

nWidth [in]
The width, in logical units, of the rectangle.

nHeight [in]
The height, in logical units, of the rectangle.

dwRop [in]
The raster operation code. This code can be one of the following values.

Value Meaning
PATCOPY Copies the specified pattern into the destination bitmap.
PATINVERT Combines the colors of the specified pattern with the colors of the destination rectangle by using the Boolean XOR operator.
DSTINVERT Inverts the destination rectangle.
BLACKNESS Fills the destination rectangle using the color associated with index 0 in the physical palette. (This color is black for the default physical palette.)
WHITENESS Fills the destination rectangle using the color associated with index 1 in the physical palette. (This color is white for the default physical palette.)

Return Value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero.

Remarks

The values of the dwRop parameter for this function are a limited subset of the full 256 ternary raster-operation codes; in particular, an operation code that refers to a source rectangle cannot be used.

Not all devices support the PatBlt function. For more information, see the description of the RC_BITBLT capability in the GetDeviceCaps function.

Examples

For an example, see “Example of Menu-Item Bitmaps” in Using Menus.

备注

参考《windows程序设计》第5版 北大出版社 Page616
绘制一个黑色矩形:
PatBlt(hdc,x,y,cx,cy,BLACKNESS)

绘制一个白色矩形:
PatBlt(hdc,x,y,cx,cy,WHITENESS)

猜你喜欢

转载自blog.csdn.net/wowocpp/article/details/80925066