#include LRESULT CALLBACK WindowProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam) { HDC hdc; PAINTSTRUCT ps; static char *str="COLORREF型とDIB"; switch(uMsg) { case WM_DESTROY: PostQuitMessage(0); return 0; case WM_PAINT: hdc=BeginPaint(hWnd,&ps); SetTextColor(hdc,0x00ff0000); TextOut(hdc,0,0,str,(int)strlen(str)); SetTextColor(hdc,0x0000ff00); TextOut(hdc,0,20,str,(int)strlen(str)); SetTextColor(hdc,0x000000ff); TextOut(hdc,0,40,str,(int)strlen(str)); //以下は不正な色指定 SetTextColor(hdc,0xffffffff); //最上位バイトは使用禁止 TextOut(hdc,0,60,str,(int)strlen(str)); EndPaint(hWnd,&ps); return 0; } return DefWindowProc(hWnd,uMsg,wParam,lParam); } int WINAPI WinMain( HINSTANCE hInstance,HINSTANCE hPrevInstance,PSTR lpCmdLine,int nCmdShow) { WNDCLASS wc; MSG msg; wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = WindowProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL,IDI_APPLICATION); wc.hCursor = LoadCursor(NULL,IDC_ARROW); wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); wc.lpszMenuName = NULL; wc.lpszClassName = __FILE__; if(!RegisterClass(&wc)) return 0; HWND hWnd=CreateWindow( __FILE__,"32ビットDIBを作る(演習3)", WS_OVERLAPPEDWINDOW | WS_VISIBLE, CW_USEDEFAULT,CW_USEDEFAULT, CW_USEDEFAULT,CW_USEDEFAULT, NULL,NULL,hInstance,NULL); if(hWnd==NULL) return 0; BOOL bRet; while((bRet=GetMessage(&msg,NULL,0,0))!=0){ if(bRet==-1) break; DispatchMessage(&msg); } return (int)msg.wParam; }