| 1 | 
 | 
|---|
| 2 | /***********************************************************************
 | 
|---|
| 3 | 
 | 
|---|
| 4 |   $Id: objwin.c 1173 2008-09-05 22:53:39Z 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 | 
 | 
|---|
| 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 | #ifdef FORTIFY
 | 
|---|
| 30 | #include "misc.h"                       // GetTidForThread
 | 
|---|
| 31 | #endif
 | 
|---|
| 32 | #include "collect.h"                    // CollectorObjWndProc
 | 
|---|
| 33 | #include "objwin.h"
 | 
|---|
| 34 | #include "treecnr.h"                    // TreeObjWndProc
 | 
|---|
| 35 | 
 | 
|---|
| 36 | 
 | 
|---|
| 37 | static PSZ pszSrcFile = __FILE__;
 | 
|---|
| 38 | 
 | 
|---|
| 39 | static MRESULT EXPENTRY ObjectWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
 | 
|---|
| 40 | 
 | 
|---|
| 41 | MRESULT EXPENTRY ObjectWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
 | 
|---|
| 42 | {
 | 
|---|
| 43 |   DIRCNRDATA *dcd;
 | 
|---|
| 44 | 
 | 
|---|
| 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);
 | 
|---|
| 56 |     }
 | 
|---|
| 57 |   }
 | 
|---|
| 58 |   return WinDefWindowProc(hwnd, msg, mp1, mp2);
 | 
|---|
| 59 | }
 | 
|---|
| 60 | 
 | 
|---|
| 61 | VOID MakeObjWin(VOID * args)
 | 
|---|
| 62 | {
 | 
|---|
| 63 |   HWND ObjectHwnd;
 | 
|---|
| 64 |   HAB hab2;
 | 
|---|
| 65 |   HMQ hmq2;
 | 
|---|
| 66 |   QMSG qmsg2;
 | 
|---|
| 67 | 
 | 
|---|
| 68 |   hab2 = WinInitialize(0);
 | 
|---|
| 69 |   if (hab2) {
 | 
|---|
| 70 |     hmq2 = WinCreateMsgQueue(hab2, 512);
 | 
|---|
| 71 |     if (hmq2) {
 | 
|---|
| 72 |       DosError(FERR_DISABLEHARDERR);
 | 
|---|
| 73 |       WinRegisterClass(hab2,
 | 
|---|
| 74 |                        WC_OBJECTWINDOW,
 | 
|---|
| 75 |                        ObjectWndProc, 0, sizeof(PVOID));
 | 
|---|
| 76 |       ObjectHwnd = WinCreateWindow(HWND_OBJECT,
 | 
|---|
| 77 |                                    WC_OBJECTWINDOW,
 | 
|---|
| 78 |                                    (PSZ) NULL,
 | 
|---|
| 79 |                                    0,
 | 
|---|
| 80 |                                    0L,
 | 
|---|
| 81 |                                    0L,
 | 
|---|
| 82 |                                    0L,
 | 
|---|
| 83 |                                    0L, 0L, HWND_TOP, OBJ_FRAME, NULL, NULL);
 | 
|---|
| 84 |       if (!ObjectHwnd)
 | 
|---|
| 85 |         Win_Error2(HWND_OBJECT, HWND_DESKTOP, pszSrcFile, __LINE__,
 | 
|---|
| 86 |                    IDS_WINCREATEWINDOW);
 | 
|---|
| 87 |       else {
 | 
|---|
| 88 | #       ifdef FORTIFY
 | 
|---|
| 89 |         Fortify_EnterScope();
 | 
|---|
| 90 | #       endif
 | 
|---|
| 91 |         WinSetWindowPtr(ObjectHwnd, QWL_USER, args);
 | 
|---|
| 92 |         /* initially populate container */
 | 
|---|
| 93 |         // 18 Jul 08 SHL fixme to know if this really kills WM_CREATE
 | 
|---|
| 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);
 | 
|---|
| 100 | #       ifdef FORTIFY
 | 
|---|
| 101 |         {
 | 
|---|
| 102 |           // Allow container to close and free data
 | 
|---|
| 103 |           HWND hwndCnr = ((DIRCNRDATA *)args)->hwndCnr;
 | 
|---|
| 104 |           USHORT i;
 | 
|---|
| 105 |           for (i = 0; WinIsWindow(hab2, hwndCnr) && i < 10; i++)
 | 
|---|
| 106 |             DosSleep(50);
 | 
|---|
| 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 |           }
 | 
|---|
| 116 |         }
 | 
|---|
| 117 | #       endif
 | 
|---|
| 118 |       }
 | 
|---|
| 119 |       WinDestroyMsgQueue(hmq2);
 | 
|---|
| 120 |     }
 | 
|---|
| 121 |     WinTerminate(hab2);
 | 
|---|
| 122 |   }
 | 
|---|
| 123 | }
 | 
|---|
| 124 | 
 | 
|---|
| 125 | #pragma alloc_text(OBJWIN,ObjectWndProc,MakeObjWin)
 | 
|---|