#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <windowsx.h>
bool RegisterWindowClass();
bool CreateWindowEx(int);
LRESULT CALLBACK WindowProc(HWND,UINT,WPARAM,LPARAM);
#define WINDOWCLASS "WINCLASS1"
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nShowCmd){
WNDCLASSEX winclass;
HWND hwnd;
MSG msg;
winclass.cbSize = sizeof(WNDCLASSEX);
winclass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC | CS_DBLCLKS;
winclass.lpfnWndProc = WindowProc;
winclass.cbClsExtra = 0;
winclass.cbWndExtra = 0;
winclass.hInstance = hInstance;
winclass.hIcon = LoadIcon(NULL, IDI_EXCLAMATION);
winclass.hCursor = LoadCursor(NULL, IDC_ARROW);
winclass.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
winclass.lpszMenuName = "MainMenu";
winclass.lpszClassName = WINDOWCLASS;
winclass.hIconSm = LoadIcon(NULL, IDI_EXCLAMATION);
if(!RegisterClassEx(&winclass))
return (0);
if(!(hwnd = CreateWindowEx(NULL,
WINDOWCLASS,
"[ First Window ]",
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
0,0,
500,500,
NULL,
NULL,
hInstance,
NULL)))
return (0);
//main event loop
while(GetMessage(&msg, NULL, 0, 0)){
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (msg.wParam);
}
LRESULT CALLBACK WindowProc(HWND hWnd,
UINT msg,
WPARAM wparam,
LPARAM lparam){
PAINTSTRUCT ps;
HDC hdc;
RECT rt;
switch(msg){
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
GetClientRect(hWnd, &rt);
EndPaint ( hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage (0);
break;
case WM_KEYDOWN:
break;
default:
return (DefWindowProc(hWnd, msg, wparam, lparam));
}
return 0;
}
resources.rc file
#include <resources.h>
MainMenu MENU DISCARDABLE{
POPUP "&File"{
MENUITEM "E&xit", MENUID_EXIT
}
POPUP "&Sounds"{
MENUITEM "Sound &A", MENUID_SOUNDA
MENUITEM "Sound &B", MENUID_SOUNDB
MENUITEM "Sound &C", MENUID_SOUNDC
}
resources.h file
//MENU: FILE
#define MENUID_EXIT 1000
//MENU: SOUNDS
#define MENUID_SOUNDA 2000
#define MENUID_SOUNDB 2001
#define MENUID_SOUNDC 2002
[edited by - Klear on June 15, 2002 4:02:21 AM] [edited by - Klear on June 15, 2002 4:06:02 AM]