source: trunk/fm3.c@ 1842

Last change on this file since 1842 was 1842, checked in by Steven Levine, 10 years ago

Comments

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.1 KB
Line 
1
2/***********************************************************************
3
4 $Id: fm3.c 1842 2015-08-12 05:10:27Z stevenhl $
5
6 fm/2 starter
7
8 Copyright (c) 1993-98 M. Kimes
9 Copyright (c) 2008, 2015 Steven H.Levine
10
11 05 Jan 08 SHL Sync
12 18 Jul 08 SHL Add Fortify support
13 11 Dec 08 SHL Add exception handler support
14 08 Aug 15 SHL Comments
15
16***********************************************************************/
17
18#include <string.h>
19
20#define INCL_DOS
21#define INCL_WIN
22#define INCL_LONGLONG
23#define INCL_DOSEXCEPTIONS // XCTP_...
24#define INCL_DOSERRORS // NO_ERROR
25
26#include "dll\fm3dll.h"
27#include "dll\mainwnd.h" // hwndBubble
28#include "dll\version.h" // VER...
29#include "dll\init.h" // StartFM3
30#include "dll\notebook.h" // appname
31#include "dll\fortify.h"
32#include "dll\errutil.h" // Error reporting
33#include "dll\excputil.h" // Exception handlers
34
35static PSZ pszSrcFile = __FILE__;
36
37int main(int argc, char *argv[])
38{
39 HAB hab;
40 HMQ hmq;
41 QMSG qmsg;
42 HWND hwndFrame;
43 APIRET regRet;
44 EXCEPTIONREGISTRATIONRECORD regRec = { NULL, NULL };
45
46 strcpy(appname, "FM/3");
47 DosError(FERR_DISABLEHARDERR);
48
49 regRec.ExceptionHandler = HandleException;
50 regRet = DosSetExceptionHandler(&regRec);
51 if (regRet != NO_ERROR) {
52#if 0 // 10 Dec 08 SHL fixme to report later maybe?
53 Dos_Error(MB_ENTER, regRet, HWND_DESKTOP, pszSrcFile, __LINE__,
54 "DosSetExceptionHandler");
55#endif
56 DbgMsg(pszSrcFile, __LINE__,
57 "DosSetExceptionHandler failed with error %u", regRet);
58 }
59
60 hab = WinInitialize(0);
61 if (hab) {
62 hmq = WinCreateMsgQueue(hab, 2048);
63 if (hmq) {
64 if (InitFM3DLL(hab, argc, argv)) {
65 if (CheckVersion(VERMAJOR, VERMINOR)) {
66# ifdef FORTIFY
67 Fortify_EnterScope();
68# endif
69 hwndFrame = StartFM3(hab, argc, argv);
70 if (hwndFrame != (HWND)0) {
71 for (;;) {
72 if (!WinGetMsg(hab, &qmsg, (HWND) 0, 0, 0)) {
73 // Get WM_QUIT
74 if (!qmsg.hwnd)
75 break; // Time to die if no window
76 // Map quit to close
77 // Must use System Menu or Ctrl-Alt-F4 accel to shutdown
78 qmsg.msg = WM_CLOSE;
79 }
80 if (hwndBubble &&
81 ((qmsg.msg > WM_BUTTON1DOWN - 1 &&
82 qmsg.msg < WM_BUTTON3DBLCLK + 1) ||
83 (qmsg.msg > WM_CHORD - 1 &&
84 qmsg.msg < WM_BUTTON3CLICK + 1)) &&
85 WinIsWindowVisible(hwndBubble))
86 {
87 WinShowWindow(hwndBubble, FALSE); // Hide
88 }
89 WinDispatchMsg(hab, &qmsg);
90 } // for
91 // Time to die
92 if (WinIsWindow(hab, WinWindowFromID(hwndFrame, FID_CLIENT)))
93 WinSendMsg(WinWindowFromID(hwndFrame, FID_CLIENT), WM_CLOSE,
94 MPVOID, MPVOID);
95 }
96# ifdef FORTIFY
97 for (;;) {
98 UCHAR scope = Fortify_LeaveScope();
99 if ((CHAR)scope == 0)
100 break;
101 Runtime_Error(__FILE__, __LINE__, "Attempting to exit thread with scope non-zero (%u)", scope);
102 if ((CHAR)scope < 0)
103 break;
104 }
105 Fortify_DumpAllMemory();
106# endif
107 }
108 }
109 DosSleep(250L);
110 WinDestroyMsgQueue(hmq);
111 }
112 WinTerminate(hab);
113 }
114
115 if (regRet == NO_ERROR) {
116 regRet = DosUnsetExceptionHandler(&regRec);
117 if (regRet != NO_ERROR) {
118 DbgMsg(pszSrcFile, __LINE__,
119 "DosUnsetExceptionHandler failed with error %u", regRet);
120 }
121 }
122 return 0;
123}
Note: See TracBrowser for help on using the repository browser.