Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetClientRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function LoadImage Lib "user32" Alias "LoadImageA" _
(ByVal hInst As Long, ByVal lpsz As String, ByVal un1 As Long, _
ByVal n1 As Long, ByVal n2 As Long, ByVal un2 As Long) As Long
Private Declare Function CreatePatternBrush Lib "gdi32" (ByVal hBitmap As Long) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function PatBlt Lib "gdi32" _
(ByVal hdc As Long, ByVal x As Long, ByVal y As Long, _
ByVal nWidth As Long, ByVal nHeight As Long, ByVal dwRop As Long) As Long
Private Const PATCOPY = &HF00021 ' (DWORD) dest = pattern
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(
HDC hdc, // handle to DC
int nXLeft, // x-coord of upper-left rectangle corner
int nYLeft, // y-coord of upper-left rectangle corner
int nWidth, // width of rectangle
int nHeight, // height of rectangle
DWORD dwRop // raster operation code
);
Parameters
hdc
[in] Handle to the device context.
nXLeft
[in] Specifies the x-coordinate, in logical units, of the upper-left corner of the rectangle to be filled.
nYLeft
[in] Specifies the y-coordinate, in logical units, of the upper-left corner of the rectangle to be filled.
nWidth
[in] Specifies the width, in logical units, of the rectangle.
nHeight
[in] Specifies the height, in logical units, of the rectangle.
dwRop
[in] Specifies 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 Values
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero.
Windows NT/2000/XP: To get extended error information, call GetLastError.
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.
Example Code
For an example, see "Example of Menu-Item Bitmaps" in Using Menus.
Requirements
Windows NT/2000/XP: Included in Windows NT 3.1 and later.
Windows 95/98/Me: Included in Windows 95 and later.
Header: Declared in Wingdi.h; include Windows.h.
Library: Use Gdi32.lib.