1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
// WinMain.cpp
#include <windows.h>
#include "resource.h"
const char g_szClassName[] = "Skeleton";
LRESULT CALLBACK WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
switch (Msg){
case WM_COMMAND:
switch (LOWORD(wParam)){
case ID_FILE_EXIT:
DestroyWindow(hWnd);
break;
}
break;
case WM_CLOSE:
DestroyWindow(hWnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, Msg, wParam, lParam);
}
return 0;
}
int __stdcall WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, int nShowExmd)
{
MSG Msg;
HWND hWnd;
WNDCLASSEX wEx;
wEx.cbSize = sizeof(WNDCLASSEX);
wEx.style = 0;
wEx.lpfnWndProc = WndProc;
wEx.cbClsExtra = 0;
wEx.cbWndExtra = 0;
wEx.hInstance = hInst;
wEx.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wEx.hCursor = LoadCursor(NULL, IDC_ARROW);
wEx.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
wEx.lpszMenuName = MAKEINTRESOURCE(IDR_MENU);
wEx.lpszClassName = g_szClassName;
wEx.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if (!RegisterClassEx(&wEx))
return -1;
if ((hWnd = CreateWindowEx(WS_EX_CLIENTEDGE, g_szClassName, "Skeleton", WS_BORDER | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT, 240, 120, 0, 0, hInst, 0)) == 0)
return -1;
ShowWindow(hWnd, nShowExmd);
UpdateWindow(hWnd);
while (GetMessage(&Msg, 0, 0, 0) > 0)
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}
// resource.h
#define IDR_MENU 101
#define ID_FILE_EXIT 9001
// resource.rc
#include "resource.h"
IDR_MENU MENU
BEGIN
POPUP "&File"
BEGIN
MENUITEM "&Exit", ID_FILE_EXIT
END
END
|