OSDN Git Service

バグレポート機能実装途中
[nlite/nlite.git] / nlite / nlite.cpp
1 // nlite.cpp : \83A\83v\83\8a\83P\81[\83V\83\87\83\93\82Ì\83G\83\93\83g\83\8a \83|\83C\83\93\83g\82ð\92è\8b`\82µ\82Ü\82·\81B
2 //
3
4 #include "stdafx.h"
5 #include "nlite_include.h"
6 using namespace nlite;
7 CAppModule _Module;
8
9
10
11
12
13
14
15
16 #ifndef NLITE_TEST
17
18 //\83\81\83C\83\93\8aÖ\90\94
19 int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE,
20         LPTSTR lpCmdLine, int nCmdShow)
21 {
22         HINSTANCE hRich = LoadLibrary(CRichEditCtrl::GetLibraryName());
23         int nRet = -1;
24         try{
25
26                 //
27                 //\83A\83v\83\8a\83P\83P\81[\83V\83\87\83\93\8f\89\8aú\89»\8f\88\97\9d
28                 //
29                 HRESULT hRes = ::CoInitialize(NULL);
30                 ATLASSERT(SUCCEEDED(hRes));
31                 AtlInitCommonControls(ICC_COOL_CLASSES | ICC_WIN95_CLASSES);
32                 GUID guid;
33                 if(_Module.Init(NULL, hInstance,&guid) != S_OK){
34                         throw AppInitException(__LINE__,TEXT(__FILE__),TEXT(__FUNCTION__));
35                 }
36
37                 AtlAxWinInit();
38
39                 if(InitializeNlite() != TRUE){
40                         throw AppInitException(__LINE__,TEXT(__FILE__),TEXT(__FUNCTION__));
41                 }
42
43                 
44
45                 
46                 //\83\81\83b\83Z\81[\83W\83\8b\81[\83v\93o\98^
47                 CMessageLoop theLoop;
48                 _Module.AddMessageLoop(&theLoop);
49
50
51                 //\83\81\83C\83\93\83E\83B\83\93\83h\83E\8f\89\8aú\89»
52                 wnd.Initialize(localAppDataPath);
53                 wnd.CreateEx(0,0,WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN);
54
55                 //\83\81\83C\83\93\83E\83B\83\93\83h\83E\95\\8e¦
56                 wnd.ShowWindow(nCmdShow);
57                 wnd.UpdateWindow();
58
59                 //\97]\95ª\82É\8am\95Û\82µ\82Ä\82¢\82é\83q\81[\83v\82ð\8aJ\95ú
60                 _heapmin();
61
62
63                 //\83\81\83b\83Z\81[\83W\83\8b\81[\83v\8aJ\8en
64                 nRet = theLoop.Run();
65
66                 //\8fI\97¹\8cã\83\81\83\82\83\8a\83`\83F\83b\83N
67                 vcassert(_heapchk() == _HEAPOK,TEXT("\83q\81[\83v\83G\83\89\81[\82Å\82·"));
68
69                 goto nliteend;
70
71         } catch(nlite::Exception &e){
72
73                 UnexpectedErrorMessageShow(TEXT("\83n\83\93\83h\83\8b\82³\82ê\82Ä\82¢\82È\82¢\83G\83\89\81["),e.what(),e.getLineNo(),e.getFileName(),e.getFunctionName());
74
75
76                 goto nliteexception;
77         } catch(nlib::Exception &e){
78
79                 UnexpectedErrorMessageShow(TEXT("nlib\82Å\83n\83\93\83h\83\8b\82³\82ê\82Ä\82¢\82È\82¢\83G\83\89\81["),e.what(),e.getLineNo(),e.getFileName(),e.getFunctionName());
80
81                 goto nliteexception;
82         }catch(std::exception &e){
83                 UnexpectedErrorMessageShow(TEXT("\83n\83\93\83h\83\8b\82³\82ê\82Ä\82¢\82È\82¢\83G\83\89\81["),CComBSTR(e.what()),-1,TEXT("\94­\90\83t\83@\83C\83\8b\82ª\93Á\92è\8fo\97\88\82Ü\82¹\82ñ"),TEXT("\94­\90\8aÖ\90\94\82ª\93Á\92è\82Å\82«\82Ü\82¹\82ñ"));
84
85
86
87                 goto nliteexception;
88         } 
89
90
91         
92
93 nliteend:
94         FreeLibrary(hRich);
95         _Module.RemoveMessageLoop();
96         FinalizeNlite();
97         _Module.Term();
98         ::CoUninitialize();
99
100         return nRet;
101
102 nliteexception:
103         wnd.OnException();
104         wnd.DestroyWindow();
105         goto nliteend;
106 }
107
108
109 #else
110 #ifdef NLITE_TEST
111
112
113 //\83\81\83C\83\93\8aÖ\90\94
114 int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE,
115         LPTSTR lpCmdLine, int nCmdShow)
116 {
117         HINSTANCE hRich = LoadLibrary(CRichEditCtrl::GetLibraryName());
118         int nRet = -1;
119
120
121         //
122         //\83A\83v\83\8a\83P\83P\81[\83V\83\87\83\93\8f\89\8aú\89»\8f\88\97\9d
123         //
124         HRESULT hRes = ::CoInitialize(NULL);
125         ATLASSERT(SUCCEEDED(hRes));
126         AtlInitCommonControls(ICC_COOL_CLASSES | ICC_WIN95_CLASSES);
127         GUID guid;
128         _Module.Init(NULL, hInstance,&guid);
129         AtlAxWinInit();
130
131         InitializeNlite();
132
133                 
134
135
136
137
138
139
140
141         //\8fI\97¹\8cã\83\81\83\82\83\8a\83`\83F\83b\83N
142         vcassert(_heapchk() == _HEAPOK,TEXT("\83q\81[\83v\83G\83\89\81[\82Å\82·"));
143
144         nRet = 0;
145
146
147         FreeLibrary(hRich);
148
149
150
151
152         FinalizeNlite();
153         ::CoUninitialize();
154
155         return nRet;
156 }
157
158 #endif
159
160 #endif