#include <windows.h> #define TITLE TEXT("Kitty on your lap") LRESULT CALLBACK WndProc(HWND hWnd , UINT msg , WPARAM wp , LPARAM lp) { HDC hdc; PAINTSTRUCT ps; HFONT hFont; switch (msg) { case WM_DESTROY: PostQuitMessage(0); return 0; case WM_PAINT: hdc = BeginPaint(hWnd , &ps); BeginPath(hdc); SetBkMode(hdc , TRANSPARENT); hFont = CreateFont( 80 , 0 , 0 , 0 , FW_BOLD , FALSE , FALSE , FALSE , ANSI_CHARSET , OUT_DEFAULT_PRECIS , CLIP_DEFAULT_PRECIS , DEFAULT_QUALITY , 0 , NULL ); SelectObject(hdc , hFont); TextOut(hdc , 0 , 0 , TITLE , lstrlen(TITLE)); EndPath(hdc); StrokePath(hdc); SelectObject(hdc , GetStockObject(SYSTEM_FONT)); DeleteObject(hFont); 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") , TITLE , 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; }
#include <windows.h> #define TITLE TEXT("Kitty on your lap") LRESULT CALLBACK WndProc(HWND hWnd , UINT msg , WPARAM wp , LPARAM lp) { HDC hdc; PAINTSTRUCT ps; HFONT hFont; switch (msg) { case WM_DESTROY: PostQuitMessage(0); return 0; case WM_PAINT: hdc = BeginPaint(hWnd , &ps); BeginPath(hdc); SetBkMode(hdc , TRANSPARENT); hFont = CreateFont( 80 , 0 , 0 , 0 , FW_BOLD , FALSE , FALSE , FALSE , ANSI_CHARSET , OUT_DEFAULT_PRECIS , CLIP_DEFAULT_PRECIS , DEFAULT_QUALITY , 0 , NULL ); SelectObject(hdc , hFont); TextOut(hdc , 0 , 0 , TITLE , lstrlen(TITLE)); EndPath(hdc); SelectObject(hdc , CreateHatchBrush(HS_DIAGCROSS , 0xFF)); FillPath(hdc); SelectObject(hdc , GetStockObject(SYSTEM_FONT)); DeleteObject(hFont); 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") , TITLE , 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; }
#include <windows.h> #define TITLE TEXT("Kitty on your lap") BITMAPINFO bmpInfo; BYTE * bPixelBits; LRESULT CALLBACK WndProc(HWND hWnd , UINT msg , WPARAM wp , LPARAM lp) { HDC hdc; PAINTSTRUCT ps; HFONT hFont; switch (msg) { case WM_DESTROY: PostQuitMessage(0); return 0; case WM_PAINT: hdc = BeginPaint(hWnd , &ps); BeginPath(hdc); SetBkMode(hdc , TRANSPARENT); hFont = CreateFont( 80 , 0 , 0 , 0 , FW_BOLD , FALSE , FALSE , FALSE , ANSI_CHARSET , OUT_DEFAULT_PRECIS , CLIP_DEFAULT_PRECIS , DEFAULT_QUALITY , 0 , NULL ); SelectObject(hdc , hFont); TextOut(hdc , 0 , 0 , TITLE , lstrlen(TITLE)); EndPath(hdc); SelectObject(hdc , GetStockObject(SYSTEM_FONT)); DeleteObject(hFont); SelectClipPath(hdc , RGN_COPY); SetDIBitsToDevice( hdc , 0 , 0 , bmpInfo.bmiHeader.biWidth , bmpInfo.bmiHeader.biHeight , 0 , 0 , 0 , bmpInfo.bmiHeader.biHeight , bPixelBits , &bmpInfo , DIB_RGB_COLORS ); 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; HANDLE hFile; DWORD dwBytes; BITMAPFILEHEADER bmpFileHeader; hFile = CreateFile(lpCmdLine , GENERIC_READ , 0 , NULL , OPEN_EXISTING , FILE_ATTRIBUTE_NORMAL , NULL); if (hFile == INVALID_HANDLE_VALUE) return 1; ReadFile(hFile , &bmpFileHeader , sizeof (BITMAPFILEHEADER) , &dwBytes , NULL); if (bmpFileHeader.bfType != 0x4D42) { MessageBox(NULL , TEXT("This is not a bitmap file") , NULL , MB_OK); return 1; } ReadFile(hFile , &bmpInfo , sizeof (BITMAPINFOHEADER) , &dwBytes , NULL); bPixelBits = (BYTE *) malloc (bmpFileHeader.bfSize - bmpFileHeader.bfOffBits); ReadFile(hFile ,bPixelBits , bmpFileHeader.bfSize - bmpFileHeader.bfOffBits , &dwBytes , NULL); CloseHandle(hFile); 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") , TITLE , 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; }
定数 | 解説 |
---|---|
RGN_AND | 現在のクリッピング領域と 現在のパスの両方に含まれる領域を 新しいクリッピング領域にします |
RGN_COPY | 現在のパスを、新しいクリッピング領域にします |
RGN_DIFF | 現在のクリッピング領域から 現在のパスを除いた領域を 新しいクリッピング領域にします |
RGN_OR | 現在のクリッピング領域と 現在のパスを組み合わせた領域を 新しいクリッピング領域にします |
RGN_XOR | 現在のクリッピング領域と 現在のパスを組み合わせた領域から 重なる部分を除いた領域を、新しいクリッピング領域にします |