source: trunk/dll/objwin.c@ 1078

Last change on this file since 1078 was 1078, checked in by Steven Levine, 17 years ago

More Fortify infrastructure enhancements
Rework Fortify_SetOwner
Add Fortify_BecomeOwner
Avoid more spurious leak reports

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