BOOL PatBlt( HDC hdc, int nXLeft , int nYLeft , int nWidth , int nHeight , DWORD dwRop );hdc にはデバイスコンテキストのハンドルを
#include <windows.h>
LRESULT CALLBACK WndProc(HWND hwnd , UINT msg , WPARAM wp , LPARAM lp) {
HDC hdc;
PAINTSTRUCT ps;
switch (msg) {
case WM_DESTROY:
PostQuitMessage(0);
return 0;
case WM_PAINT:
hdc = BeginPaint(hwnd , &ps);
SelectObject(hdc , CreateSolidBrush(RGB(0xFF , 0 , 0)));
PatBlt(hdc , 10 , 10 , 200 , 100 , PATCOPY);
DeleteObject(
SelectObject(
hdc , GetStockObject(WHITE_BRUSH)
)
);
EndPaint(hwnd , &ps);
return 0;
}
return DefWindowProc(hwnd , msg , wp , lp);
}
int WINAPI WinMain(HINSTANCE hInstance , HINSTANCE hPrevInstance ,
PSTR lpCmdLine , int nCmdShow ) {
HWND hwnd;
MSG msg;
WNDCLASS winc;
winc.style = CS_HREDRAW | CS_VREDRAW;
winc.lpfnWndProc = WndProc;
winc.cbClsExtra = winc.cbWndExtra = 0;
winc.hInstance = hInstance;
winc.hIcon = LoadIcon(NULL , IDI_APPLICATION);
winc.hCursor = LoadCursor(NULL , IDC_ARROW);
winc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
winc.lpszMenuName = NULL;
winc.lpszClassName = TEXT("KITTY");
if (!RegisterClass(&winc)) return -1;
hwnd = CreateWindow(
TEXT("KITTY") , TEXT("Kitty on your lap") ,
WS_OVERLAPPEDWINDOW | WS_VISIBLE ,
CW_USEDEFAULT , CW_USEDEFAULT ,
CW_USEDEFAULT , CW_USEDEFAULT ,
NULL , NULL ,
hInstance , NULL
);
if (hwnd == NULL) return -1;
while(GetMessage(&msg , NULL , 0 , 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}

BOOL PatBlt( HDC hdc, int nXLeft , int nYLeft , int nWidth , int nHeight , DWORD dwRop );指定された長方形を現在のブラシでペイントします
| 定数 | 解説 |
|---|---|
| PATCOPY | 指定したパターンを描画先にコピーします |
| PATINVERT | 指定したパターンの色と、描画先の色を、論理 XOR 演算子で結合します |
| DSTINVERT | 描画先長方形の色を反転します |
| BLACKNESS | 物理パレットのインデックス 0 に対応する色 (デフォルトは黒) で 描画先の長方形を塗りつぶします |
| WHITENESS | 物理パレットのインデックス 0 に対応する色 (デフォルトは黒) で 描画先の長方形を塗りつぶします |