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