| [907] | 1 |  | 
|---|
|  | 2 | /*********************************************************************** | 
|---|
|  | 3 |  | 
|---|
|  | 4 | $Id: fm4.c 1341 2008-12-14 22:18:26Z stevenhl $ | 
|---|
|  | 5 |  | 
|---|
|  | 6 | fm/2 lite applet | 
|---|
|  | 7 |  | 
|---|
|  | 8 | Copyright (c) 1993-98 M. Kimes | 
|---|
|  | 9 | Copyright (c) 2008 Steven H.Levine | 
|---|
|  | 10 |  | 
|---|
|  | 11 | 05 Jan 08 SHL Sync | 
|---|
| [1341] | 12 | 14 Dec 08 SHL Add exception handler support | 
|---|
| [907] | 13 |  | 
|---|
|  | 14 | ***********************************************************************/ | 
|---|
|  | 15 |  | 
|---|
|  | 16 | #include <string.h> | 
|---|
|  | 17 |  | 
|---|
| [2] | 18 | #define INCL_DOS | 
|---|
|  | 19 | #define INCL_WIN | 
|---|
| [907] | 20 | #define INCL_LONGLONG | 
|---|
| [1341] | 21 | #define INCL_DOSEXCEPTIONS              // XCTP_... | 
|---|
|  | 22 | #define INCL_DOSERRORS                  // NO_ERROR | 
|---|
| [2] | 23 |  | 
|---|
| [1177] | 24 | #include "dll\fm3dll.h" | 
|---|
| [1341] | 25 | #include "dll\mainwnd.h"                // hwndBubble | 
|---|
|  | 26 | #include "dll\notebook.h"               // appname | 
|---|
| [2] | 27 | #include "dll\tools.h" | 
|---|
|  | 28 | #include "dll\version.h" | 
|---|
| [1215] | 29 | #include "dll\mainwnd2.h"               // StartFM32 | 
|---|
| [1177] | 30 | #include "dll\init.h"                   // InitFM3DLL | 
|---|
| [1341] | 31 | #include "dll\errutil.h"                // Error reporting | 
|---|
|  | 32 | #include "dll\excputil.h"               // Exception handlers | 
|---|
| [2] | 33 |  | 
|---|
| [1341] | 34 | static PSZ pszSrcFile = __FILE__; | 
|---|
|  | 35 |  | 
|---|
| [551] | 36 | int main(int argc, char *argv[]) | 
|---|
|  | 37 | { | 
|---|
|  | 38 | HAB hab; | 
|---|
|  | 39 | HMQ hmq; | 
|---|
|  | 40 | QMSG qmsg; | 
|---|
|  | 41 | HWND hwndFrame; | 
|---|
| [1341] | 42 | APIRET regRet; | 
|---|
|  | 43 | UINT x; | 
|---|
|  | 44 | EXCEPTIONREGISTRATIONRECORD regRec = { NULL, NULL }; | 
|---|
| [2] | 45 |  | 
|---|
| [551] | 46 | strcpy(appname, "FM/4"); | 
|---|
| [1341] | 47 | DosError(FERR_DISABLEHARDERR); | 
|---|
| [2] | 48 |  | 
|---|
| [1341] | 49 | regRec.ExceptionHandler = HandleException; | 
|---|
|  | 50 | regRet = DosSetExceptionHandler(®Rec); | 
|---|
|  | 51 | if (regRet != NO_ERROR) { | 
|---|
|  | 52 | DbgMsg(pszSrcFile, __LINE__, | 
|---|
|  | 53 | "DosSetExceptionHandler failed with error %u", regRet); | 
|---|
|  | 54 | } | 
|---|
|  | 55 |  | 
|---|
|  | 56 | for (x = 1; x < argc; x++) { | 
|---|
|  | 57 | if (*argv[x] == '+' && !argv[x][1]) | 
|---|
|  | 58 | fLogFile = TRUE; | 
|---|
|  | 59 | if (*argv[x] == '-') { | 
|---|
|  | 60 | if (argv[x][1]) | 
|---|
|  | 61 | strcpy(profile, &argv[x][1]); | 
|---|
| [2] | 62 | } | 
|---|
|  | 63 | } | 
|---|
| [1341] | 64 |  | 
|---|
| [2] | 65 | hab = WinInitialize(0); | 
|---|
| [551] | 66 | if (hab) { | 
|---|
|  | 67 | hmq = WinCreateMsgQueue(hab, 2048); | 
|---|
|  | 68 | if (hmq) { | 
|---|
|  | 69 | if (InitFM3DLL(hab, argc, argv)) { | 
|---|
|  | 70 | if (CheckVersion(VERMAJOR, VERMINOR)) { | 
|---|
|  | 71 | hwndFrame = StartFM32(hab, argc, argv); | 
|---|
|  | 72 | if (hwndFrame != (HWND) 0) { | 
|---|
|  | 73 | for (;;) { | 
|---|
|  | 74 | if (!WinGetMsg(hab, &qmsg, (HWND) 0, 0, 0)) { | 
|---|
|  | 75 | if (qmsg.hwnd) | 
|---|
|  | 76 | qmsg.msg = WM_CLOSE; | 
|---|
|  | 77 | else | 
|---|
|  | 78 | break; | 
|---|
|  | 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 | WinShowWindow(hwndBubble, FALSE); | 
|---|
|  | 87 | WinDispatchMsg(hab, &qmsg); | 
|---|
|  | 88 | } | 
|---|
|  | 89 | if (WinIsWindow(hab, WinWindowFromID(hwndFrame, FID_CLIENT))) | 
|---|
|  | 90 | WinSendMsg(WinWindowFromID(hwndFrame, | 
|---|
|  | 91 | FID_CLIENT), | 
|---|
|  | 92 | WM_CLOSE, MPVOID, MPVOID); | 
|---|
|  | 93 | } | 
|---|
|  | 94 | } | 
|---|
| [2] | 95 | } | 
|---|
|  | 96 | DosSleep(250L); | 
|---|
|  | 97 | WinDestroyMsgQueue(hmq); | 
|---|
|  | 98 | } | 
|---|
|  | 99 | WinTerminate(hab); | 
|---|
|  | 100 | } | 
|---|
|  | 101 | return 0; | 
|---|
|  | 102 | } | 
|---|