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
RevLine 
[907]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
[1842]9 Copyright (c) 2008, 2015 Steven H.Levine
[907]10
11 05 Jan 08 SHL Sync
[1077]12 18 Jul 08 SHL Add Fortify support
[1336]13 11 Dec 08 SHL Add exception handler support
[1842]14 08 Aug 15 SHL Comments
[907]15
16***********************************************************************/
17
18#include <string.h>
19
[2]20#define INCL_DOS
21#define INCL_WIN
[907]22#define INCL_LONGLONG
[1336]23#define INCL_DOSEXCEPTIONS // XCTP_...
24#define INCL_DOSERRORS // NO_ERROR
[2]25
[1215]26#include "dll\fm3dll.h"
[1341]27#include "dll\mainwnd.h" // hwndBubble
28#include "dll\version.h" // VER...
29#include "dll\init.h" // StartFM3
30#include "dll\notebook.h" // appname
[1077]31#include "dll\fortify.h"
[1336]32#include "dll\errutil.h" // Error reporting
33#include "dll\excputil.h" // Exception handlers
[2]34
[1336]35static PSZ pszSrcFile = __FILE__;
36
[551]37int main(int argc, char *argv[])
38{
39 HAB hab;
40 HMQ hmq;
41 QMSG qmsg;
42 HWND hwndFrame;
[1336]43 APIRET regRet;
44 EXCEPTIONREGISTRATIONRECORD regRec = { NULL, NULL };
[2]45
[551]46 strcpy(appname, "FM/3");
[2]47 DosError(FERR_DISABLEHARDERR);
[1336]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
[2]60 hab = WinInitialize(0);
[551]61 if (hab) {
62 hmq = WinCreateMsgQueue(hab, 2048);
63 if (hmq) {
64 if (InitFM3DLL(hab, argc, argv)) {
65 if (CheckVersion(VERMAJOR, VERMINOR)) {
[1077]66# ifdef FORTIFY
67 Fortify_EnterScope();
68# endif
[551]69 hwndFrame = StartFM3(hab, argc, argv);
[1842]70 if (hwndFrame != (HWND)0) {
[551]71 for (;;) {
72 if (!WinGetMsg(hab, &qmsg, (HWND) 0, 0, 0)) {
[1842]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;
[551]79 }
80 if (hwndBubble &&
[1842]81 ((qmsg.msg > WM_BUTTON1DOWN - 1 &&
82 qmsg.msg < WM_BUTTON3DBLCLK + 1) ||
83 (qmsg.msg > WM_CHORD - 1 &&
84 qmsg.msg < WM_BUTTON3CLICK + 1)) &&
[551]85 WinIsWindowVisible(hwndBubble))
[1842]86 {
87 WinShowWindow(hwndBubble, FALSE); // Hide
88 }
[551]89 WinDispatchMsg(hab, &qmsg);
[1842]90 } // for
91 // Time to die
[551]92 if (WinIsWindow(hab, WinWindowFromID(hwndFrame, FID_CLIENT)))
93 WinSendMsg(WinWindowFromID(hwndFrame, FID_CLIENT), WM_CLOSE,
94 MPVOID, MPVOID);
95 }
[1077]96# ifdef FORTIFY
[1078]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 }
[1341]105 Fortify_DumpAllMemory();
[1077]106# endif
[551]107 }
[2]108 }
109 DosSleep(250L);
110 WinDestroyMsgQueue(hmq);
111 }
112 WinTerminate(hab);
113 }
[1336]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 }
[2]122 return 0;
123}
Note: See TracBrowser for help on using the repository browser.