-
Notifications
You must be signed in to change notification settings - Fork 0
/
WinMain.c
51 lines (42 loc) · 1.28 KB
/
WinMain.c
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
#include <windows.h>
#include "Globals.h"
#include "MainWnd.h"
#include "Resource.h"
/* Global instance handle */
HINSTANCE g_hInstance = NULL;
/* Our application entry point */
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
HWND hWnd;
HACCEL hAccelerators;
MSG msg;
/* Assign global HINSTANCE */
g_hInstance = hInstance;
/* Register our main window class, or error */
if (!hPrevInstance && !RegisterMainWindowClass())
{
MessageBox(NULL, "Error registering main window class.", "Error", MB_ICONHAND | MB_OK);
return 0;
}
/* Create our main window, or error */
if (!(hWnd = CreateMainWindow()))
{
MessageBox(NULL, "Error creating main window.", "Error", MB_ICONHAND | MB_OK);
return 0;
}
/* Load accelerators */
hAccelerators = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDR_ACCELERATOR));
/* Show main window and force a paint */
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
/* Main message loop */
while (GetMessage(&msg, NULL, 0, 0) > 0)
{
if (!TranslateAccelerator(hWnd, hAccelerators, &msg) && !IsDialogMessage(hWnd, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return (int)msg.wParam;
}