Simple Win32 Window
#undef UNICODE
#undef _UNICODE
#include
//
// SIMPLE WINDOW
//
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
switch (msg) {
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
}
int __stdcall WinMain(HINSTANCE hPrevInstance, HINSTANCE hInstance, LPSTR CmdLine, int nCmdShow) {
WNDCLASSEX wc;
int ret=0;
wc.cbClsExtra=0;
wc.cbSize=sizeof(WNDCLASSEX);
wc.cbWndExtra=0;
wc.hbrBackground=(HBRUSH) (COLOR_WINDOW+1);
wc.hCursor=LoadCursor(NULL, IDC_ARROW);
wc.hIcon=LoadIcon(NULL, IDI_APPLICATION);
wc.hIconSm=LoadIcon(NULL, IDI_APPLICATION);
wc.hInstance=hInstance;
wc.lpfnWndProc=WndProc;
wc.lpszClassName="Marshal";
wc.lpszMenuName=NULL;
wc.style=0;
ret = RegisterClassExA(&wc);
if (ret==0) {
MessageBoxA(NULL, "Could not register window class", "Error", MB_OK);
ExitProcess(-1);
}
HWND hwnd;
hwnd = CreateWindowEx(0, "Marshal", "Video Game", WS_OVERLAPPEDWINDOW, 10, 10, 320, 200, NULL, NULL, hInstance, NULL);
if (hwnd==NULL) {
MessageBoxA(NULL, "Could not instantiate window class", "Error", MB_OK);
ExitProcess(-1);
}
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
MSG msg;
while (GetMessage(&msg, NULL, 0, 0)>0) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int) msg.wParam;
}
#undef _UNICODE
#include
//
// SIMPLE WINDOW
//
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
switch (msg) {
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
}
int __stdcall WinMain(HINSTANCE hPrevInstance, HINSTANCE hInstance, LPSTR CmdLine, int nCmdShow) {
WNDCLASSEX wc;
int ret=0;
wc.cbClsExtra=0;
wc.cbSize=sizeof(WNDCLASSEX);
wc.cbWndExtra=0;
wc.hbrBackground=(HBRUSH) (COLOR_WINDOW+1);
wc.hCursor=LoadCursor(NULL, IDC_ARROW);
wc.hIcon=LoadIcon(NULL, IDI_APPLICATION);
wc.hIconSm=LoadIcon(NULL, IDI_APPLICATION);
wc.hInstance=hInstance;
wc.lpfnWndProc=WndProc;
wc.lpszClassName="Marshal";
wc.lpszMenuName=NULL;
wc.style=0;
ret = RegisterClassExA(&wc);
if (ret==0) {
MessageBoxA(NULL, "Could not register window class", "Error", MB_OK);
ExitProcess(-1);
}
HWND hwnd;
hwnd = CreateWindowEx(0, "Marshal", "Video Game", WS_OVERLAPPEDWINDOW, 10, 10, 320, 200, NULL, NULL, hInstance, NULL);
if (hwnd==NULL) {
MessageBoxA(NULL, "Could not instantiate window class", "Error", MB_OK);
ExitProcess(-1);
}
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
MSG msg;
while (GetMessage(&msg, NULL, 0, 0)>0) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int) msg.wParam;
}
0 Comments:
Post a Comment
<< Home