| 1 |  | 
|---|
| 2 | /*********************************************************************** | 
|---|
| 3 |  | 
|---|
| 4 | $Id: objwin.c 1395 2009-02-08 01:48:16Z gyoung $ | 
|---|
| 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 | 07 Feb 09 GKY Eliminate Win_Error2 by moving function names to PCSZs used in Win_Error | 
|---|
| 17 |  | 
|---|
| 18 | ***********************************************************************/ | 
|---|
| 19 |  | 
|---|
| 20 | #define INCL_DOS | 
|---|
| 21 | #define INCL_WIN | 
|---|
| 22 | #define INCL_LONGLONG                   // dircnrs.h | 
|---|
| 23 |  | 
|---|
| 24 | #include "fm3dll.h" | 
|---|
| 25 | #include "fm3dll2.h"                    // #define's for UM_*, control id's, etc. | 
|---|
| 26 | #include "init.h"                       // Data declaration(s) | 
|---|
| 27 | #include "fm3dlg.h" | 
|---|
| 28 | #include "fm3str.h" | 
|---|
| 29 | #include "arccnrs.h"                    // ArcObjWndProc | 
|---|
| 30 | #include "errutil.h"                    // Win_Error | 
|---|
| 31 | #include "fortify.h" | 
|---|
| 32 | #include "misc.h"                       // GetTidForThread | 
|---|
| 33 | #include "collect.h"                    // CollectorObjWndProc | 
|---|
| 34 | #include "objwin.h" | 
|---|
| 35 | #include "treecnr.h"                    // TreeObjWndProc | 
|---|
| 36 | #include "strutil.h"                    // GetPString | 
|---|
| 37 |  | 
|---|
| 38 | static PSZ pszSrcFile = __FILE__; | 
|---|
| 39 |  | 
|---|
| 40 | static MRESULT EXPENTRY ObjectWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2); | 
|---|
| 41 |  | 
|---|
| 42 | MRESULT EXPENTRY ObjectWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) | 
|---|
| 43 | { | 
|---|
| 44 | DIRCNRDATA *dcd; | 
|---|
| 45 |  | 
|---|
| 46 | dcd = WinQueryWindowPtr(hwnd, QWL_USER); | 
|---|
| 47 | if (dcd) { | 
|---|
| 48 | switch (dcd->type) { | 
|---|
| 49 | case DIR_FRAME: | 
|---|
| 50 | return DirObjWndProc(hwnd, msg, mp1, mp2); | 
|---|
| 51 | case TREE_FRAME: | 
|---|
| 52 | return TreeObjWndProc(hwnd, msg, mp1, mp2); | 
|---|
| 53 | case COLLECTOR_FRAME: | 
|---|
| 54 | return CollectorObjWndProc(hwnd, msg, mp1, mp2); | 
|---|
| 55 | case ARC_FRAME: | 
|---|
| 56 | return ArcObjWndProc(hwnd, msg, mp1, mp2); | 
|---|
| 57 | } | 
|---|
| 58 | } | 
|---|
| 59 | return WinDefWindowProc(hwnd, msg, mp1, mp2); | 
|---|
| 60 | } | 
|---|
| 61 |  | 
|---|
| 62 | VOID MakeObjWin(VOID * args) | 
|---|
| 63 | { | 
|---|
| 64 | HWND ObjectHwnd; | 
|---|
| 65 | HAB hab2; | 
|---|
| 66 | HMQ hmq2; | 
|---|
| 67 | QMSG qmsg2; | 
|---|
| 68 |  | 
|---|
| 69 | hab2 = WinInitialize(0); | 
|---|
| 70 | if (hab2) { | 
|---|
| 71 | hmq2 = WinCreateMsgQueue(hab2, 512); | 
|---|
| 72 | if (hmq2) { | 
|---|
| 73 | DosError(FERR_DISABLEHARDERR); | 
|---|
| 74 | WinRegisterClass(hab2, | 
|---|
| 75 | WC_OBJECTWINDOW, | 
|---|
| 76 | ObjectWndProc, 0, sizeof(PVOID)); | 
|---|
| 77 | ObjectHwnd = WinCreateWindow(HWND_OBJECT, | 
|---|
| 78 | WC_OBJECTWINDOW, | 
|---|
| 79 | (PSZ) NULL, | 
|---|
| 80 | 0, | 
|---|
| 81 | 0L, | 
|---|
| 82 | 0L, | 
|---|
| 83 | 0L, | 
|---|
| 84 | 0L, 0L, HWND_TOP, OBJ_FRAME, NULL, NULL); | 
|---|
| 85 | if (!ObjectHwnd) | 
|---|
| 86 | Win_Error(HWND_OBJECT, HWND_DESKTOP, pszSrcFile, __LINE__, | 
|---|
| 87 | PCSZ_WINCREATEWINDOW); | 
|---|
| 88 | else { | 
|---|
| 89 | #       ifdef FORTIFY | 
|---|
| 90 | Fortify_EnterScope(); | 
|---|
| 91 | #       endif | 
|---|
| 92 | WinSetWindowPtr(ObjectHwnd, QWL_USER, args); | 
|---|
| 93 | /* initially populate container */ | 
|---|
| 94 | // 18 Jul 08 SHL fixme to know if this really kills WM_CREATE | 
|---|
| 95 | WinSendMsg(ObjectHwnd, UM_SETUP, MPVOID, MPVOID); | 
|---|
| 96 | PostMsg(ObjectHwnd, UM_RESCAN, MPVOID, MPVOID); | 
|---|
| 97 | priority_normal(); | 
|---|
| 98 | while (WinGetMsg(hab2, &qmsg2, (HWND) 0, 0, 0)) | 
|---|
| 99 | WinDispatchMsg(hab2, &qmsg2); | 
|---|
| 100 | WinDestroyWindow(ObjectHwnd); | 
|---|
| 101 | #       ifdef FORTIFY | 
|---|
| 102 | { | 
|---|
| 103 | // Allow container to close and free data | 
|---|
| 104 | HWND hwndCnr = ((DIRCNRDATA *)args)->hwndCnr; | 
|---|
| 105 | USHORT i; | 
|---|
| 106 | for (i = 0; WinIsWindow(hab2, hwndCnr) && i < 10; i++) | 
|---|
| 107 | DosSleep(50); | 
|---|
| 108 | for (;;) { | 
|---|
| 109 | UCHAR scope = Fortify_LeaveScope(); | 
|---|
| 110 | if ((CHAR)scope == 0) | 
|---|
| 111 | break; | 
|---|
| 112 | Runtime_Error(pszSrcFile, __LINE__, "Attempting to exit thread %u with scope non-zero (%u)", | 
|---|
| 113 | GetTidForThread(), scope); | 
|---|
| 114 | if ((CHAR)scope < 0) | 
|---|
| 115 | break; | 
|---|
| 116 | } | 
|---|
| 117 | } | 
|---|
| 118 | #       endif | 
|---|
| 119 | } | 
|---|
| 120 | WinDestroyMsgQueue(hmq2); | 
|---|
| 121 | } | 
|---|
| 122 | WinTerminate(hab2); | 
|---|
| 123 | } | 
|---|
| 124 | } | 
|---|
| 125 |  | 
|---|
| 126 | #pragma alloc_text(OBJWIN,ObjectWndProc,MakeObjWin) | 
|---|