source: trunk/vtree.c@ 1341

Last change on this file since 1341 was 1341, checked in by Steven Levine, 17 years ago

Ticket 26: add thread 1 exception handler support to applets

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.7 KB
Line 
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
12 14 Dec 08 SHL Add exception handler support
13
14***********************************************************************/
15
16#include <stdlib.h> // min
17#include <string.h>
18
19#define INCL_DOS
20#define INCL_WIN
21#define INCL_DOSEXCEPTIONS // XCTP_...
22#define INCL_DOSERRORS // NO_ERROR
23
24#include "dll\fm3dll.h"
25#include "dll\mainwnd.h" // hwndTree hwndBubble
26#include "dll\notebook.h" // appname
27#include "dll\init.h" // InitFM3DLL
28#include "dll\treecnr.h" // StartTreeCnr
29#include "dll\errutil.h" // Error reporting
30#include "dll\excputil.h" // Exception handlers
31
32static PSZ pszSrcFile = __FILE__;
33
34int main(int argc, char *argv[])
35{
36 HAB hab;
37 HMQ hmq;
38 QMSG qmsg;
39 UINT x;
40 BOOL startminimized = FALSE;
41 APIRET regRet;
42 EXCEPTIONREGISTRATIONRECORD regRec = { NULL, NULL };
43
44 strcpy(appname, "VTREE");
45 DosError(FERR_DISABLEHARDERR);
46
47 regRec.ExceptionHandler = HandleException;
48 regRet = DosSetExceptionHandler(&regRec);
49 if (regRet != NO_ERROR) {
50 DbgMsg(pszSrcFile, __LINE__,
51 "DosSetExceptionHandler failed with error %u", regRet);
52 }
53
54 hab = WinInitialize(0);
55 if (hab) {
56 hmq = WinCreateMsgQueue(hab, 1024);
57 if (hmq) {
58 if (InitFM3DLL(hab, argc, argv)) {
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)) {
70
71 SWP swp;
72 ULONG adjust;
73
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 }
103 }
104 DosSleep(125);
105 WinDestroyMsgQueue(hmq);
106 }
107 WinTerminate(hab);
108 }
109 return 0;
110}
Note: See TracBrowser for help on using the repository browser.