// Windowsプログラムの例 // bcc32 -W test2.cpp #include LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); char szClassNme[] = "sample window"; int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPreInst, LPSTR lpCmdLine, int nCmdShow) { HWND hWnd; MSG msg; WNDCLASS wndcls; if (!hPreInst) { wndcls.style = CS_HREDRAW | CS_VREDRAW; wndcls.lpfnWndProc = WndProc; wndcls.cbClsExtra = 0; wndcls.cbWndExtra = 0; wndcls.hInstance = hInstance; wndcls.hIcon = NULL; wndcls.hCursor = LoadCursor(NULL, IDC_ARROW); wndcls.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); wndcls.lpszMenuName = NULL; wndcls.lpszClassName = szClassNme; if (!RegisterClass(&wndcls)) return FALSE; } hWnd = CreateWindow(szClassNme, lpCmdLine, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 320, 240, NULL, NULL, hInstance, NULL); ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return (msg.wParam); } LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_DESTROY: PostQuitMessage(0); break; default: return(DefWindowProc(hWnd, msg, wParam, lParam)); } return (0L); }