1 #include "precomp.h"
2
3 HINSTANCE hInstance;
4 HANDLE ProcessHeap;
5
6 int WINAPI
_tWinMain(HINSTANCE hThisInstance,HINSTANCE hPrevInstance,LPTSTR lpCmdLine,int nCmdShow)7 _tWinMain(HINSTANCE hThisInstance,
8 HINSTANCE hPrevInstance,
9 LPTSTR lpCmdLine,
10 int nCmdShow)
11 {
12 LPTSTR lpAppName, lpVersion, lpTitle;
13 HWND hMainWnd;
14 MSG Msg;
15 BOOL bRet;
16 int Ret = 1;
17 size_t len;
18 INITCOMMONCONTROLSEX icex;
19
20 hInstance = hThisInstance;
21 ProcessHeap = GetProcessHeap();
22
23 icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
24 icex.dwICC = ICC_BAR_CLASSES | ICC_COOL_CLASSES;
25 InitCommonControlsEx(&icex);
26
27 if (!AllocAndLoadString(&lpAppName, hInstance, IDS_APPNAME) ||
28 !AllocAndLoadString(&lpVersion, hInstance, IDS_VERSION) )
29 {
30 MessageBox(NULL,
31 _T("Error loading resource "),
32 NULL,
33 0);
34 return 1;
35 }
36
37 len = _tcslen(lpAppName) + _tcslen(lpVersion);
38 lpTitle = (TCHAR*) HeapAlloc(ProcessHeap,
39 0,
40 (len + 2) * sizeof(TCHAR));
41
42 wsprintf(lpTitle,
43 _T("%s %s"),
44 lpAppName,
45 lpVersion);
46
47 if (InitMainWindowImpl())
48 {
49 if (InitEditWindowImpl())
50 {
51 hMainWnd = CreateMainWindow(lpTitle,
52 nCmdShow);
53 if (hMainWnd != NULL)
54 {
55 /* pump the message queue */
56 while((bRet = GetMessage(&Msg,
57 NULL,
58 0,
59 0) != 0))
60 {
61 if (bRet != (BOOL)-1)
62 {
63 if (!MainWndTranslateMDISysAccel(hMainWnd,
64 &Msg))
65 {
66 TranslateMessage(&Msg);
67 DispatchMessage(&Msg);
68 }
69 }
70 }
71
72 Ret = 0;
73 }
74
75 UninitEditWindowImpl();
76 }
77
78 UninitMainWindowImpl();
79 }
80
81 LocalFree((HLOCAL)lpAppName);
82
83 return Ret;
84 }
85