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