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
|
// Mnu02.cpp
#include <windows.h>
#define IDR_MAIN_MENU 2000
#define IDM_FILE_OPEN 2100
#define IDM_FILE_EXIT 2105
long __stdcall WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
if(message==WM_DESTROY)
PostQuitMessage(0);
else
return DefWindowProc(hwnd, message, wParam, lParam);
return 0;
}
int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrev, LPSTR lpszArgument, int nCmdShow)
{
char szClassName[ ] = "CodeBlocksWindowsApp";
MSG messages;
WNDCLASS wc;
HWND hwnd;
wc.hInstance = hInstance, wc.lpszClassName = szClassName;
wc.lpfnWndProc = WindowProcedure, wc.style = 0;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION), wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.lpszMenuName = MAKEINTRESOURCE(IDR_MAIN_MENU), wc.cbClsExtra = 0;
wc.cbWndExtra = 0, wc.hbrBackground = (HBRUSH)COLOR_BACKGROUND;
RegisterClass(&wc);
hwnd=CreateWindow(szClassName,"Template",WS_OVERLAPPEDWINDOW,50,50,544,375,HWND_DESKTOP,NULL,hInstance,NULL);
ShowWindow (hwnd, nCmdShow);
while(GetMessage (&messages, NULL, 0, 0))
{
TranslateMessage(&messages);
DispatchMessage(&messages);
}
return messages.wParam;
}
|