#include <windows.h> LRESULT CALLBACK WndProc(HWND hwnd , UINT msg , WPARAM wp , LPARAM lp) { HDC hdc; HPEN hpen; PAINTSTRUCT ps; LPCTSTR lpctStr = TEXT("Kitty on your lap"); switch (msg) { case WM_DESTROY: PostQuitMessage(0); return 0; case WM_PAINT: hdc = BeginPaint(hwnd , &ps); hpen = GetStockObject(WHITE_PEN); SelectObject(hdc , hpen); TextOut(hdc , 10 , 10 , lpctStr , lstrlen(lpctStr)); Rectangle(hdc , 20 , 20 , 200 , 50); 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; }
#include <windows.h> LRESULT CALLBACK WndProc(HWND hwnd , UINT msg , WPARAM wp , LPARAM lp) { HDC hdc; HPEN hpen; PAINTSTRUCT ps; switch (msg) { case WM_DESTROY: PostQuitMessage(0); return 0; case WM_PAINT: hdc = BeginPaint(hwnd , &ps); hpen = CreatePen(PS_DASH , 0 , 0XFF << 16); SelectObject(hdc , hpen); Rectangle(hdc , 10 , 10 , 200 , 50); EndPaint(hwnd , &ps); DeleteObject(hpen); 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; }
typedef struct tagLOGPEN { UINT lopnStyle; POINT lopnWidth; COLORREF lopnColor; } LOGPEN;lopnStyleは、ペンスタイルを
#include <windows.h> LRESULT CALLBACK WndProc(HWND hwnd , UINT msg , WPARAM wp , LPARAM lp) { HDC hdc; static LOGPEN lopnPen; PAINTSTRUCT ps; switch (msg) { case WM_DESTROY: PostQuitMessage(0); return 0; case WM_CREATE: lopnPen.lopnStyle = PS_SOLID; lopnPen.lopnWidth.x = 5; lopnPen.lopnColor = 0XFF; return 0; case WM_PAINT: hdc = BeginPaint(hwnd , &ps); SelectObject(hdc , CreatePenIndirect(&lopnPen)); Ellipse(hdc , 10 , 10 , 200 , 50); 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)) DispatchMessage(&msg); return msg.wParam; }
定数 | 解説 |
---|---|
SIMPLEREGION | リージョンは単一の長方形です |
COMPLEXREGION | リージョンは単一の長方形よりも複雑な形です |
NULLREGION | リージョンは空です |
GDI_ERROR | 失敗 |
PS_SOLID | 実線のペンを作成します |
PS_DASH | 破線のペンを作成します このスタイルは、ペンの幅がデバイス単位で 1 以下のときにだけ有効です |
PS_DOT | 点線のペンを作成します このスタイルは、ペンの幅がデバイス単位で 1 以下のときにだけ有効です |
PS_DASHDOT | 一点鎖線のペンを作成します このスタイルは、ペンの幅がデバイス単位で 1 以下のときにだけ有効です |
PS_DASHDOTDOT | 二点鎖線のペンを作成します このスタイルは、ペンの幅がデバイス単位で 1 以下のときにだけ有効です |
PS_NULL | 空のペンを作成します 描画は行われません |
PS_INSIDEFRAME | 実線のペンを作成します 境界長方形を指定するRectangle()やEllipse()などでこのペンを使うと その長方形に完全に収まるように図形が縮小されます ジオメトリックペンにだけ有効です |