| [377] | 1 |  | 
|---|
|  | 2 | /*********************************************************************** | 
|---|
|  | 3 |  | 
|---|
|  | 4 | $Id: objwin.c 1226 2008-09-13 23:12:40Z jbs $ | 
|---|
|  | 5 |  | 
|---|
|  | 6 | Object windows | 
|---|
|  | 7 |  | 
|---|
|  | 8 | Copyright (c) 1993-98 M. Kimes | 
|---|
| [1062] | 9 | Copyright (c) 2006, 2008 Steven H.Levine | 
|---|
| [377] | 10 |  | 
|---|
|  | 11 | 26 Jul 06 SHL Check more run time errors | 
|---|
| [516] | 12 | 02 Nov 06 SHL Comments | 
|---|
| [593] | 13 | 30 Mar 07 GKY Remove GetPString for window class names | 
|---|
| [793] | 14 | 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat | 
|---|
| [1062] | 15 | 08 Jul 08 SHL Correct Fortify_LeaveScope usage and avoid spurious reports | 
|---|
| [377] | 16 |  | 
|---|
|  | 17 | ***********************************************************************/ | 
|---|
|  | 18 |  | 
|---|
| [2] | 19 | #define INCL_DOS | 
|---|
|  | 20 | #define INCL_WIN | 
|---|
| [907] | 21 | #define INCL_LONGLONG                   // dircnrs.h | 
|---|
| [2] | 22 |  | 
|---|
| [1173] | 23 | #include "fm3dll.h" | 
|---|
| [1226] | 24 | #include "fm3dll2.h"                    // #define's for UM_*, control id's, etc. | 
|---|
| [1211] | 25 | #include "init.h"                       // Data declaration(s) | 
|---|
| [2] | 26 | #include "fm3dlg.h" | 
|---|
|  | 27 | #include "fm3str.h" | 
|---|
| [907] | 28 | #include "arccnrs.h"                    // ArcObjWndProc | 
|---|
|  | 29 | #include "errutil.h"                    // Win_Error | 
|---|
| [1078] | 30 | #include "fortify.h" | 
|---|
|  | 31 | #include "misc.h"                       // GetTidForThread | 
|---|
| [1156] | 32 | #include "collect.h"                    // CollectorObjWndProc | 
|---|
|  | 33 | #include "objwin.h" | 
|---|
|  | 34 | #include "treecnr.h"                    // TreeObjWndProc | 
|---|
| [2] | 35 |  | 
|---|
| [1173] | 36 |  | 
|---|
| [377] | 37 | static PSZ pszSrcFile = __FILE__; | 
|---|
|  | 38 |  | 
|---|
| [1156] | 39 | static MRESULT EXPENTRY ObjectWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2); | 
|---|
|  | 40 |  | 
|---|
| [551] | 41 | MRESULT EXPENTRY ObjectWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) | 
|---|
| [413] | 42 | { | 
|---|
| [2] | 43 | DIRCNRDATA *dcd; | 
|---|
|  | 44 |  | 
|---|
| [551] | 45 | dcd = WinQueryWindowPtr(hwnd, QWL_USER); | 
|---|
|  | 46 | if (dcd) { | 
|---|
|  | 47 | switch (dcd->type) { | 
|---|
|  | 48 | case DIR_FRAME: | 
|---|
|  | 49 | return DirObjWndProc(hwnd, msg, mp1, mp2); | 
|---|
|  | 50 | case TREE_FRAME: | 
|---|
|  | 51 | return TreeObjWndProc(hwnd, msg, mp1, mp2); | 
|---|
|  | 52 | case COLLECTOR_FRAME: | 
|---|
|  | 53 | return CollectorObjWndProc(hwnd, msg, mp1, mp2); | 
|---|
|  | 54 | case ARC_FRAME: | 
|---|
|  | 55 | return ArcObjWndProc(hwnd, msg, mp1, mp2); | 
|---|
| [2] | 56 | } | 
|---|
|  | 57 | } | 
|---|
| [551] | 58 | return WinDefWindowProc(hwnd, msg, mp1, mp2); | 
|---|
| [2] | 59 | } | 
|---|
|  | 60 |  | 
|---|
| [551] | 61 | VOID MakeObjWin(VOID * args) | 
|---|
| [413] | 62 | { | 
|---|
| [551] | 63 | HWND ObjectHwnd; | 
|---|
|  | 64 | HAB hab2; | 
|---|
|  | 65 | HMQ hmq2; | 
|---|
|  | 66 | QMSG qmsg2; | 
|---|
| [2] | 67 |  | 
|---|
|  | 68 | hab2 = WinInitialize(0); | 
|---|
| [551] | 69 | if (hab2) { | 
|---|
|  | 70 | hmq2 = WinCreateMsgQueue(hab2, 512); | 
|---|
|  | 71 | if (hmq2) { | 
|---|
| [2] | 72 | DosError(FERR_DISABLEHARDERR); | 
|---|
|  | 73 | WinRegisterClass(hab2, | 
|---|
| [593] | 74 | WC_OBJECTWINDOW, | 
|---|
| [551] | 75 | ObjectWndProc, 0, sizeof(PVOID)); | 
|---|
| [2] | 76 | ObjectHwnd = WinCreateWindow(HWND_OBJECT, | 
|---|
| [593] | 77 | WC_OBJECTWINDOW, | 
|---|
| [551] | 78 | (PSZ) NULL, | 
|---|
|  | 79 | 0, | 
|---|
|  | 80 | 0L, | 
|---|
|  | 81 | 0L, | 
|---|
|  | 82 | 0L, | 
|---|
|  | 83 | 0L, 0L, HWND_TOP, OBJ_FRAME, NULL, NULL); | 
|---|
| [377] | 84 | if (!ObjectHwnd) | 
|---|
| [551] | 85 | Win_Error2(HWND_OBJECT, HWND_DESKTOP, pszSrcFile, __LINE__, | 
|---|
|  | 86 | IDS_WINCREATEWINDOW); | 
|---|
| [377] | 87 | else { | 
|---|
| [1077] | 88 | #       ifdef FORTIFY | 
|---|
|  | 89 | Fortify_EnterScope(); | 
|---|
|  | 90 | #       endif | 
|---|
| [551] | 91 | WinSetWindowPtr(ObjectHwnd, QWL_USER, args); | 
|---|
|  | 92 | /* initially populate container */ | 
|---|
| [1077] | 93 | // 18 Jul 08 SHL fixme to know if this really kills WM_CREATE | 
|---|
| [551] | 94 | WinSendMsg(ObjectHwnd, UM_SETUP, MPVOID, MPVOID); | 
|---|
|  | 95 | PostMsg(ObjectHwnd, UM_RESCAN, MPVOID, MPVOID); | 
|---|
|  | 96 | priority_normal(); | 
|---|
|  | 97 | while (WinGetMsg(hab2, &qmsg2, (HWND) 0, 0, 0)) | 
|---|
|  | 98 | WinDispatchMsg(hab2, &qmsg2); | 
|---|
|  | 99 | WinDestroyWindow(ObjectHwnd); | 
|---|
| [1077] | 100 | #       ifdef FORTIFY | 
|---|
| [1062] | 101 | { | 
|---|
| [1077] | 102 | // Allow container to close and free data | 
|---|
| [1062] | 103 | HWND hwndCnr = ((DIRCNRDATA *)args)->hwndCnr; | 
|---|
|  | 104 | USHORT i; | 
|---|
| [1077] | 105 | for (i = 0; WinIsWindow(hab2, hwndCnr) && i < 10; i++) | 
|---|
|  | 106 | DosSleep(50); | 
|---|
| [1078] | 107 | for (;;) { | 
|---|
|  | 108 | UCHAR scope = Fortify_LeaveScope(); | 
|---|
|  | 109 | if ((CHAR)scope == 0) | 
|---|
|  | 110 | break; | 
|---|
|  | 111 | Runtime_Error(pszSrcFile, __LINE__, "Attempting to exit thread %u with scope non-zero (%u)", | 
|---|
|  | 112 | GetTidForThread(), scope); | 
|---|
|  | 113 | if ((CHAR)scope < 0) | 
|---|
|  | 114 | break; | 
|---|
|  | 115 | } | 
|---|
| [1062] | 116 | } | 
|---|
| [1077] | 117 | #       endif | 
|---|
| [2] | 118 | } | 
|---|
|  | 119 | WinDestroyMsgQueue(hmq2); | 
|---|
|  | 120 | } | 
|---|
|  | 121 | WinTerminate(hab2); | 
|---|
|  | 122 | } | 
|---|
|  | 123 | } | 
|---|
| [793] | 124 |  | 
|---|
|  | 125 | #pragma alloc_text(OBJWIN,ObjectWndProc,MakeObjWin) | 
|---|