- Revert 47615. Please fix actual sysreg instead of adding inconsistency between...
[reactos.git] / rosapps / templates / imagesoft / imagesoft.c
1 #include <precomp.h>
2
3 HINSTANCE hInstance;
4 HANDLE ProcessHeap;
5
6 int WINAPI
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, len;
17 INITCOMMONCONTROLSEX icex;
18
19 hInstance = hThisInstance;
20 ProcessHeap = GetProcessHeap();
21
22 icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
23 icex.dwICC = ICC_BAR_CLASSES | ICC_COOL_CLASSES;
24 InitCommonControlsEx(&icex);
25
26 if (!AllocAndLoadString(&lpAppName, hInstance, IDS_APPNAME) ||
27 !AllocAndLoadString(&lpVersion, hInstance, IDS_VERSION) )
28 {
29 return Ret;
30 }
31
32 len = (int)_tcslen(lpAppName) + (int)_tcslen(lpVersion);
33 lpTitle = HeapAlloc(ProcessHeap,
34 0,
35 (len + 2) * sizeof(TCHAR));
36 if (lpTitle == NULL)
37 {
38 LocalFree((HLOCAL)lpAppName);
39 LocalFree((HLOCAL)lpVersion);
40 return Ret;
41 }
42
43 wsprintf(lpTitle,
44 _T("%s %s"),
45 lpAppName,
46 lpVersion);
47
48 LocalFree((HLOCAL)lpAppName);
49 LocalFree((HLOCAL)lpVersion);
50
51 if (TbdInitImpl())
52 {
53 if (InitMainWindowImpl())
54 {
55 if (InitImageEditWindowImpl())
56 {
57 if (InitFloatWndClass())
58 {
59 hMainWnd = CreateMainWindow(lpTitle,
60 nCmdShow);
61 if (hMainWnd != NULL)
62 {
63 /* pump the message queue */
64 while((bRet = GetMessage(&Msg,
65 NULL,
66 0,
67 0) != 0))
68 {
69 if (bRet != (BOOL)-1)
70 {
71 if (!MainWndTranslateMDISysAccel(hMainWnd,
72 &Msg))
73 {
74 TranslateMessage(&Msg);
75 DispatchMessage(&Msg);
76 }
77 }
78 }
79
80 Ret = 0;
81 }
82
83 UninitImageEditWindowImpl();
84 }
85
86 UninitFloatWndImpl();
87 }
88
89 UninitMainWindowImpl();
90 }
91
92 TbdUninitImpl();
93 }
94
95 HeapFree(GetProcessHeap(),
96 0,
97 lpTitle);
98
99 return Ret;
100 }