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
RevLine 
[377]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
[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
[907]31#include "fm3dll.h"
[2]32
[377]33static PSZ pszSrcFile = __FILE__;
34
[551]35MRESULT EXPENTRY ObjectWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
[413]36{
[2]37 DIRCNRDATA *dcd;
38
[551]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);
[2]50 }
51 }
[551]52 return WinDefWindowProc(hwnd, msg, mp1, mp2);
[2]53}
54
[551]55VOID MakeObjWin(VOID * args)
[413]56{
[551]57 HWND ObjectHwnd;
58 HAB hab2;
59 HMQ hmq2;
60 QMSG qmsg2;
[2]61
62 hab2 = WinInitialize(0);
[551]63 if (hab2) {
64 hmq2 = WinCreateMsgQueue(hab2, 512);
65 if (hmq2) {
[2]66 DosError(FERR_DISABLEHARDERR);
67 WinRegisterClass(hab2,
[593]68 WC_OBJECTWINDOW,
[551]69 ObjectWndProc, 0, sizeof(PVOID));
[2]70 ObjectHwnd = WinCreateWindow(HWND_OBJECT,
[593]71 WC_OBJECTWINDOW,
[551]72 (PSZ) NULL,
73 0,
74 0L,
75 0L,
76 0L,
77 0L, 0L, HWND_TOP, OBJ_FRAME, NULL, NULL);
[377]78 if (!ObjectHwnd)
[551]79 Win_Error2(HWND_OBJECT, HWND_DESKTOP, pszSrcFile, __LINE__,
80 IDS_WINCREATEWINDOW);
[377]81 else {
[1077]82# ifdef FORTIFY
83 Fortify_EnterScope();
84# endif
[551]85 WinSetWindowPtr(ObjectHwnd, QWL_USER, args);
86 /* initially populate container */
[1077]87 // 18 Jul 08 SHL fixme to know if this really kills WM_CREATE
[551]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);
[1077]94# ifdef FORTIFY
[1062]95 {
[1077]96 // Allow container to close and free data
[1062]97 HWND hwndCnr = ((DIRCNRDATA *)args)->hwndCnr;
98 USHORT i;
[1077]99 for (i = 0; WinIsWindow(hab2, hwndCnr) && i < 10; i++)
100 DosSleep(50);
[1078]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 }
[1062]110 }
[1077]111# endif
[2]112 }
113 WinDestroyMsgQueue(hmq2);
114 }
115 WinTerminate(hab2);
116 }
117}
[793]118
119#pragma alloc_text(OBJWIN,ObjectWndProc,MakeObjWin)
Note: See TracBrowser for help on using the repository browser.