[907] | 1 |
|
---|
| 2 | /***********************************************************************
|
---|
| 3 |
|
---|
| 4 | $Id: vtree.c 1341 2008-12-14 22:18:26Z stevenhl $
|
---|
| 5 |
|
---|
| 6 | Tree viewer 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 |
|
---|
[1341] | 16 | #include <stdlib.h> // min
|
---|
[907] | 17 | #include <string.h>
|
---|
| 18 |
|
---|
[2] | 19 | #define INCL_DOS
|
---|
| 20 | #define INCL_WIN
|
---|
[1341] | 21 | #define INCL_DOSEXCEPTIONS // XCTP_...
|
---|
| 22 | #define INCL_DOSERRORS // NO_ERROR
|
---|
[2] | 23 |
|
---|
| 24 | #include "dll\fm3dll.h"
|
---|
[1341] | 25 | #include "dll\mainwnd.h" // hwndTree hwndBubble
|
---|
| 26 | #include "dll\notebook.h" // appname
|
---|
[1176] | 27 | #include "dll\init.h" // InitFM3DLL
|
---|
[1341] | 28 | #include "dll\treecnr.h" // StartTreeCnr
|
---|
| 29 | #include "dll\errutil.h" // Error reporting
|
---|
| 30 | #include "dll\excputil.h" // Exception handlers
|
---|
[2] | 31 |
|
---|
[1341] | 32 | static PSZ pszSrcFile = __FILE__;
|
---|
| 33 |
|
---|
[551] | 34 | int main(int argc, char *argv[])
|
---|
| 35 | {
|
---|
| 36 | HAB hab;
|
---|
| 37 | HMQ hmq;
|
---|
| 38 | QMSG qmsg;
|
---|
[1341] | 39 | UINT x;
|
---|
[551] | 40 | BOOL startminimized = FALSE;
|
---|
[1341] | 41 | APIRET regRet;
|
---|
| 42 | EXCEPTIONREGISTRATIONRECORD regRec = { NULL, NULL };
|
---|
[2] | 43 |
|
---|
[551] | 44 | strcpy(appname, "VTREE");
|
---|
[2] | 45 | DosError(FERR_DISABLEHARDERR);
|
---|
[1341] | 46 |
|
---|
| 47 | regRec.ExceptionHandler = HandleException;
|
---|
| 48 | regRet = DosSetExceptionHandler(®Rec);
|
---|
| 49 | if (regRet != NO_ERROR) {
|
---|
| 50 | DbgMsg(pszSrcFile, __LINE__,
|
---|
| 51 | "DosSetExceptionHandler failed with error %u", regRet);
|
---|
| 52 | }
|
---|
| 53 |
|
---|
[2] | 54 | hab = WinInitialize(0);
|
---|
[551] | 55 | if (hab) {
|
---|
| 56 | hmq = WinCreateMsgQueue(hab, 1024);
|
---|
| 57 | if (hmq) {
|
---|
| 58 | if (InitFM3DLL(hab, argc, argv)) {
|
---|
[1341] | 59 | for (x = 1; x < argc; x++) {
|
---|
| 60 | if (*argv[x] == '~') {
|
---|
| 61 | startminimized = TRUE;
|
---|
| 62 | break;
|
---|
| 63 | }
|
---|
| 64 | }
|
---|
| 65 | hwndTree = StartTreeCnr(HWND_DESKTOP, 0);
|
---|
| 66 | if (hwndTree) {
|
---|
| 67 | if (hwndHelp)
|
---|
| 68 | WinAssociateHelpInstance(hwndHelp, hwndTree);
|
---|
| 69 | if (!WinRestoreWindowPos("FM/2", "VTreeWindowPos", hwndTree)) {
|
---|
[2] | 70 |
|
---|
[1341] | 71 | SWP swp;
|
---|
| 72 | ULONG adjust;
|
---|
[2] | 73 |
|
---|
[1341] | 74 | adjust = WinQuerySysValue(HWND_DESKTOP, SV_CXICON) * 8L;
|
---|
| 75 | WinQueryTaskSizePos(hab, 0L, &swp);
|
---|
| 76 | swp.cx = min(swp.cx, adjust);
|
---|
| 77 | WinSetWindowPos(hwndTree, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
|
---|
| 78 | SWP_SHOW | SWP_MOVE | SWP_SIZE | SWP_ZORDER |
|
---|
| 79 | SWP_ACTIVATE);
|
---|
| 80 | }
|
---|
| 81 | if (startminimized)
|
---|
| 82 | WinSetWindowPos(hwndTree, HWND_TOP, 0, 0, 0, 0, SWP_MINIMIZE);
|
---|
| 83 | else
|
---|
| 84 | WinSetWindowPos(hwndTree, HWND_TOP, 0, 0, 0, 0,
|
---|
| 85 | SWP_SHOW | SWP_ZORDER | SWP_ACTIVATE);
|
---|
| 86 | for (;;) {
|
---|
| 87 | if (!WinGetMsg(hab, &qmsg, (HWND) 0, 0, 0)) {
|
---|
| 88 | if (qmsg.hwnd)
|
---|
| 89 | qmsg.msg = WM_CLOSE;
|
---|
| 90 | else
|
---|
| 91 | break;
|
---|
| 92 | }
|
---|
| 93 | if (hwndBubble &&
|
---|
| 94 | ((qmsg.msg > (WM_BUTTON1DOWN - 1) &&
|
---|
| 95 | qmsg.msg < (WM_BUTTON3DBLCLK + 1)) ||
|
---|
| 96 | (qmsg.msg > (WM_CHORD - 1) &&
|
---|
| 97 | qmsg.msg < (WM_BUTTON3CLICK + 1))) &&
|
---|
| 98 | WinIsWindowVisible(hwndBubble))
|
---|
| 99 | WinShowWindow(hwndBubble, FALSE);
|
---|
| 100 | WinDispatchMsg(hab, &qmsg);
|
---|
| 101 | }
|
---|
| 102 | }
|
---|
[2] | 103 | }
|
---|
[766] | 104 | DosSleep(125);
|
---|
[2] | 105 | WinDestroyMsgQueue(hmq);
|
---|
| 106 | }
|
---|
| 107 | WinTerminate(hab);
|
---|
| 108 | }
|
---|
| 109 | return 0;
|
---|
| 110 | }
|
---|