#include <windows.h>
///// プロトタイプ宣言
int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR,int);
LRESULT CALLBACK WindowProc(HWND hwnd,UINT msg,WPARAM wp,LPARAM lp);
///// 変数宣言
const char *strClassName="SAMPLE"; // ウィンドウクラスの名前
const char *strTitle="サンプル"; // タイトル
///// WinMain
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
{
// ウィンドウクラスの登録
WNDCLASSEX wcx;
wcx.cbSize = sizeof(WNDCLASSEX);
wcx.style = NULL;
wcx.lpfnWndProc = WindowProc;
wcx.cbClsExtra = 0;
wcx.cbWndExtra = 0;
wcx.hInstance = hInstance;
wcx.hIcon = LoadIcon(NULL,MAKEINTRESOURCE(IDI_APPLICATION));
wcx.hCursor = LoadCursor(NULL,MAKEINTRESOURCE(IDC_ARROW));
wcx.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wcx.lpszMenuName = NULL;
wcx.lpszClassName = strClassName;
wcx.hIconSm = NULL;
if(!RegisterClassEx(&wcx)) return 0; // クラス登録
// ウィンドウ作成
HWND hwnd;
hwnd=CreateWindowEx(NULL,strClassName,strTitle,WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,
NULL,NULL,hInstance,NULL);
if(!hwnd) return 0;
ShowWindow(hwnd,nCmdShow); // Window表示
// メッセージループ
MSG msg;
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
///// ウィンドウプロシージャ
LRESULT CALLBACK WindowProc(HWND hwnd,UINT msg,WPARAM wp,LPARAM lp)
{
switch(msg)
{
case WM_DESTROY:
PostQuitMessage(0);
break;
default: return DefWindowProc(hwnd,msg,wp,lp);
}
return 0;
}
///// End of Source
|