-
Notifications
You must be signed in to change notification settings - Fork 1
/
WinMain.cpp
76 lines (66 loc) · 2.06 KB
/
WinMain.cpp
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
69
70
71
72
73
74
75
76
/*
* $Header: /Book/WinMain.cpp 20 5.03.02 10:05 Oslph312 $
*/
#include "precomp.h"
#include "resource.h"
#include "init.h"
#include "handlers.h"
#include "Exception.h"
#include "ComSupport.h"
#include "language.h"
#include "mainwnd.h"
#include "winUtils.h"
#include "persistence.h"
#include "os.h"
#include "combobug.h"
int WINAPI _tWinMain(
HINSTANCE hinst, HINSTANCE, LPTSTR pszCmdLine, int nShow )
{
// MessageBox( HWND_DESKTOP, pszCmdLine, "Hi from TextEdit", MB_OK );
trace( _T( "TextEdit _tWinMain( \"%s\" )\n" ), pszCmdLine );
fixComboBug();
#if defined( _DEBUG ) && defined( _CRTDBG_REPORT_FLAG )
{
int nDebugFlags = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG );
nDebugFlags |= _CRTDBG_LEAK_CHECK_DF;
nDebugFlags |= _CRTDBG_CHECK_ALWAYS_DF;
_CrtSetDbgFlag( nDebugFlags );
}
#if 0 // Test if leaks are detected.
// (Leaks are reported in the debug trace.)
TCHAR *testLeak = new TCHAR[ 100 ];
#endif
#endif
setNewLanguage( getLanguage() );
int nRetCode = -1;
ThreadErrorHandling teh;
try {
ComSupport cs;
AutoEditor pEditor;
// In case of exception thrown during init.
pEditor = init( pszCmdLine, nShow );
if ((const Editor *)pEditor != nullptr)
{
assert(isGoodPtr((Editor *) pEditor));
nRetCode = pEditor->run();
}
}
catch ( const AccessDeniedException& x ) {
messageBox( HWND_DESKTOP, MB_ICONERROR | MB_OK, IDS_ACCESS_DENIED, x.what() );
}
catch ( const ComException& x ) {
// In case the ComSupport constructor fails
messageBox( HWND_DESKTOP, MB_ICONERROR | MB_OK, IDS_COM_INIT_ERROR, x.what() );
}
catch ( const Exception& x ) {
// We get here in case of accidents during init.
messageBox( HWND_DESKTOP, MB_ICONERROR | MB_OK, IDS_INIT_ERROR, x.what() );
}
catch ( ... ) {
// We get here in case of SEHs that we don't translate.
assert( false );
messageBox( HWND_DESKTOP, MB_ICONERROR | MB_OK, IDS_FATAL_ERROR );
}
return nRetCode; // Goodbye, and thanks for all the fish.
}
// end of file