-
Notifications
You must be signed in to change notification settings - Fork 0
/
WinMain.c
68 lines (56 loc) · 1.72 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <windows.h>
#include "Globals.h"
#include "MainWnd.h"
#include "MDIChWnd.h"
#include "Resource.h"
/* Global instance handle */
HINSTANCE g_hInstance = NULL;
/* Global main window handle so that child windows can access it */
HWND g_hMainWindow = 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)
{
if (!RegisterMainWindowClass())
{
MessageBox(NULL, "Error registering main window class.", "Error", MB_ICONHAND | MB_OK);
return 0;
}
/* Register our MDI child window class, or error */
if (!RegisterMDIChildWindowClass())
{
MessageBox(NULL, "Error registering MDI child 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;
}
/* Set global main window handle */
g_hMainWindow = hWnd;
/* 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 (!TranslateMDISysAccel(g_hMDIClient, &msg) && !TranslateAccelerator(hWnd, hAccelerators, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return (int)msg.wParam;
}