source: trunk/src/user32/wndsubproc.cpp@ 4

Last change on this file since 4 was 4, checked in by ktk, 26 years ago

Import

File size: 3.5 KB
Line 
1/* $Id: wndsubproc.cpp,v 1.1 1999-05-24 20:20:00 ktk Exp $ */
2
3/*
4 * Win32 window subproc class for OS/2
5 *
6 * Copyright 1998 Sander van Leeuwen
7 *
8 *
9 * Project Odin Software License can be found in LICENSE.TXT
10 *
11 */
12#include <os2win.h>
13#include <stdarg.h>
14#include <assert.h>
15#include "misc.h"
16#include "user32.h"
17#include "wndsubproc.h"
18
19static LRESULT WIN32API SubWndCallback(HWND, UINT, WPARAM, LPARAM);
20
21//******************************************************************************
22//******************************************************************************
23Win32WindowSubProc::Win32WindowSubProc(HWND hwnd, WNDPROC_O32 pOpen32Callback)
24{
25#ifdef DEBUG
26 WriteLog("ctr Win32WindowSubProc, %X %X\n", hwnd, pOpen32Callback);
27#endif
28 //Insert it in front of the rest
29 next = windows;
30 windows = this;
31
32 pCallback = pOpen32Callback;
33 this->hwnd = hwnd;
34}
35//******************************************************************************
36//******************************************************************************
37Win32WindowSubProc::~Win32WindowSubProc()
38{
39 Win32WindowSubProc *window = Win32WindowSubProc::windows;
40
41 if(window == this) {
42 windows = next;
43 }
44 else {
45 while(window->next != NULL) {
46 if(window->next == this) {
47 window->next = next;
48 break;
49 }
50 window = window->next;
51 }
52 }
53}
54//******************************************************************************
55//******************************************************************************
56WNDPROC Win32WindowSubProc::GetWin32Callback()
57{
58 return(SubWndCallback);
59}
60//******************************************************************************
61//******************************************************************************
62Win32WindowSubProc *Win32WindowSubProc::FindSubProc(WNDPROC_O32 pOrgCallback)
63{
64 Win32WindowSubProc *window = Win32WindowSubProc::windows;
65
66 while(window != NULL) {
67 if(window->pCallback == pOrgCallback) {
68 return(window);
69 }
70 window = window->next;
71 }
72#ifdef DEBUG
73//// WriteLog("Win32WindowSubProc::FindSubProc, can't find callback %X!\n", pOrgCallback);
74#endif
75 return(NULL);
76}
77//******************************************************************************
78//******************************************************************************
79void Win32WindowSubProc::DeleteSubWindow(HWND hwnd)
80{
81 Win32WindowSubProc *window = windows;
82
83#ifdef DEBUG
84 WriteLog("::DeleteSubWindow, destroy window/dialog %X!!\n", hwnd);
85#endif
86 while(window != NULL) {
87 if(window->hwnd == hwnd) {
88 delete(window);
89 return;
90 }
91 window = window->next;
92 }
93#ifdef DEBUG
94 WriteLog("::DeleteSubWindow, can't find window %X!!\n", hwnd);
95#endif
96}
97//******************************************************************************
98//******************************************************************************
99static LRESULT WIN32API SubWndCallback(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
100{
101 Win32WindowSubProc *curwnd = Win32WindowSubProc::windows;
102 LRESULT rc;
103
104 while(curwnd != NULL) {
105 if(curwnd->hwnd == hwnd) {
106 rc = curwnd->pCallback(hwnd, Msg, wParam, lParam);
107 if(Msg == WM_NCDESTROY) {
108#ifdef DEBUG
109 WriteLog("WM_NCDESTROY received for subwindow %X\n", curwnd->hwnd);
110#endif
111 delete curwnd;
112 }
113 return rc;
114 }
115 curwnd = curwnd->next;
116 }
117#ifdef DEBUG
118 WriteLog("SubWndCallback, can't find window %X %d!!!!\n", hwnd, Msg);
119#endif
120 return 0;
121}
122//******************************************************************************
123//******************************************************************************
124Win32WindowSubProc *Win32WindowSubProc::windows = NULL;
Note: See TracBrowser for help on using the repository browser.