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