/* ちょっとお試し Windows program sample 1 */ #include static LRESULT CALLBACK winMainProc(HWND hWnd, UINT msg, UINT wParam, LONG lParam) { /* ウィンドウ・メッセージ処理 */ switch (msg) { case WM_DESTROY: PostQuitMessage(0); return 0; } return DefWindowProc(hWnd, msg, wParam, lParam); } int WINAPI WinMain(HINSTANCE hInst, HINSTANCE dummy_hPrevInst, LPSTR dummy_lpCmdLine, int nCmdShow) { /* ここより始まる */ char *app_name = "hello world."; /*プログラムの名前*/ WNDCLASS wndclass; HWND hWnd; MSG msg; /* 多重起動防止. */ CreateMutex(NULL, 1, app_name); if (GetLastError() == ERROR_ALREADY_EXISTS) return 0; /* ウィンドウクラスの登録 */ wndclass.lpszClassName = app_name; wndclass.hCursor = LoadCursor(NULL, IDI_APPLICATION); wndclass.hIcon = LoadIcon(NULL,IDI_APPLICATION); wndclass.lpszMenuName = NULL; wndclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); wndclass.hInstance = hInst; wndclass.style = 0; wndclass.lpfnWndProc = (WNDPROC)winMainProc; wndclass.cbClsExtra = 0; wndclass.cbWndExtra = 0; if (RegisterClass(&wndclass) == 0) return 0; /* メインウィンドウの作成 */ hWnd = CreateWindowEx( 0 , app_name , app_name , WS_OVERLAPPEDWINDOW , CW_USEDEFAULT , CW_USEDEFAULT , 320 + GetSystemMetrics(SM_CXSIZEFRAME)*2 , 240 + GetSystemMetrics(SM_CYSIZEFRAME)*2+GetSystemMetrics(SM_CYMENU)+GetSystemMetrics(SM_CYCAPTION) , NULL , NULL , hInst , NULL ); ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); /* メインループ */ while(GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } /* 終了 */ return 0; }