WindowsAPI 終了処理

#include

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) {
switch (msg) {
case WM_DESTROY:
MessageBox(hwnd, TEXT(“魔王を倒した”),
TEXT(“勇者の攻撃”), MB_ICONINFORMATION);
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd, msg, wp, lp);
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR lpCndLine, 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(“勇者”);

if (!RegisterClass(&winc))return 0;

hwnd = CreateWindow(
TEXT(“勇者”), TEXT(“勇者の攻撃!”),
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
100, 100, 200, 200, NULL, NULL,
hInstance, NULL
);

if (hwnd == NULL)return 0;

while (GetMessage(&msg, NULL, 0, 0))DispatchMessage(&msg);
return msg.wParam;
}

投稿者: chosuke

趣味はゲームやアニメや漫画などです

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です