| 1 | /* $Id: setwindow.cpp,v 1.3 1999-09-15 23:20:39 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 | //****************************************************************************** | 
|---|
| 20 | LONG 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 | if(arg3 == (LONG)wndproc->GetWin32ToOS2Callback()) { | 
|---|
| 41 | //restore original dialog control handler | 
|---|
| 42 | dprintf(("SetWindowLongA: restore original dialog control handler")); | 
|---|
| 43 | rc = (LONG)wndproc->GetWin32Callback(); | 
|---|
| 44 | wndproc->SetWin32Callback(0); | 
|---|
| 45 | #ifdef DEBUG | 
|---|
| 46 | if(wndproc->GetOrgOS2Callback() == NULL) { | 
|---|
| 47 | DebugInt3(); | 
|---|
| 48 | } | 
|---|
| 49 | #endif | 
|---|
| 50 | O32_SetWindowLong(hwnd, nIndex, (LONG)wndproc->GetOrgOS2Callback()); | 
|---|
| 51 | return rc; | 
|---|
| 52 | } | 
|---|
| 53 | rc = (LONG)wndproc->GetWin32Callback(); | 
|---|
| 54 | if(rc == 0) { | 
|---|
| 55 | //window proc that was just created with os/2 callback only | 
|---|
| 56 | rc = (LONG) wndproc->GetWin32ToOS2Callback(); | 
|---|
| 57 | } | 
|---|
| 58 | dprintf(("USER32:  SetWindowLong change WindowProc %X to %X\n", rc, arg3)); | 
|---|
| 59 | wndproc->SetWin32Callback((WNDPROC)arg3); | 
|---|
| 60 | O32_SetWindowLong(hwnd, nIndex, (LONG)wndproc->GetOS2Callback()); | 
|---|
| 61 | return(rc); | 
|---|
| 62 | } | 
|---|
| 63 | } | 
|---|
| 64 | } | 
|---|
| 65 | return O32_SetWindowLong(hwnd, nIndex, arg3); | 
|---|
| 66 | } | 
|---|
| 67 | //****************************************************************************** | 
|---|
| 68 | //TODO: Is this always correct? (GWL_ID: window identifier??) | 
|---|
| 69 | //****************************************************************************** | 
|---|
| 70 | LONG WIN32API SetWindowLongW(HWND arg1, int arg2, LONG  arg3) | 
|---|
| 71 | { | 
|---|
| 72 | dprintf(("USER32:  SetWindowLongW %X %d %X\n", arg1, arg2, arg3)); | 
|---|
| 73 | return SetWindowLongA(arg1, arg2, arg3); | 
|---|
| 74 | } | 
|---|
| 75 | //****************************************************************************** | 
|---|
| 76 | //****************************************************************************** | 
|---|
| 77 | WORD WIN32API GetWindowWord( HWND arg1, int  arg2) | 
|---|
| 78 | { | 
|---|
| 79 | #ifdef DEBUG | 
|---|
| 80 | WriteLog("USER32:  GetWindowWord\n"); | 
|---|
| 81 | #endif | 
|---|
| 82 | return O32_GetWindowWord(arg1, arg2); | 
|---|
| 83 | } | 
|---|
| 84 | //****************************************************************************** | 
|---|
| 85 | //****************************************************************************** | 
|---|
| 86 | WORD WIN32API SetWindowWord( HWND arg1, int arg2, WORD  arg3) | 
|---|
| 87 | { | 
|---|
| 88 | dprintf(("USER32:  SetWindowWord\n")); | 
|---|
| 89 | return O32_SetWindowWord(arg1, arg2, arg3); | 
|---|
| 90 | } | 
|---|
| 91 | //****************************************************************************** | 
|---|
| 92 | //****************************************************************************** | 
|---|
| 93 | LONG WIN32API GetWindowLongA(HWND hwnd, int nIndex) | 
|---|
| 94 | { | 
|---|
| 95 | LONG rc; | 
|---|
| 96 |  | 
|---|
| 97 | if(nIndex == GWL_WNDPROC || nIndex == DWL_DLGPROC) | 
|---|
| 98 | { | 
|---|
| 99 | dprintf(("USER32:  GetWindowLong %X %d\n", hwnd, nIndex)); | 
|---|
| 100 |  | 
|---|
| 101 | Win32WindowProc *wndproc = Win32WindowProc::FindProc(hwnd); | 
|---|
| 102 | if(wndproc) { | 
|---|
| 103 | if(!(nIndex == DWL_DLGPROC && wndproc->IsWindow() == TRUE)) | 
|---|
| 104 | { | 
|---|
| 105 | rc = (LONG)wndproc->GetWin32Callback(); | 
|---|
| 106 | if(rc == 0) { | 
|---|
| 107 | //window proc that was just created with os/2 callback only | 
|---|
| 108 | rc = (LONG) wndproc->GetWin32ToOS2Callback(); | 
|---|
| 109 | } | 
|---|
| 110 | return rc; | 
|---|
| 111 | } | 
|---|
| 112 | } | 
|---|
| 113 | else {//probably a dialog box control | 
|---|
| 114 | dprintf(("USER32:  GetWindowLong create new Win32 to OS/2 callback\n")); | 
|---|
| 115 | wndproc = new Win32WindowProc(0, (WNDPROC_O32)O32_GetWindowLong(hwnd, nIndex)); | 
|---|
| 116 | if(wndproc) | 
|---|
| 117 | return (LONG)wndproc->GetWin32ToOS2Callback(); | 
|---|
| 118 | } | 
|---|
| 119 | } | 
|---|
| 120 | rc = O32_GetWindowLong(hwnd, nIndex); | 
|---|
| 121 | //SvL: We must return longs here, not shorts! | 
|---|
| 122 | //     (fixed Winhlp32 buttons) | 
|---|
| 123 | if(nIndex == GWL_ID && rc == 0xffff) | 
|---|
| 124 | rc = 0xffffffff; | 
|---|
| 125 | dprintf(("USER32:  GetWindowLong %X %d returned %x\n", hwnd, nIndex, rc)); | 
|---|
| 126 | return(rc); | 
|---|
| 127 | } | 
|---|
| 128 | //****************************************************************************** | 
|---|
| 129 | //****************************************************************************** | 
|---|
| 130 | LONG WIN32API GetWindowLongW( HWND arg1, int  arg2) | 
|---|
| 131 | { | 
|---|
| 132 | #ifdef DEBUG | 
|---|
| 133 | WriteLog("USER32:  GetWindowLongW\n"); | 
|---|
| 134 | #endif | 
|---|
| 135 | return GetWindowLongA(arg1, arg2);   //class procedures.. | 
|---|
| 136 | } | 
|---|
| 137 | //****************************************************************************** | 
|---|
| 138 | //****************************************************************************** | 
|---|