source: trunk/src/user32/setwindow.cpp@ 232

Last change on this file since 232 was 232, checked in by sandervl, 26 years ago

Dialog control proc override bugfix

File size: 4.4 KB
Line 
1/* $Id: setwindow.cpp,v 1.5 1999-06-27 21:59:40 sandervl Exp $ */
2
3/*
4 * Win32 Get/SetWindowLong/Word user32 API functions 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 <misc.h>
14
15#include <wndproc.h>
16#include <wndclass.h>
17
18//******************************************************************************
19//******************************************************************************
20LONG WIN32API SetWindowLongA(HWND hwnd, int nIndex, LONG arg3)
21{
22 LONG rc;
23
24 dprintf(("USER32: SetWindowLongA %X %d %X\n", hwnd, nIndex, arg3));
25 if(nIndex == GWL_WNDPROC || nIndex == DWL_DLGPROC)
26 {
27 Win32WindowProc *wndproc = Win32WindowProc::FindProc(hwnd);
28 if(wndproc == NULL)
29 {//dialog control that has was automatically created
30 dprintf(("USER32: SetWindowLong create new Win32 to OS/2 callback\n"));
31 wndproc = new Win32WindowProc((WNDPROC)arg3, (WNDPROC_O32)O32_GetWindowLong(hwnd, nIndex));
32 if(wndproc) {
33 O32_SetWindowLong(hwnd, nIndex, (LONG)wndproc->GetOS2Callback());
34 return (LONG)wndproc->GetWin32ToOS2Callback();
35 }
36 else DebugInt3();
37 }
38 else {
39 if(!(nIndex == DWL_DLGPROC && wndproc->IsWindow() == TRUE)) {
40 rc = (LONG)wndproc->GetWin32Callback();
41 if(rc == 0) {
42 //window proc that was just created with os/2 callback only
43 rc = (LONG) wndproc->GetWin32ToOS2Callback();
44 }
45 dprintf(("USER32: SetWindowLong change WindowProc %X to %X\n", rc, arg3));
46 wndproc->SetWin32Callback((WNDPROC)arg3);
47 O32_SetWindowLong(hwnd, nIndex, (LONG)wndproc->GetOS2Callback());
48 return(rc);
49 }
50 }
51 }
52 return O32_SetWindowLong(hwnd, nIndex, arg3);
53}
54//******************************************************************************
55//TODO: Is this always correct? (GWL_ID: window identifier??)
56//******************************************************************************
57LONG WIN32API SetWindowLongW(HWND arg1, int arg2, LONG arg3)
58{
59 dprintf(("USER32: SetWindowLongW %X %d %X\n", arg1, arg2, arg3));
60 return SetWindowLongA(arg1, arg2, arg3);
61}
62//******************************************************************************
63//******************************************************************************
64WORD WIN32API GetWindowWord( HWND arg1, int arg2)
65{
66#ifdef DEBUG
67 WriteLog("USER32: GetWindowWord\n");
68#endif
69 return O32_GetWindowWord(arg1, arg2);
70}
71//******************************************************************************
72//******************************************************************************
73WORD WIN32API SetWindowWord( HWND arg1, int arg2, WORD arg3)
74{
75 dprintf(("USER32: SetWindowWord\n"));
76 return O32_SetWindowWord(arg1, arg2, arg3);
77}
78//******************************************************************************
79//******************************************************************************
80LONG WIN32API GetWindowLongA(HWND hwnd, int nIndex)
81{
82 LONG rc;
83
84 if(nIndex == GWL_WNDPROC || nIndex == DWL_DLGPROC)
85 {
86 dprintf(("USER32: GetWindowLong %X %d\n", hwnd, nIndex));
87
88 Win32WindowProc *wndproc = Win32WindowProc::FindProc(hwnd);
89 if(wndproc) {
90 if(!(nIndex == DWL_DLGPROC && wndproc->IsWindow() == TRUE))
91 return (LONG)wndproc->GetWin32Callback();
92 }
93 else {//probably a dialog box control
94 dprintf(("USER32: GetWindowLong create new Win32 to OS/2 callback\n"));
95 wndproc = new Win32WindowProc(0, (WNDPROC_O32)O32_GetWindowLong(hwnd, nIndex));
96 if(wndproc)
97 return (LONG)wndproc->GetWin32ToOS2Callback();
98 }
99 }
100 rc = O32_GetWindowLong(hwnd, nIndex);
101 //SvL: We must return longs here, not shorts!
102 // (fixed Winhlp32 buttons)
103 if(nIndex == GWL_ID && rc == 0xffff)
104 rc = 0xffffffff;
105 dprintf(("USER32: GetWindowLong %X %d returned %x\n", hwnd, nIndex, rc));
106 return(rc);
107}
108//******************************************************************************
109//******************************************************************************
110LONG WIN32API GetWindowLongW( HWND arg1, int arg2)
111{
112#ifdef DEBUG
113 WriteLog("USER32: GetWindowLongW\n");
114#endif
115 return GetWindowLongA(arg1, arg2); //class procedures..
116}
117//******************************************************************************
118//******************************************************************************
Note: See TracBrowser for help on using the repository browser.