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
|
#include <windows.h>
HINSTANCE hinst;
HWND hwnd;
LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow) {
MSG msg;
WNDCLASS wc;
memset(&wc, 0, sizeof(WNDCLASS));
wc.style = wc.cbClsExtra = wc.cbWndExtra = 0;
wc.lpfnWndProc = (WNDPROC)WndProc;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon((HINSTANCE)NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor((HINSTANCE)NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = L"win32_menu_unique";
wc.lpszClassName = L"win32_class_unique";
if(!RegisterClass(&wc)) {return 0;}
hinst = hInstance;
hwnd = CreateWindow(wc.lpszClassName, L"title", WS_OVERLAPPED | WS_SYSMENU, CW_USEDEFAULT, CW_USEDEFAULT, 640, 480, (HWND)NULL, (HMENU)NULL, hinst, (LPVOID)NULL);
if(!hwnd) {return 0;}
ShowWindow(hwnd, SW_HIDE);//in your case, using nCmdShow would be counter productive for obvious reasons.
UpdateWindow(hwnd);
while(GetMessage(&msg, NULL, 0, 0) > 0) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
switch(uMsg) {
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
return 0;
}
|