HRGN CreateRectRgn( int nLeftRect , int nTopRect , int nRightRect , int nBottomRect );nLeftRect には始点X座標、nTopRect には始点Y座標
#include <windows.h>
LRESULT CALLBACK WndProc(HWND hwnd , UINT msg , WPARAM wp , LPARAM lp) {
HDC hdc;
PAINTSTRUCT ps;
HRGN hrgn;
switch (msg) {
case WM_DESTROY:
PostQuitMessage(0);
return 0;
case WM_PAINT:
hdc = BeginPaint(hwnd , &ps);
hrgn = CreateRectRgn(10 , 10 , 100 , 100);
FillRgn(hdc , hrgn , GetStockObject(BLACK_BRUSH));
DeleteObject(hrgn);
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)) DispatchMessage(&msg);
return msg.wParam;
}

BOOL FrameRgn( HDC hdc , HRGN hrgn , HBRUSH hbr , int nWidth , int nHeight );hdc には、デバイスコンテキストのハンドルを
#include <windows.h>
LRESULT CALLBACK WndProc(HWND hwnd , UINT msg , WPARAM wp , LPARAM lp) {
HDC hdc;
PAINTSTRUCT ps;
HRGN hrgn;
switch (msg) {
case WM_DESTROY:
PostQuitMessage(0);
return 0;
case WM_PAINT:
hdc = BeginPaint(hwnd , &ps);
hrgn = CreateRectRgn(10 , 10 , 100 , 100);
SelectObject(hdc , CreateHatchBrush(HS_DIAGCROSS , RGB(0xFF , 0 , 0)));
PaintRgn(hdc , hrgn);
FrameRgn(hdc , hrgn , GetStockObject(GRAY_BRUSH) , 2 , 5);
DeleteObject(hrgn);
DeleteObject(SelectObject(hdc , GetStockObject(BLACK_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)) DispatchMessage(&msg);
return msg.wParam;
}

HRGN CreateEllipticRgn( int nLeftRect , int nTopRect, int nRightRect , int nBottomRect );nLeftRect は左上隅のX座標、nTopRect は左上隅のY座標
#include <windows.h>
LRESULT CALLBACK WndProc(HWND hwnd , UINT msg , WPARAM wp , LPARAM lp) {
HDC hdc;
PAINTSTRUCT ps;
HRGN hrgn;
switch (msg) {
case WM_DESTROY:
PostQuitMessage(0);
return 0;
case WM_PAINT:
hdc = BeginPaint(hwnd , &ps);
SelectObject(hdc , GetStockObject(GRAY_BRUSH));
hrgn = CreateEllipticRgn(10 , 10 , 200 , 200);
PaintRgn(hdc , hrgn);
DeleteObject(hrgn);
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)) DispatchMessage(&msg);
return msg.wParam;
}

HRGN CreateRoundRectRgn( int nLeftRect , int nTopRect , int nRightRect , int nBottomRect , int nWidthEllipse , int nHeightEllipse );nLeftRect は左上隅のX座標、nTopRect は左上隅のY座標
#include <windows.h>
LRESULT CALLBACK WndProc(HWND hwnd , UINT msg , WPARAM wp , LPARAM lp) {
HDC hdc;
PAINTSTRUCT ps;
HRGN hrgn;
switch (msg) {
case WM_DESTROY:
PostQuitMessage(0);
return 0;
case WM_PAINT:
hdc = BeginPaint(hwnd , &ps);
SelectObject(hdc , GetStockObject(GRAY_BRUSH));
hrgn = CreateRoundRectRgn(10 , 10 , 200 , 100 , 50 , 20);
PaintRgn(hdc , hrgn);
DeleteObject(hrgn);
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)) DispatchMessage(&msg);
return msg.wParam;
}

HRGN CreatePolygonRgn( CONST POINT *lppt, int cPoints, int fnPolyFillMode );lppt には、多角形の各頂点が格納されているPOINT構造体の配列へのポインタ
HRGN CreatePolyPolygonRgn( CONST POINT *lppt, CONST INT *lpPolyCounts, int nCount, int fnPolyFillMode );lppt には、多角形の角頂点の位置を表した配列へのポインタを
#include <windows.h>
LRESULT CALLBACK WndProc(HWND hwnd , UINT msg , WPARAM wp , LPARAM lp) {
HDC hdc;
PAINTSTRUCT ps;
HRGN hrgn;
static POINT pt[3];
switch (msg) {
case WM_DESTROY:
PostQuitMessage(0);
return 0;
case WM_CREATE:
pt[0].x = 10 ; pt[0].y = 10;
pt[1].x = 100 ; pt[1].y = 10;
pt[2].x = 30 ; pt[2].y = 100;
return 0;
case WM_PAINT:
hdc = BeginPaint(hwnd , &ps);
SelectObject(hdc , GetStockObject(GRAY_BRUSH));
hrgn = CreatePolygonRgn(pt , 3 , ALTERNATE);
PaintRgn(hdc , hrgn);
DeleteObject(hrgn);
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)) DispatchMessage(&msg);
return msg.wParam;
}

HRGN CreateRectRgn( int nLeftRect , int nTopRect , int nRightRect , int nBottomRect );長方形のリージョンを作成します
HRGN CreateEllipticRgn( int nLeftRect , int nTopRect, int nRightRect , int nBottomRect );楕円のリージョンを作成します
HRGN CreateRoundRectRgn( int nLeftRect , int nTopRect , int nRightRect , int nBottomRect , int nWidthEllipse , int nHeightEllipse );角の丸い長方形のリージョンを作成します
HRGN CreatePolygonRgn( CONST POINT *lppt, int cPoints, int fnPolyFillMode );多角形のリージョンを作成します
| 定数 | 解説 |
|---|---|
| ALTERNATE | 交互モードを選択します 多角形の各走査行について、多角形の奇数番目の辺から 偶数番目の辺までの間の領域が塗りつぶされます |
| WINDING | 全域モードを選択します 0 以外のワインディング値をもつすべての領域が塗りつぶされます |
HRGN CreatePolyPolygonRgn( CONST POINT *lppt, CONST INT *lpPolyCounts, int nCount, int fnPolyFillMode );複数の多角形のリージョンを作成します
| 定数 | 解説 |
|---|---|
| ALTERNATE | 交互モードを選択します 多角形の各走査行について、多角形の奇数番目の辺から 偶数番目の辺までの間の領域が塗りつぶされます |
| WINDING | 全域モードを選択します 0 以外のワインディング値をもつすべての領域が塗りつぶされます |
BOOL FrameRgn( HDC hdc , HRGN hrgn , HBRUSH hbr , int nWidth , int nHeight );指定されたブラシを使って、指定されたリージョンの境界を描きます