- Timestamp:
- Dec 16, 1999, 1:11:49 AM (26 years ago)
- Location:
- trunk/src/user32
- Files:
-
- 2 deleted
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/HOOK.CPP
r949 r2084 1 /* $Id: HOOK.CPP,v 1. 5 1999-09-15 23:18:47sandervl Exp $ */1 /* $Id: HOOK.CPP,v 1.6 1999-12-16 00:11:44 sandervl Exp $ */ 2 2 3 3 /* 4 * Win32 hook API functions for OS/2 5 * 6 * Copyright 1998 Sander van Leeuwen 4 * Windows hook functions 5 * 6 * Copyright 1999 Sander van Leeuwen (OS/2 Port) 7 * 8 * Port of Wine code (windows\hook.c; dated 990920) 9 * All 16 bits code removed 10 * 11 * Copyright 1994, 1995 Alexandre Julliard 12 * 1996 Andrew Lewycky 13 * 14 * Based on investigations by Alex Korobka 7 15 * 8 16 * 9 17 * Project Odin Software License can be found in LICENSE.TXT 10 * 11 */ 18 */ 19 20 /* 21 * Warning! 22 * A HHOOK is a 32-bit handle for compatibility with Windows 3.0 where it was 23 * a pointer to the next function. Now it is in fact composed of a USER heap 24 * handle in the low 16 bits and of a HOOK_MAGIC value in the high 16 bits. 25 */ 26 12 27 #include <os2win.h> 13 #include <stdarg.h> 14 #include "misc.h" 15 #include "hooks.h" 16 17 //****************************************************************************** 18 //****************************************************************************** 19 HHOOK WIN32API SetWindowsHookExA(int idHook, HOOKPROC hkprc, HINSTANCE hmod, DWORD dwThreadId) 20 { 21 HHOOK rc; 22 HOOKPROC_O32 os2hkprc; 23 24 switch(idHook) { 25 case WH_CALLWNDPROC: 26 os2hkprc = HkWindow::GetOS2Hook(); 27 break; 28 case WH_CBT: 28 #include "hook.h" 29 #include "win.h" 30 #include "queue.h" 31 #include "task.h" 32 #include "winproc.h" 33 #include "debugtools.h" 34 #include <misc.h> 35 #include <heapstring.h> 36 #include <vmutex.h> 37 #include <wprocess.h> 38 39 DEFAULT_DEBUG_CHANNEL(hook) 40 41 #include "pshpack1.h" 42 43 /* Hook data (pointed to by a HHOOK) */ 44 typedef struct 45 { 46 HANDLE next; /* 00 Next hook in chain */ 47 HOOKPROC proc; /* 04 Hook procedure (original) */ 48 INT id; /* 08 Hook id (WH_xxx) */ 49 DWORD ownerThread; /* 0C Owner thread (0 for system hook) */ 50 HMODULE ownerModule; /* 10 Owner module */ 51 DWORD flags; /* 14 flags */ 52 DWORD magic; /* 18 magic dword */ 53 } HOOKDATA; 54 55 #include "poppack.h" 56 57 #define HOOK_MAGIC1 ((int)'H' | (int)'K' << 8) /* 'HK' */ 58 #define HOOK_MAGIC ((HOOK_MAGIC1<<16)|HOOK_MAGIC1) // 'HKHK' 59 60 #define CHECK_MAGIC(a) ((a != 0) && (((HOOKDATA *)a)->magic == HOOK_MAGIC)) 61 62 //Global DLL Data 63 #pragma data_seg(_GLOBALDATA) 64 static HANDLE HOOK_systemHooks[WH_NB_HOOKS] = { 0 }; 65 static VMutex systemHookMutex(TRUE); 66 #pragma data_seg() 67 static HANDLE HOOK_threadHooks[WH_NB_HOOKS] = { 0 }; 68 static VMutex threadHookMutex; 69 70 typedef VOID (*HOOK_MapFunc)(INT, INT, WPARAM *, LPARAM *); 71 typedef VOID (*HOOK_UnMapFunc)(INT, INT, WPARAM, LPARAM, WPARAM, 72 LPARAM); 73 74 /*********************************************************************** 75 * HOOK_Map32ATo32W 76 */ 77 static void HOOK_Map32ATo32W(INT id, INT code, WPARAM *pwParam, 78 LPARAM *plParam) 79 { 80 if (id == WH_CBT && code == HCBT_CREATEWND) 81 { 82 LPCBT_CREATEWNDA lpcbtcwA = (LPCBT_CREATEWNDA)*plParam; 83 LPCBT_CREATEWNDW lpcbtcwW = (LPCBT_CREATEWNDW)HeapAlloc(GetProcessHeap(), 0, 84 sizeof(*lpcbtcwW) ); 85 lpcbtcwW->lpcs = (CREATESTRUCTW*)HeapAlloc( GetProcessHeap(), 0, sizeof(*lpcbtcwW->lpcs) ); 86 87 lpcbtcwW->hwndInsertAfter = lpcbtcwA->hwndInsertAfter; 88 *lpcbtcwW->lpcs = *(LPCREATESTRUCTW)lpcbtcwA->lpcs; 89 90 if (HIWORD(lpcbtcwA->lpcs->lpszName)) 29 91 { 30 HkCBT *hkhook = new HkCBT(0, hkprc, hmod, dwThreadId);; 31 #ifdef DEBUG 32 WriteLog("OS2SetWindowsHookExA WH_CBT %X, %X, %X, %X\n", idHook, hkprc, hmod, dwThreadId); 92 lpcbtcwW->lpcs->lpszName = HEAP_strdupAtoW( GetProcessHeap(), 0, 93 lpcbtcwA->lpcs->lpszName ); 94 } 95 else 96 lpcbtcwW->lpcs->lpszName = (LPWSTR)lpcbtcwA->lpcs->lpszName; 97 98 if (HIWORD(lpcbtcwA->lpcs->lpszClass)) 99 { 100 lpcbtcwW->lpcs->lpszClass = HEAP_strdupAtoW( GetProcessHeap(), 0, 101 lpcbtcwA->lpcs->lpszClass ); 102 } 103 else 104 lpcbtcwW->lpcs->lpszClass = (LPCWSTR)lpcbtcwA->lpcs->lpszClass; 105 *plParam = (LPARAM)lpcbtcwW; 106 } 107 return; 108 } 109 110 111 /*********************************************************************** 112 * HOOK_UnMap32ATo32W 113 */ 114 static void HOOK_UnMap32ATo32W(INT id, INT code, WPARAM wParamOrig, 115 LPARAM lParamOrig, WPARAM wParam, 116 LPARAM lParam) 117 { 118 if (id == WH_CBT && code == HCBT_CREATEWND) 119 { 120 LPCBT_CREATEWNDW lpcbtcwW = (LPCBT_CREATEWNDW)lParam; 121 if (HIWORD(lpcbtcwW->lpcs->lpszName)) 122 HeapFree( GetProcessHeap(), 0, (LPWSTR)lpcbtcwW->lpcs->lpszName ); 123 if (HIWORD(lpcbtcwW->lpcs->lpszClass)) 124 HeapFree( GetProcessHeap(), 0, (LPWSTR)lpcbtcwW->lpcs->lpszClass ); 125 HeapFree( GetProcessHeap(), 0, lpcbtcwW->lpcs ); 126 HeapFree( GetProcessHeap(), 0, lpcbtcwW ); 127 } 128 return; 129 } 130 131 132 /*********************************************************************** 133 * HOOK_Map32WTo32A 134 */ 135 static void HOOK_Map32WTo32A(INT id, INT code, WPARAM *pwParam, 136 LPARAM *plParam) 137 { 138 if (id == WH_CBT && code == HCBT_CREATEWND) 139 { 140 LPCBT_CREATEWNDW lpcbtcwW = (LPCBT_CREATEWNDW)*plParam; 141 LPCBT_CREATEWNDA lpcbtcwA = (LPCBT_CREATEWNDA)HeapAlloc(GetProcessHeap(), 0, 142 sizeof(*lpcbtcwA) ); 143 lpcbtcwA->lpcs = (CREATESTRUCTA*)HeapAlloc( GetProcessHeap(), 0, sizeof(*lpcbtcwA->lpcs) ); 144 145 lpcbtcwA->hwndInsertAfter = lpcbtcwW->hwndInsertAfter; 146 *lpcbtcwA->lpcs = *(LPCREATESTRUCTA)lpcbtcwW->lpcs; 147 148 if (HIWORD(lpcbtcwW->lpcs->lpszName)) 149 lpcbtcwA->lpcs->lpszName = HEAP_strdupWtoA( GetProcessHeap(), 0, 150 lpcbtcwW->lpcs->lpszName ); 151 else 152 lpcbtcwA->lpcs->lpszName = (LPSTR)lpcbtcwW->lpcs->lpszName; 153 154 if (HIWORD(lpcbtcwW->lpcs->lpszClass)) 155 lpcbtcwA->lpcs->lpszClass = HEAP_strdupWtoA( GetProcessHeap(), 0, 156 lpcbtcwW->lpcs->lpszClass ); 157 else 158 lpcbtcwA->lpcs->lpszClass = (LPSTR)lpcbtcwW->lpcs->lpszClass; 159 *plParam = (LPARAM)lpcbtcwA; 160 } 161 return; 162 } 163 164 165 /*********************************************************************** 166 * HOOK_UnMap32WTo32A 167 */ 168 static void HOOK_UnMap32WTo32A(INT id, INT code, WPARAM wParamOrig, 169 LPARAM lParamOrig, WPARAM wParam, 170 LPARAM lParam) 171 { 172 if (id == WH_CBT && code == HCBT_CREATEWND) 173 { 174 LPCBT_CREATEWNDA lpcbtcwA = (LPCBT_CREATEWNDA)lParam; 175 if (HIWORD(lpcbtcwA->lpcs->lpszName)) 176 HeapFree( GetProcessHeap(), 0, (LPSTR)lpcbtcwA->lpcs->lpszName ); 177 if (HIWORD(lpcbtcwA->lpcs->lpszClass)) 178 HeapFree( GetProcessHeap(), 0, (LPSTR)lpcbtcwA->lpcs->lpszClass ); 179 HeapFree( GetProcessHeap(), 0, lpcbtcwA->lpcs ); 180 HeapFree( GetProcessHeap(), 0, lpcbtcwA ); 181 } 182 return; 183 } 184 185 186 /*********************************************************************** 187 * Map Function Tables 188 */ 189 static const HOOK_MapFunc HOOK_MapFuncs[3][3] = 190 { 191 { NULL, NULL, NULL }, 192 { NULL, NULL, HOOK_Map32ATo32W }, 193 { NULL, HOOK_Map32WTo32A, NULL } 194 }; 195 196 static const HOOK_UnMapFunc HOOK_UnMapFuncs[3][3] = 197 { 198 { NULL, NULL, NULL }, 199 { NULL, NULL, HOOK_UnMap32ATo32W }, 200 { NULL, HOOK_UnMap32WTo32A, NULL } 201 }; 202 203 204 /*********************************************************************** 205 * Internal Functions 206 */ 207 208 /*********************************************************************** 209 * HOOK_GetNextHook 210 * 211 * Get the next hook of a given hook. 212 */ 213 static HANDLE HOOK_GetNextHook( HANDLE hook ) 214 { 215 HOOKDATA *data = (HOOKDATA *)hook; 216 217 if (!data || !hook) return 0; 218 if (data->next) return data->next; 219 if (!data->ownerThread) return 0; /* Already system hook */ 220 221 /* Now start enumerating the system hooks */ 222 return HOOK_systemHooks[data->id - WH_MINHOOK]; 223 } 224 225 226 /*********************************************************************** 227 * HOOK_GetHook 228 * 229 * Get the first hook for a given type. 230 */ 231 static HANDLE HOOK_GetHook( INT id, DWORD threadId ) 232 { 233 MESSAGEQUEUE *queue; 234 HANDLE hook = 0; 235 THDB *thdb; 236 237 thdb = GetTHDBFromThreadId(threadId); 238 if(thdb) { 239 hook = thdb->hooks[id - WH_MINHOOK]; 240 } 241 if (!hook) hook = HOOK_systemHooks[id - WH_MINHOOK]; 242 243 return hook; 244 } 245 246 247 /*********************************************************************** 248 * HOOK_SetHook 249 * 250 * Install a given hook. 251 */ 252 static HHOOK HOOK_SetHook( INT id, LPVOID proc, INT type, 253 HMODULE hModule, DWORD dwThreadId ) 254 { 255 HOOKDATA *data; 256 THDB *thdb; 257 258 if ((id < WH_MINHOOK) || (id > WH_MAXHOOK) || !proc ) 259 { 260 SetLastError(ERROR_INVALID_PARAMETER); 261 return 0; 262 } 263 264 dprintf(("Setting hook %d: %08x %04x %08lx\n", 265 id, (UINT)proc, hModule, dwThreadId )); 266 267 #ifndef __WIN32OS2__ 268 /* Create task queue if none present */ 269 GetFastQueue16(); 270 271 if (id == WH_JOURNALPLAYBACK) EnableHardwareInput16(FALSE); 33 272 #endif 34 return((HHOOK)hkhook); 273 274 275 if (dwThreadId) /* Task-specific hook */ 276 { 277 if ((id == WH_JOURNALRECORD) || (id == WH_JOURNALPLAYBACK) || 278 (id == WH_SYSMSGFILTER)) { 279 SetLastError(ERROR_INVALID_PARAMETER); 280 return 0; /* System-only hooks */ 35 281 } 36 case WH_DEBUG: 37 os2hkprc = HkDebug::GetOS2Hook(); 38 break; 39 case WH_JOURNALPLAYBACK: 40 os2hkprc = HkJrnlPlayback::GetOS2Hook(); 41 break; 42 case WH_JOURNALRECORD: 43 os2hkprc = HkJrnlRecord::GetOS2Hook(); 44 break; 45 case WH_GETMESSAGE: 46 os2hkprc = HkGetMessage::GetOS2Hook(); 47 break; 48 case WH_MOUSE: 49 os2hkprc = HkMouse::GetOS2Hook(); 50 break; 51 case WH_KEYBOARD: 52 os2hkprc = HkKeyboard::GetOS2Hook(); 53 break; 54 case WH_SHELL: 55 os2hkprc = HkShell::GetOS2Hook(); 56 break; 57 case WH_SYSMSGFILTER: 58 os2hkprc = HkSysMsgFilter::GetOS2Hook(); 59 break; 60 case WH_MSGFILTER: 61 os2hkprc = HkMsgFilter::GetOS2Hook(); 62 break; 63 } 64 65 rc = O32_SetWindowsHookEx(idHook, os2hkprc, hmod, dwThreadId); 66 67 if(rc) { 68 switch(idHook) { 69 case WH_CALLWNDPROC: 70 new HkWindow(rc, hkprc, hmod, dwThreadId); 71 break; 72 case WH_CBT: 73 break; 74 case WH_DEBUG: 75 new HkDebug(rc, hkprc, hmod, dwThreadId);; 76 break; 77 case WH_JOURNALPLAYBACK: 78 new HkJrnlPlayback(rc, hkprc, hmod, dwThreadId);; 79 break; 80 case WH_JOURNALRECORD: 81 new HkJrnlRecord(rc, hkprc, hmod, dwThreadId);; 82 break; 83 case WH_GETMESSAGE: 84 new HkGetMessage(rc, hkprc, hmod, dwThreadId);; 85 break; 86 case WH_MOUSE: 87 new HkMouse(rc, hkprc, hmod, dwThreadId);; 88 break; 89 case WH_KEYBOARD: 90 new HkKeyboard(rc, hkprc, hmod, dwThreadId);; 91 break; 92 case WH_SHELL: 93 new HkShell(rc, hkprc, hmod, dwThreadId);; 94 break; 95 case WH_SYSMSGFILTER: 96 new HkSysMsgFilter(rc, hkprc, hmod, dwThreadId);; 97 break; 98 case WH_MSGFILTER: 99 new HkMsgFilter(rc, hkprc, hmod, dwThreadId);; 100 break; 101 } 102 } 103 #ifdef DEBUG 104 WriteLog("OS2SetWindowsHookExA %X, %X, %X, %X, returned %X\n", idHook, hkprc, hmod, dwThreadId, rc); 282 } 283 284 /* Create the hook structure */ 285 286 data = (HOOKDATA *) HeapAlloc(GetProcessHeap(), 0, sizeof(HOOKDATA)); 287 data->proc = (HOOKPROC)proc; 288 data->id = id; 289 data->ownerThread = dwThreadId; 290 data->ownerModule = hModule; 291 data->flags = type; 292 data->magic = HOOK_MAGIC; 293 294 /* Insert it in the correct linked list */ 295 if(dwThreadId) 296 { 297 thdb = GetTHDBFromThreadId(dwThreadId); 298 if(!thdb) { 299 dprintf(("HOOK_SetHook: can't find thread database for thread %x", dwThreadId)); 300 return 0; 301 } 302 threadHookMutex.enter(); 303 data->next = thdb->hooks[id - WH_MINHOOK]; 304 thdb->hooks[id - WH_MINHOOK] = (DWORD)data; 305 threadHookMutex.leave(); 306 } 307 else 308 { 309 systemHookMutex.enter(); 310 data->next = HOOK_systemHooks[id - WH_MINHOOK]; 311 HOOK_systemHooks[id - WH_MINHOOK] = (HANDLE)data; 312 systemHookMutex.leave(); 313 } 314 315 return (HHOOK)data; 316 } 317 318 319 /*********************************************************************** 320 * HOOK_RemoveHook 321 * 322 * Remove a hook from the list. 323 */ 324 static BOOL HOOK_RemoveHook( HOOKDATA *data ) 325 { 326 HOOKDATA *prevHook; 327 THDB *thdb; 328 VMutex *hookMutex; 329 330 dprintf(("Removing hook %08x\n", data)); 331 332 if (data->flags & HOOK_INUSE) 333 { 334 /* Mark it for deletion later on */ 335 dprintf(("Hook still running, deletion delayed\n" )); 336 data->flags |= HOOK_DELAYED_DELETE; 337 return TRUE; 338 } 339 340 #ifndef __WIN32OS2__ 341 if (data->id == WH_JOURNALPLAYBACK) EnableHardwareInput16(TRUE); 105 342 #endif 106 return(rc); 107 } 108 //****************************************************************************** 109 //****************************************************************************** 110 HHOOK WIN32API SetWindowsHookA(int idHook, HOOKPROC hkprc) 111 { 112 HHOOK rc; 113 114 rc = SetWindowsHookExA(idHook, hkprc, NULL, 0); 115 #ifdef DEBUG 116 WriteLog("OS2SetWindowsHookA %X, %X, returned %X\n", idHook, hkprc, rc); 343 344 /* Remove it from the linked list */ 345 346 if (data->ownerThread) 347 { 348 thdb = GetTHDBFromThreadId(data->ownerThread); 349 if(!thdb) { 350 dprintf(("HOOK_RemoveHook: can't find thread database for thread %x", data->ownerThread)); 351 return FALSE; 352 } 353 hookMutex = &threadHookMutex; 354 hookMutex->enter(); 355 prevHook = (HOOKDATA *)thdb->hooks[data->id - WH_MINHOOK]; 356 } 357 else { 358 hookMutex = &systemHookMutex; 359 hookMutex->enter(); 360 prevHook = (HOOKDATA *)HOOK_systemHooks[data->id - WH_MINHOOK]; 361 } 362 while (prevHook && prevHook != data) 363 prevHook = (HOOKDATA *)prevHook->next; 364 365 if (!prevHook) { 366 hookMutex->leave(); 367 return FALSE; 368 } 369 prevHook = (HOOKDATA *)data->next; 370 hookMutex->leave(); 371 372 HeapFree(GetProcessHeap(), 0, (LPVOID)data ); 373 return TRUE; 374 } 375 376 377 /*********************************************************************** 378 * HOOK_FindValidHook 379 */ 380 static HANDLE HOOK_FindValidHook( HANDLE hook ) 381 { 382 HOOKDATA *data; 383 384 for (;;) 385 { 386 if (!(data = (HOOKDATA *)hook)) return 0; 387 if (data->proc) return hook; 388 hook = data->next; 389 } 390 } 391 392 393 /*********************************************************************** 394 * HOOK_CallHook 395 * 396 * Call a hook procedure. 397 */ 398 static LRESULT HOOK_CallHook( HANDLE hook, INT fromtype, INT code, 399 WPARAM wParam, LPARAM lParam ) 400 { 401 MESSAGEQUEUE *queue; 402 HANDLE prevHook; 403 HOOKDATA *data = (HOOKDATA *)hook; 404 LRESULT ret; 405 406 WPARAM wParamOrig = wParam; 407 LPARAM lParamOrig = lParam; 408 HOOK_MapFunc MapFunc; 409 HOOK_UnMapFunc UnMapFunc; 410 411 MapFunc = HOOK_MapFuncs[fromtype][data->flags & HOOK_MAPTYPE]; 412 UnMapFunc = HOOK_UnMapFuncs[fromtype][data->flags & HOOK_MAPTYPE]; 413 414 if (MapFunc) 415 MapFunc( data->id, code, &wParam, &lParam ); 416 417 /* Now call it */ 418 419 data->flags |= HOOK_INUSE; 420 421 dprintf2(("Calling hook %04x: %d %08x %08lx\n", hook, code, wParam, lParam )); 422 423 ret = data->proc(code, wParam, lParam); 424 425 data->flags &= ~HOOK_INUSE; 426 427 if (UnMapFunc) 428 UnMapFunc( data->id, code, wParamOrig, lParamOrig, wParam, lParam ); 429 430 if(data->flags & HOOK_DELAYED_DELETE) HOOK_RemoveHook( data ); 431 432 return ret; 433 } 434 435 /*********************************************************************** 436 * Exported Functions & APIs 437 */ 438 439 /*********************************************************************** 440 * HOOK_IsHooked 441 * 442 * Replacement for calling HOOK_GetHook from other modules. 443 */ 444 BOOL HOOK_IsHooked( INT id ) 445 { 446 /* Hmmm. Use GetThreadQueue(0) instead of GetFastQueue() here to 447 avoid queue being created if someone wants to merely check ... */ 448 449 return HOOK_GetHook( id, GetCurrentThreadId() ) != 0; 450 } 451 452 /*********************************************************************** 453 * HOOK_CallHooks32A 454 * 455 * Call a hook chain. 456 */ 457 LRESULT HOOK_CallHooksA( INT id, INT code, WPARAM wParam, 458 LPARAM lParam ) 459 { 460 HANDLE hook; 461 462 if (!(hook = HOOK_GetHook( id, GetCurrentThreadId() ))) return 0; 463 if (!(hook = HOOK_FindValidHook(hook))) return 0; 464 return HOOK_CallHook( hook, HOOK_WIN32A, code, wParam, lParam ); 465 } 466 467 /*********************************************************************** 468 * HOOK_CallHooks32W 469 * 470 * Call a hook chain. 471 */ 472 LRESULT HOOK_CallHooksW( INT id, INT code, WPARAM wParam, 473 LPARAM lParam ) 474 { 475 HANDLE hook; 476 477 if (!(hook = HOOK_GetHook( id, GetCurrentThreadId() ))) return 0; 478 if (!(hook = HOOK_FindValidHook(hook))) return 0; 479 return HOOK_CallHook( hook, HOOK_WIN32W, code, wParam, 480 lParam ); 481 } 482 483 484 #if 0 485 /*********************************************************************** 486 * HOOK_ResetQueueHooks 487 */ 488 void HOOK_ResetQueueHooks( HQUEUE hQueue ) 489 { 490 MESSAGEQUEUE *queue; 491 492 if ((queue = (MESSAGEQUEUE *)QUEUE_Lock( hQueue )) != NULL) 493 { 494 HOOKDATA* data; 495 HHOOK hook; 496 int id; 497 for( id = WH_MINHOOK; id <= WH_MAXHOOK; id++ ) 498 { 499 hook = queue->hooks[id - WH_MINHOOK]; 500 while( hook ) 501 { 502 if( (data = (HOOKDATA *)hook) ) 503 { 504 data->ownerQueue = hQueue; 505 hook = data->next; 506 } else break; 507 } 508 } 509 510 QUEUE_Unlock( queue ); 511 } 512 } 117 513 #endif 118 return(rc); 119 } 120 //****************************************************************************** 121 //****************************************************************************** 122 HHOOK WIN32API SetWindowsHookExW(int idHook, HOOKPROC hkprc, HINSTANCE hmod, DWORD dwThreadId) 123 { 124 #ifdef DEBUG 125 WriteLog("OS2SetWindowsHookExW\n"); 126 #endif 127 return(SetWindowsHookExA(idHook, hkprc, hmod, dwThreadId)); 128 } 129 //****************************************************************************** 130 //****************************************************************************** 131 BOOL WIN32API UnhookWindowsHookEx(HHOOK hook) 132 { 133 #ifdef DEBUG 134 WriteLog("OS2UnhookWindowsHookEx\n"); 135 #endif 136 137 if(HkWindow::UnHookWindowsHook(hook) == FALSE) 138 if(HkCBT::UnHookWindowsHook(hook) == TRUE) { 139 return(TRUE); 140 } 141 else 142 if(HkGetMessage::UnHookWindowsHook(hook) == FALSE) 143 if(HkMsgFilter::UnHookWindowsHook(hook) == FALSE) 144 if(HkSysMsgFilter::UnHookWindowsHook(hook) == FALSE) 145 if(HkMouse::UnHookWindowsHook(hook) == FALSE) 146 if(HkKeyboard::UnHookWindowsHook(hook) == FALSE) 147 if(HkShell::UnHookWindowsHook(hook) == FALSE) 148 if(HkDebug::UnHookWindowsHook(hook) == FALSE) 149 if(HkJrnlPlayback::UnHookWindowsHook(hook) == FALSE) 150 if(HkJrnlRecord::UnHookWindowsHook(hook) == FALSE) { 151 dprintf(("Hook %X not found!\n", hook)); 152 } 153 return O32_UnhookWindowsHookEx(hook); 154 } 155 //****************************************************************************** 156 //****************************************************************************** 157 BOOL WIN32API UnhookWindowsHook(int nCode, HOOKPROC hkproc) 158 { 159 HHOOK hook = 0; 160 161 switch(nCode) { 162 case WH_CALLWNDPROC: 163 hook = HkWindow::FindHookProc(hkproc); 164 break; 165 case WH_CBT: 166 hook = HkCBT::FindHookProc(hkproc); 167 break; 168 case WH_DEBUG: 169 hook = HkDebug::FindHookProc(hkproc); 170 break; 171 case WH_JOURNALPLAYBACK: 172 hook = HkJrnlPlayback::FindHookProc(hkproc); 173 break; 174 case WH_JOURNALRECORD: 175 hook = HkJrnlRecord::FindHookProc(hkproc); 176 break; 177 case WH_GETMESSAGE: 178 hook = HkGetMessage::FindHookProc(hkproc); 179 break; 180 case WH_MOUSE: 181 hook = HkMouse::FindHookProc(hkproc); 182 break; 183 case WH_KEYBOARD: 184 hook = HkKeyboard::FindHookProc(hkproc); 185 break; 186 case WH_SHELL: 187 hook = HkShell::FindHookProc(hkproc); 188 break; 189 case WH_SYSMSGFILTER: 190 hook = HkSysMsgFilter::FindHookProc(hkproc); 191 break; 192 case WH_MSGFILTER: 193 hook = HkMsgFilter::FindHookProc(hkproc); 194 break; 195 } 196 #ifdef DEBUG 197 WriteLog("OS2UnhookWindowsHook %X\n", hook); 198 #endif 199 if(hook == 0) 200 return(FALSE); 201 202 return O32_UnhookWindowsHookEx(hook); 203 } 204 //****************************************************************************** 205 //****************************************************************************** 206 LRESULT WIN32API CallNextHookEx(HHOOK arg1, int arg2, WPARAM arg3, LPARAM arg4) 207 { 208 HkCBT *hook; 209 210 #ifdef DEBUG 211 WriteLog("OS2CallNextHookEx\n"); 212 #endif 213 if((hook = HkCBT::FindHook(arg1)) != NULL) { 214 return hook->CallNextHook(arg1, arg2, arg3, arg4); 215 } 216 else return O32_CallNextHookEx(arg1, arg2, arg3, arg4); 217 } 218 //****************************************************************************** 219 //TODO 220 //****************************************************************************** 221 BOOL WIN32API CallMsgFilterA( LPMSG msg, int nCode) 222 { 223 #ifdef DEBUG 224 WriteLog("USER32: CallMsgFilterA\n"); 225 #endif 226 #if 0 227 if(HkSysMsgFilter::OS2HkCBTProc(msg->hwnd, nCode, 0, (LPARAM)msg)) 228 return TRUE; 229 230 return HkMsgFilter::OS2HkCBTProc(hwnd, Msg, wParam, lParam); 231 #else 232 return 0; 233 #endif 234 } 235 //****************************************************************************** 236 //TODO 237 //****************************************************************************** 238 BOOL WIN32API CallMsgFilterW( LPMSG msg, int nCode) 239 { 240 #ifdef DEBUG 241 WriteLog("USER32: CallMsgFilterW\n"); 242 #endif 243 #if 0 244 if(HkSysMsgFilter::OS2HkCBTProc(msg->hwnd, nCode, 0, (LPARAM)msg)) 245 return TRUE; 246 247 return HkMsgFilter::OS2HkCBTProc(hwnd, Msg, wParam, lParam); 248 #else 249 return 0; 250 #endif 251 } 252 //****************************************************************************** 253 //****************************************************************************** 514 515 /*********************************************************************** 516 * HOOK_FreeModuleHooks 517 */ 518 void HOOK_FreeModuleHooks( HMODULE hModule ) 519 { 520 /* remove all system hooks registered by this module */ 521 522 HOOKDATA* hptr; 523 HHOOK hook, next; 524 int id; 525 526 for( id = WH_MINHOOK; id <= WH_MAXHOOK; id++ ) 527 { 528 hook = HOOK_systemHooks[id - WH_MINHOOK]; 529 while( hook ) 530 if( (hptr = (HOOKDATA *)hook) ) 531 { 532 next = hptr->next; 533 if( hptr->ownerModule == hModule ) 534 { 535 hptr->flags &= HOOK_MAPTYPE; 536 HOOK_RemoveHook(hptr); 537 } 538 hook = next; 539 } 540 else hook = 0; 541 } 542 } 543 544 /*********************************************************************** 545 * HOOK_FreeQueueHooks 546 */ 547 void HOOK_FreeQueueHooks( DWORD threadId ) 548 { 549 /* remove all hooks registered by this queue */ 550 551 HOOKDATA* hptr = NULL; 552 HHOOK hook, next; 553 int id; 554 555 for( id = WH_MINHOOK; id <= WH_MAXHOOK; id++ ) 556 { 557 hook = HOOK_GetHook( id, threadId ); 558 while( hook ) 559 { 560 next = HOOK_GetNextHook(hook); 561 562 hptr = (HOOKDATA *)hook; 563 if( hptr && hptr->ownerThread == threadId ) 564 { 565 hptr->flags &= HOOK_MAPTYPE; 566 HOOK_RemoveHook(hptr); 567 } 568 hook = next; 569 } 570 } 571 } 572 573 574 /*********************************************************************** 575 * SetWindowsHook32A (USER32.525) 576 */ 577 HHOOK WINAPI SetWindowsHookA( INT id, HOOKPROC proc ) 578 { 579 return SetWindowsHookExA( id, proc, 0, GetCurrentThreadId() ); 580 } 581 582 /*********************************************************************** 583 * SetWindowsHook32W (USER32.528) 584 */ 585 HHOOK WINAPI SetWindowsHookW( INT id, HOOKPROC proc ) 586 { 587 return SetWindowsHookExW( id, proc, 0, GetCurrentThreadId() ); 588 } 589 590 /*********************************************************************** 591 * SetWindowsHookEx32A (USER32.526) 592 */ 593 HHOOK WINAPI SetWindowsHookExA( INT id, HOOKPROC proc, HINSTANCE hInst, 594 DWORD dwThreadId ) 595 { 596 return HOOK_SetHook( id, proc, HOOK_WIN32A, hInst, dwThreadId ); 597 } 598 599 /*********************************************************************** 600 * SetWindowsHookEx32W (USER32.527) 601 */ 602 HHOOK WINAPI SetWindowsHookExW( INT id, HOOKPROC proc, HINSTANCE hInst, 603 DWORD dwThreadId ) 604 { 605 return HOOK_SetHook( id, proc, HOOK_WIN32W, hInst, dwThreadId ); 606 } 607 608 /*********************************************************************** 609 * UnhookWindowsHook32 (USER32.557) 610 */ 611 BOOL WINAPI UnhookWindowsHook( INT id, HOOKPROC proc ) 612 { 613 HANDLE hook = HOOK_GetHook( id, GetCurrentThreadId() ); 614 615 dprintf(("UnhookWindowsHook: %d %08lx\n", id, (DWORD)proc )); 616 617 while (hook) 618 { 619 HOOKDATA *data = (HOOKDATA *)hook; 620 if (data->proc == proc) break; 621 hook = HOOK_GetNextHook( hook ); 622 } 623 if (!hook) return FALSE; 624 return HOOK_RemoveHook( (HOOKDATA *)hook ); 625 } 626 627 628 /*********************************************************************** 629 * UnhookWindowHookEx32 (USER32.558) 630 */ 631 BOOL WINAPI UnhookWindowsHookEx( HHOOK hhook ) 632 { 633 if (CHECK_MAGIC(hhook) == FALSE) 634 return FALSE; 635 636 return HOOK_RemoveHook( (HOOKDATA *)hhook ); 637 } 638 639 /*********************************************************************** 640 * CallNextHookEx32 (USER32.17) 641 * 642 * There aren't ANSI and UNICODE versions of this. 643 */ 644 LRESULT WINAPI CallNextHookEx( HHOOK hhook, INT code, WPARAM wParam, 645 LPARAM lParam ) 646 { 647 HANDLE next; 648 INT fromtype; /* figure out Ansi/Unicode */ 649 HOOKDATA *oldhook; 650 651 if (CHECK_MAGIC(hhook) == FALSE) 652 return FALSE; 653 654 if (!(next = HOOK_GetNextHook( hhook ))) return 0; 655 656 oldhook = (HOOKDATA *)hhook ; 657 fromtype = oldhook->flags & HOOK_MAPTYPE; 658 659 return HOOK_CallHook( next, fromtype, code, wParam, lParam ); 660 } 661 662 663 /*********************************************************************** 664 * CallMsgFilter32A (USER32.15) 665 */ 666 /* 667 * FIXME: There are ANSI and UNICODE versions of this, plus an unspecified 668 * version, plus USER (the 16bit one) has a CallMsgFilter32 function. 669 */ 670 BOOL WINAPI CallMsgFilterA( LPMSG msg, INT code ) 671 { 672 if (GetSysModalWindow()) return FALSE; /* ??? */ 673 if (HOOK_CallHooksA( WH_SYSMSGFILTER, code, 0, (LPARAM)msg )) 674 return TRUE; 675 return HOOK_CallHooksA( WH_MSGFILTER, code, 0, (LPARAM)msg ); 676 } 677 678 679 /*********************************************************************** 680 * CallMsgFilter32W (USER32.16) 681 */ 682 BOOL WINAPI CallMsgFilterW( LPMSG msg, INT code ) 683 { 684 if (GetSysModalWindow()) return FALSE; /* ??? */ 685 if (HOOK_CallHooksW( WH_SYSMSGFILTER, code, 0, (LPARAM)msg )) 686 return TRUE; 687 return HOOK_CallHooksW( WH_MSGFILTER, code, 0, (LPARAM)msg ); 688 } 689 -
trunk/src/user32/Makefile
r2033 r2084 1 # $Id: Makefile,v 1.4 7 1999-12-09 00:53:36sandervl Exp $1 # $Id: Makefile,v 1.48 1999-12-16 00:11:45 sandervl Exp $ 2 2 3 3 # … … 31 31 OBJS = user32.obj loadres.obj \ 32 32 dde.obj win32wndhandle.obj wsprintf.obj winmouse.obj \ 33 icon.obj hook.obj hooks.objwinmenu.obj winkeyboard.obj \33 icon.obj hook.obj winmenu.obj winkeyboard.obj \ 34 34 defwndproc.obj syscolor.obj char.obj initterm.obj \ 35 35 uitools.obj unknown.obj spy.obj wndmsg.obj display.obj \ … … 96 96 syscolor.obj: syscolor.cpp syscolor.h 97 97 dde.obj: dde.cpp 98 hook.obj: hook.cpp hooks.h98 hook.obj: hook.cpp $(PDWIN32_INCLUDE)\win\hook.h 99 99 defwndproc.obj: defwndproc.cpp syscolor.h win32wmdiclient.h win32wbase.h win32wnd.h win32dlg.h 100 hooks.obj: hooks.cpp hooks.h101 100 initterm.obj: initterm.cpp $(PDWIN32_INCLUDE)\spy.h pmwindow.h initterm.h 102 101 uitools.obj: uitools.cpp win32wbase.h … … 130 129 pmframe.obj: pmframe.cpp win32class.h win32wbase.h pmframe.h win32wndchild.h 131 130 win32class.obj: win32class.cpp win32class.h win32wbase.h win32dlg.h gen_object.h $(PDWIN32_INCLUDE)\heapshared.h oslibwin.h win32wndchild.h $(PDWIN32_INCLUDE)\win\winproc.h 132 win32wbase.obj: win32wbase.cpp win32class.h win32wbase.h win32dlg.h gen_object.h $(PDWIN32_INCLUDE)\heapshared.h oslibwin.h win32wndchild.h $(PDWIN32_INCLUDE)\winres.h oslibres.h win32wndhandle.h oslibdos.h dc.h pmframe.h win32wdesktop.h controls.h winmouse.h $(PDWIN32_INCLUDE)\win\winproc.h 131 win32wbase.obj: win32wbase.cpp win32class.h win32wbase.h win32dlg.h gen_object.h $(PDWIN32_INCLUDE)\heapshared.h oslibwin.h win32wndchild.h $(PDWIN32_INCLUDE)\winres.h oslibres.h win32wndhandle.h oslibdos.h dc.h pmframe.h win32wdesktop.h controls.h winmouse.h $(PDWIN32_INCLUDE)\win\winproc.h $(PDWIN32_INCLUDE)\win\hook.h 133 132 win32wbasepos.obj: win32wbasepos.cpp win32class.h win32wbase.h win32dlg.h gen_object.h $(PDWIN32_INCLUDE)\heapshared.h oslibwin.h win32wndchild.h $(PDWIN32_INCLUDE)\winres.h oslibres.h win32wndhandle.h oslibdos.h dc.h pmframe.h win32wdesktop.h 134 133 win32wnd.obj: win32wnd.cpp win32class.h win32wbase.h win32wnd.h win32dlg.h gen_object.h $(PDWIN32_INCLUDE)\heapshared.h oslibwin.h win32wndchild.h $(PDWIN32_INCLUDE)\winres.h oslibres.h win32wndhandle.h oslibdos.h oslibmenu.h -
trunk/src/user32/pmwindow.cpp
r2076 r2084 1 /* $Id: pmwindow.cpp,v 1.6 4 1999-12-14 19:13:19sandervl Exp $ */1 /* $Id: pmwindow.cpp,v 1.65 1999-12-16 00:11:45 sandervl Exp $ */ 2 2 /* 3 3 * Win32 Window Managment Code for OS/2 … … 214 214 if(msg == WIN32APP_POSTMSG && (ULONG)mp1 == WIN32PM_MAGIC) { 215 215 //win32 app user message 216 win32wnd->PostMessage((POSTMSG_PACKET *)mp2); 217 return (MRESULT)0; 216 return (MRESULT)win32wnd->PostMessage((POSTMSG_PACKET *)mp2);; 218 217 } 219 218 switch( msg ) … … 417 416 break; 418 417 } 419 418 case WM_MINMAXFRAME: 419 { 420 dprintf(("OS2: WM_MINMAXFRAME")); 421 break; 422 } 420 423 case WM_OWNERPOSCHANGE: 421 424 { -
trunk/src/user32/user32.cpp
r1963 r2084 1 /* $Id: user32.cpp,v 1.5 8 1999-12-03 20:40:09 phallerExp $ */1 /* $Id: user32.cpp,v 1.59 1999-12-16 00:11:45 sandervl Exp $ */ 2 2 3 3 /* … … 2676 2676 /* Hook Functions */ 2677 2677 2678 /*****************************************************************************2679 * Name : BOOL WIN32API SetWindowsHookW2680 * Purpose : The SetWindowsHook function is not implemented in the Win32 API.2681 * Win32-based applications should use the SetWindowsHookEx function.2682 * Parameters:2683 * Variables :2684 * Result :2685 * Remark : ARGH ! MICROSOFT !2686 * Status : UNTESTED STUB2687 *2688 * Author : Patrick Haller [Thu, 1998/02/26 11:55]2689 *****************************************************************************/2690 HHOOK WIN32API SetWindowsHookW(int nFilterType, HOOKPROC pfnFilterProc)2691 2692 {2693 return (FALSE);2694 }2695 2696 /* CB: move to ShowWindow() */2697 2698 /*****************************************************************************2699 * Name : BOOL WIN32API ShowWindowAsync2700 * Purpose : The ShowWindowAsync function sets the show state of a window2701 * created by a different thread.2702 * Parameters: HWND hwnd handle of window2703 * int nCmdShow show state of window2704 * Variables :2705 * Result : If the window was previously visible, the return value is TRUE.2706 * If the window was previously hidden, the return value is FALSE.2707 * Remark :2708 * Status : UNTESTED STUB2709 *2710 * Author : Patrick Haller [Thu, 1998/02/26 11:55]2711 *****************************************************************************/2712 BOOL WIN32API ShowWindowAsync (HWND hWnd,2713 int nCmdShow)2714 {2715 dprintf(("USER32:ShowWindowAsync (%08xh,%08x) not implemented.\n",2716 hWnd,2717 nCmdShow));2718 2719 return (FALSE);2720 }2721 2722 2678 /* CB: move to MDI */ 2723 2679 -
trunk/src/user32/win32dlg.cpp
r2033 r2084 1 /* $Id: win32dlg.cpp,v 1.3 6 1999-12-09 00:53:37sandervl Exp $ */1 /* $Id: win32dlg.cpp,v 1.37 1999-12-16 00:11:46 sandervl Exp $ */ 2 2 /* 3 3 * Win32 Dialog Code for OS/2 … … 217 217 218 218 if (hUserFont) 219 Send MessageA(WM_SETFONT, (WPARAM)hUserFont, 0 );219 SendInternalMessageA(WM_SETFONT, (WPARAM)hUserFont, 0 ); 220 220 221 221 /* Create controls */ … … 226 226 hwndFocus = GetNextDlgTabItem( getWindowHandle(), 0, FALSE ); 227 227 228 if (Send MessageA(WM_INITDIALOG, (WPARAM)hwndFocus, param))228 if (SendInternalMessageA(WM_INITDIALOG, (WPARAM)hwndFocus, param)) 229 229 SetFocus(hwndFocus); 230 230 … … 262 262 /* Owner must be a top-level window */ 263 263 if(getOwner() == NULL) { 264 topOwner = windowDesktop;264 topOwner = windowDesktop; 265 265 } 266 266 else topOwner = getOwner()->GetTopParent(); … … 295 295 if (!OSLibWinPeekMsg(&msg,0,0,0,MSG_NOREMOVE)) 296 296 { 297 if(!(getStyle() & DS_NOIDLEMSG)) 298 topOwner->SendMessageA(WM_ENTERIDLE,MSGF_DIALOGBOX,getWindowHandle()); 299 OSLibWinGetMsg(&msg,0,0,0); 300 } else OSLibWinPeekMsg(&msg,0,0,0,MSG_REMOVE); 297 if(!(getStyle() & DS_NOIDLEMSG)) 298 topOwner->SendMessageA(WM_ENTERIDLE,MSGF_DIALOGBOX,getWindowHandle()); 299 OSLibWinGetMsg(&msg,0,0,0); 300 } 301 else OSLibWinPeekMsg(&msg,0,0,0,MSG_REMOVE); 301 302 302 303 if(msg.message == WM_QUIT) 303 304 { 304 dprintf(("Win32Dialog::doDialogBox: received WM_QUIT"));305 break;305 dprintf(("Win32Dialog::doDialogBox: received WM_QUIT")); 306 break; 306 307 } 307 308 if (!IsDialogMessageA( getWindowHandle(), &msg)) 308 309 { 309 TranslateMessage( &msg );310 DispatchMessageA( &msg );310 TranslateMessage( &msg ); 311 DispatchMessageA( &msg ); 311 312 } 312 if (dialogFlags & DF_END) break; 313 if (dialogFlags & DF_END) 314 break; 313 315 } 314 316 #else … … 332 334 else { 333 335 if(!(getStyle() & DS_NOIDLEMSG)) { 334 topOwner->Send MessageA(WM_ENTERIDLE, MSGF_DIALOGBOX, getWindowHandle());336 topOwner->SendInternalMessageA(WM_ENTERIDLE, MSGF_DIALOGBOX, getWindowHandle()); 335 337 } 336 338 } … … 1030 1032 { 1031 1033 case DWL_DLGPROC: 1032 1034 oldval = (LONG)WINPROC_GetProc(Win32DlgProc, (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A); 1033 1035 WINPROC_SetProc((HWINDOWPROC *)&Win32DlgProc, (WNDPROC)value, (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A, WIN_PROC_WINDOW); 1034 1036 return oldval; … … 1053 1055 { 1054 1056 case DWL_DLGPROC: 1055 1057 return (ULONG)WINPROC_GetProc(Win32DlgProc, (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A); 1056 1058 case DWL_MSGRESULT: 1057 1059 return msgResult; -
trunk/src/user32/win32wbase.cpp
r2076 r2084 1 /* $Id: win32wbase.cpp,v 1.11 0 1999-12-14 19:13:19sandervl Exp $ */1 /* $Id: win32wbase.cpp,v 1.111 1999-12-16 00:11:46 sandervl Exp $ */ 2 2 /* 3 3 * Win32 Window Base Class for OS/2 … … 11 11 * 12 12 * TODO: Not thread/process safe 13 * TODO: Calling window handler directly from SendMessageA/W can cause problems14 * for GetMessageTime/Pos & InSendMessage15 13 * 16 14 * Project Odin Software License can be found in LICENSE.TXT … … 28 26 #include <winres.h> 29 27 #include "wndmsg.h" 30 #include "hooks.h"31 28 #include "oslibwin.h" 32 29 #include "oslibutil.h" … … 44 41 #include <wprocess.h> 45 42 #include "winmouse.h" 43 #include <win\hook.h> 46 44 47 45 #define HAS_DLGFRAME(style,exStyle) \ … … 81 79 82 80 static fDestroyAll = FALSE; 81 //For quick lookup of current process id 82 static ULONG currentProcessId = -1; 83 83 84 84 //****************************************************************************** … … 145 145 fNoSizeMsg = FALSE; 146 146 fIsDestroyed = FALSE; 147 fDestroyWindowCalled = FALSE; 147 148 fCreated = FALSE; 148 149 fTaskList = FALSE; … … 203 204 204 205 ownDC = 0; 206 207 if(currentProcessId == -1) 208 { 209 currentProcessId = GetCurrentProcessId(); 210 } 211 dwThreadId = GetCurrentThreadId(); 212 dwProcessId = currentProcessId; 205 213 } 206 214 //****************************************************************************** … … 461 469 windowClass->IncreaseWindowCount(); 462 470 471 if (HOOK_IsHooked( WH_CBT )) 472 { 473 CBT_CREATEWNDA cbtc; 474 LRESULT ret; 475 476 cbtc.lpcs = cs; 477 cbtc.hwndInsertAfter = hwndLinkAfter; 478 ret = HOOK_CallHooksA(WH_CBT, HCBT_CREATEWND, getWindowHandle(), (LPARAM)&cbtc); 479 if(ret) 480 { 481 dprintf(("CBT-hook returned 0!!")); 482 SetLastError(ERROR_CAN_NOT_COMPLETE); //todo: wrong error 483 return FALSE; 484 } 485 } 486 463 487 /* Correct the window style */ 464 488 if (!(cs->style & WS_CHILD)) … … 510 534 } 511 535 512 if(((cs->style & 0xC0000000) == WS_OVERLAPPED) && ((cs->style & WS_CAPTION) == WS_CAPTION) && owner == NULL) 536 if(((dwStyle & 0xC0000000) == WS_OVERLAPPED) && ((dwStyle & WS_CAPTION) == WS_CAPTION) && owner == NULL 537 && dwStyle & WS_SYSMENU) 513 538 { 514 539 fTaskList = TRUE; 515 540 } 516 541 … … 697 722 fNoSizeMsg = FALSE; 698 723 699 if(Send MessageA(WM_NCCREATE, 0, (LPARAM)cs) )724 if(SendInternalMessageA(WM_NCCREATE, 0, (LPARAM)cs) ) 700 725 { 701 726 fCreated = TRUE; … … 704 729 705 730 // OffsetRect(&rectWindow, maxPos.x - rectWindow.left, maxPos.y - rectWindow.top); 706 if( (Send MessageA(WM_CREATE, 0, (LPARAM)cs )) != -1 )731 if( (SendInternalMessageA(WM_CREATE, 0, (LPARAM)cs )) != -1 ) 707 732 { 708 733 if(!(flags & WIN_NEED_SIZE)) { 709 Send MessageA(WM_SIZE, SIZE_RESTORED,734 SendInternalMessageA(WM_SIZE, SIZE_RESTORED, 710 735 MAKELONG(rectClient.right-rectClient.left, 711 736 rectClient.bottom-rectClient.top)); 712 Send MessageA(WM_MOVE, 0, MAKELONG( rectClient.left, rectClient.top ) );737 SendInternalMessageA(WM_MOVE, 0, MAKELONG( rectClient.left, rectClient.top ) ); 713 738 } 714 739 740 if( getStyle() & WS_CHILD && !(getExStyle() & WS_EX_NOPARENTNOTIFY) ) 741 { 742 /* Notify the parent window only */ 743 SendInternalMessageA(WM_PARENTNOTIFY, MAKEWPARAM(WM_CREATE, getWindowId()), (LPARAM)getWindowHandle()); 744 if(!::IsWindow(getWindowHandle())) 745 { 746 dprintf(("Createwindow: WM_PARENTNOTIFY destroyed window")); 747 goto end; 748 } 749 } 750 715 751 if (cs->style & WS_VISIBLE) ShowWindow( sw ); 716 752 717 #if 0718 753 /* Call WH_SHELL hook */ 719 720 if (!(dwStyle & WS_CHILD) && !owner) 721 HOOK_CallHooks16( WH_SHELL, HSHELL_WINDOWCREATED, hwnd, 0 ); 722 #endif 754 if (!(getStyle() & WS_CHILD) && !owner) 755 HOOK_CallHooksA(WH_SHELL, HSHELL_WINDOWCREATED, getWindowHandle(), 0 ); 756 723 757 SetLastError(0); 724 758 return TRUE; … … 727 761 dprintf(("Window creation FAILED (NCCREATE cancelled creation)")); 728 762 SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error 763 end: 729 764 return FALSE; 730 765 } … … 755 790 756 791 fIsDestroyed = TRUE; 757 //According to the SDK, WM_PARENTNOTIFY messages are sent to the parent (this window) 758 //before any window destruction has begun 759 child = (Win32BaseWindow *)getFirstChild(); 760 while(child) { 761 child->NotifyParent(WM_DESTROY, 0, 0); 762 763 child = (Win32BaseWindow *)child->getNextChild(); 792 793 if(fDestroyWindowCalled == FALSE) 794 {//this window was destroyed because DestroyWindow was called for it's parent 795 //so: send a WM_PARENTNOTIFY now as that hasn't happened yet 796 if((getStyle() & WS_CHILD) && !(getExStyle() & WS_EX_NOPARENTNOTIFY)) 797 { 798 if(getParent()) 799 { 800 /* Notify the parent window only */ 801 getParent()->SendMessageA(WM_PARENTNOTIFY, MAKEWPARAM(WM_DESTROY, getWindowId()), (LPARAM)getWindowHandle()); 802 } 803 else DebugInt3(); 804 } 764 805 } 765 806 SendInternalMessageA(WM_DESTROY, 0, 0); 807 SendInternalMessageA(WM_NCDESTROY, 0, 0); 766 808 767 809 if (hwndHorzScroll && OSLibWinQueryWindow(hwndHorzScroll,QWOS_PARENT) == OSLibWinQueryObjectWindow()) OSLibWinDestroyWindow(hwndHorzScroll); … … 828 870 return SendInternalMessageA(WM_MOVE, 0, MAKELONG((USHORT)x, (USHORT)y)); 829 871 } 872 //****************************************************************************** 873 //****************************************************************************** 874 #if 0 875 ULONG Win32BaseWindow::MsgMinMax() 876 { 877 878 } 879 #endif 830 880 //****************************************************************************** 831 881 //****************************************************************************** … … 901 951 { 902 952 ULONG rc, curprocid, procidhwnd = -1, threadidhwnd = 0; 953 903 954 904 955 //According to SDK docs, if app returns FALSE & window is being deactivated, … … 1151 1202 1152 1203 /* Activate the window if needed */ 1153 if(isSubclassedOS2Wnd()) {1154 Win32BaseWindow *parentwnd = GetWindowFromOS2FrameHandle(OSLibWinQueryWindow(OS2Hwnd, QWOS_PARENT));1155 if(parentwnd) {1156 hwndTop = (parentwnd->GetTopParent()) ? parentwnd->GetTopParent()->getWindowHandle() : 0;1157 }1158 else hwndTop = 0;1159 }1160 else hwndTop = (GetTopParent()) ? GetTopParent()->getWindowHandle() : 0;1204 if(isSubclassedOS2Wnd()) { 1205 Win32BaseWindow *parentwnd = GetWindowFromOS2FrameHandle(OSLibWinQueryWindow(OS2Hwnd, QWOS_PARENT)); 1206 if(parentwnd) { 1207 hwndTop = (parentwnd->GetTopParent()) ? parentwnd->GetTopParent()->getWindowHandle() : 0; 1208 } 1209 else hwndTop = 0; 1210 } 1211 else hwndTop = (GetTopParent()) ? GetTopParent()->getWindowHandle() : 0; 1161 1212 1162 1213 if (hwndTop && getWindowHandle() != GetActiveWindow()) 1163 1214 { 1164 LONG ret = Send MessageA(WM_MOUSEACTIVATE, hwndTop,1165 MAKELONG( HTCLIENT, win32msg ) );1215 LONG ret = SendInternalMessageA(WM_MOUSEACTIVATE, hwndTop, 1216 MAKELONG( HTCLIENT, win32msg ) ); 1166 1217 1167 1218 #if 0 … … 1447 1498 1448 1499 case SC_CLOSE: 1449 return Send MessageA(WM_CLOSE, 0, 0);1500 return SendInternalMessageA(WM_CLOSE, 0, 0); 1450 1501 1451 1502 #if 0 … … 1627 1678 { 1628 1679 if(getParent()) { 1629 LRESULT rc = getParent()->Send MessageA(WM_MOUSEACTIVATE, wParam, lParam );1680 LRESULT rc = getParent()->SendInternalMessageA(WM_MOUSEACTIVATE, wParam, lParam ); 1630 1681 if(rc) return rc; 1631 1682 } … … 1639 1690 { 1640 1691 if(getParent()) { 1641 LRESULT rc = getParent()->Send MessageA(WM_SETCURSOR, wParam, lParam);1692 LRESULT rc = getParent()->SendInternalMessageA(WM_SETCURSOR, wParam, lParam); 1642 1693 if(rc) return rc; 1643 1694 } … … 1665 1716 1666 1717 if (!(wpos->flags & SWP_NOMOVE) && !(wpos->flags & SWP_NOCLIENTMOVE)) 1667 Send MessageA(WM_MOVE, 0, MAKELONG(rectClient.left, rectClient.top));1718 SendInternalMessageA(WM_MOVE, 0, MAKELONG(rectClient.left, rectClient.top)); 1668 1719 1669 1720 if (!(wpos->flags & SWP_NOSIZE) && !(wpos->flags & SWP_NOCLIENTSIZE)) … … 1672 1723 else if (dwStyle & WS_MINIMIZE) wp = SIZE_MINIMIZED; 1673 1724 1674 Send MessageA(WM_SIZE, wp, MAKELONG(rectClient.right - rectClient.left,1725 SendInternalMessageA(WM_SIZE, wp, MAKELONG(rectClient.right - rectClient.left, 1675 1726 rectClient.bottom - rectClient.top)); 1676 1727 } … … 1779 1830 // key matches siblings mnemonic, send mouseclick 1780 1831 if (mnemonic == (char) wParam) { 1781 siblingWindow->Send MessageA (BM_CLICK, 0, 0);1832 siblingWindow->SendInternalMessageA (BM_CLICK, 0, 0); 1782 1833 } 1783 1834 … … 1873 1924 LRESULT Win32BaseWindow::SendMessageA(ULONG Msg, WPARAM wParam, LPARAM lParam) 1874 1925 { 1926 POSTMSG_PACKET *packet; 1927 1928 //if the destination window is created by this process & thread, call window proc directly 1929 if(dwProcessId == currentProcessId && dwThreadId == GetCurrentThreadId()) { 1930 return SendInternalMessageA(Msg, wParam, lParam); 1931 } 1932 //otherwise use WinSendMsg to send it to the right process/thread 1933 packet = (POSTMSG_PACKET *)_smalloc(sizeof(POSTMSG_PACKET)); 1934 packet->Msg = Msg; 1935 packet->wParam = wParam; 1936 packet->lParam = lParam; 1937 packet->fUnicode = FALSE; 1938 return OSLibSendMessage(getOS2WindowHandle(), WIN32APP_POSTMSG, WIN32PM_MAGIC, (DWORD)packet); 1939 } 1940 //****************************************************************************** 1941 //****************************************************************************** 1942 LRESULT Win32BaseWindow::SendMessageW(ULONG Msg, WPARAM wParam, LPARAM lParam) 1943 { 1944 POSTMSG_PACKET *packet; 1945 1946 //if the destination window is created by this process & thread, call window proc directly 1947 if(dwProcessId == currentProcessId && dwThreadId == GetCurrentThreadId()) { 1948 return SendInternalMessageA(Msg, wParam, lParam); 1949 } 1950 //otherwise use WinSendMsg to send it to the right process/thread 1951 packet = (POSTMSG_PACKET *)_smalloc(sizeof(POSTMSG_PACKET)); 1952 packet->Msg = Msg; 1953 packet->wParam = wParam; 1954 packet->lParam = lParam; 1955 packet->fUnicode = TRUE; 1956 return OSLibSendMessage(getOS2WindowHandle(), WIN32APP_POSTMSG, WIN32PM_MAGIC, (DWORD)packet); 1957 } 1958 //****************************************************************************** 1959 //Called as a result of an OS/2 message or called from a class method 1960 //****************************************************************************** 1961 LRESULT Win32BaseWindow::SendInternalMessageA(ULONG Msg, WPARAM wParam, LPARAM lParam) 1962 { 1875 1963 LRESULT rc; 1876 1964 BOOL fInternalMsgBackup = fInternalMsg; 1877 1965 1878 //SvL: Some Wine controls send WM_COMMAND messages when they receive the focus -> apps don't like to 1879 // receive those before they get their WM_CREATE message 1880 //NOTE: May need to refuse more messages 1881 if(fCreated == FALSE && Msg == WM_COMMAND) { 1882 dprintf(("SendMessageA BEFORE creation! %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam)); 1883 return 0; 1884 } 1885 1886 DebugPrintMessage(getWindowHandle(), Msg, wParam, lParam, FALSE, FALSE); 1887 1888 if(HkCBT::OS2HkCBTProc(getWindowHandle(), Msg, wParam, lParam) == TRUE) {//hook swallowed msg 1889 return(0); 1890 } 1891 fInternalMsg = FALSE; 1966 DebugPrintMessage(getWindowHandle(), Msg, wParam, lParam, FALSE, TRUE); 1967 1968 CallWindowHookProc(WH_CALLWNDPROC, Msg, wParam, lParam, FALSE); 1969 1970 fInternalMsg = TRUE; 1892 1971 switch(Msg) 1893 1972 { … … 1899 1978 break; 1900 1979 } 1901 NotifyParent(Msg, wParam, lParam);1902 1903 1980 rc = 0; 1904 1981 break; 1905 1982 } 1906 case WM_SETTEXT:1907 rc = CallWindowProcA(win32wndproc, getWindowHandle(), WM_SETTEXT, wParam, lParam);1908 break;1909 1910 1983 case WM_LBUTTONDOWN: 1911 1984 case WM_MBUTTONDOWN: … … 1916 1989 1917 1990 case WM_DESTROY: 1918 win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);1919 1991 rc = win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0); 1920 1992 break; … … 1928 2000 } 1929 2001 //****************************************************************************** 1930 //****************************************************************************** 1931 LRESULT Win32BaseWindow::SendMessageW(ULONG Msg, WPARAM wParam, LPARAM lParam) 2002 //Called as a result of an OS/2 message or called from a class method 2003 //****************************************************************************** 2004 LRESULT Win32BaseWindow::SendInternalMessageW(ULONG Msg, WPARAM wParam, LPARAM lParam) 1932 2005 { 1933 2006 LRESULT rc; 1934 2007 BOOL fInternalMsgBackup = fInternalMsg; 1935 2008 1936 //SvL: Some Wine controls send WM_COMMAND messages when they receive the focus -> apps don't like to 1937 // receive those before they get their WM_CREATE message 1938 //NOTE: May need to refuse more messages 1939 if(fCreated == FALSE && Msg == WM_COMMAND) { 1940 dprintf(("SendMessageA BEFORE creation! %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam)); 1941 return 0; 1942 } 1943 1944 DebugPrintMessage(getWindowHandle(), Msg, wParam, lParam, TRUE, FALSE); 1945 1946 if(HkCBT::OS2HkCBTProc(getWindowHandle(), Msg, wParam, lParam) == TRUE) {//hook swallowed msg 1947 return(0); 1948 } 1949 fInternalMsg = FALSE; 2009 DebugPrintMessage(getWindowHandle(), Msg, wParam, lParam, TRUE, TRUE); 2010 2011 CallWindowHookProc(WH_CALLWNDPROC, Msg, wParam, lParam, TRUE); 2012 2013 fInternalMsg = TRUE; 1950 2014 switch(Msg) 1951 2015 { … … 1957 2021 break; 1958 2022 } 1959 NotifyParent(Msg, wParam, lParam);1960 1961 2023 rc = 0; 1962 2024 break; 1963 2025 } 1964 case WM_SETTEXT:1965 rc = CallWindowProcW(win32wndproc, getWindowHandle(), WM_SETTEXT, wParam, lParam);1966 break;1967 1968 2026 case WM_LBUTTONDOWN: 1969 2027 case WM_MBUTTONDOWN: … … 1974 2032 1975 2033 case WM_DESTROY: 1976 win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);1977 rc = win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);1978 break;1979 1980 default:1981 rc = CallWindowProcW(win32wndproc, getWindowHandle(), Msg, wParam, lParam);1982 break;1983 }1984 fInternalMsg = fInternalMsgBackup;1985 return rc;1986 }1987 //******************************************************************************1988 //Called as a result of an OS/2 message1989 //******************************************************************************1990 LRESULT Win32BaseWindow::SendInternalMessageA(ULONG Msg, WPARAM wParam, LPARAM lParam)1991 {1992 LRESULT rc;1993 BOOL fInternalMsgBackup = fInternalMsg;1994 1995 DebugPrintMessage(getWindowHandle(), Msg, wParam, lParam, FALSE, TRUE);1996 1997 if(HkCBT::OS2HkCBTProc(getWindowHandle(), Msg, wParam, lParam) == TRUE) {//hook swallowed msg1998 return(0);1999 }2000 fInternalMsg = TRUE;2001 switch(Msg)2002 {2003 case WM_CREATE:2004 {2005 if(CallWindowProcA(win32wndproc, getWindowHandle(), WM_CREATE, 0, lParam) == -1) {2006 dprintf(("WM_CREATE returned -1\n"));2007 rc = -1; //don't create window2008 break;2009 }2010 NotifyParent(Msg, wParam, lParam);2011 rc = 0;2012 break;2013 }2014 case WM_LBUTTONDOWN:2015 case WM_MBUTTONDOWN:2016 case WM_RBUTTONDOWN:2017 NotifyParent(Msg, wParam, lParam);2018 rc = win32wndproc(getWindowHandle(), Msg, wParam, lParam);2019 break;2020 2021 case WM_DESTROY:2022 win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);2023 rc = win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);2024 break;2025 2026 default:2027 rc = CallWindowProcA(win32wndproc, getWindowHandle(), Msg, wParam, lParam);2028 break;2029 }2030 fInternalMsg = fInternalMsgBackup;2031 return rc;2032 }2033 //******************************************************************************2034 //Called as a result of an OS/2 message2035 //todo, unicode msgs (WM_SETTEXT etc)2036 //******************************************************************************2037 LRESULT Win32BaseWindow::SendInternalMessageW(ULONG Msg, WPARAM wParam, LPARAM lParam)2038 {2039 LRESULT rc;2040 BOOL fInternalMsgBackup = fInternalMsg;2041 2042 DebugPrintMessage(getWindowHandle(), Msg, wParam, lParam, TRUE, TRUE);2043 2044 if(HkCBT::OS2HkCBTProc(getWindowHandle(), Msg, wParam, lParam) == TRUE) {//hook swallowed msg2045 return(0);2046 }2047 fInternalMsg = TRUE;2048 switch(Msg)2049 {2050 case WM_CREATE:2051 {2052 if(CallWindowProcW(win32wndproc, getWindowHandle(), WM_CREATE, 0, lParam) == -1) {2053 dprintf(("WM_CREATE returned -1\n"));2054 rc = -1; //don't create window2055 break;2056 }2057 NotifyParent(Msg, wParam, lParam);2058 rc = 0;2059 break;2060 }2061 case WM_LBUTTONDOWN:2062 case WM_MBUTTONDOWN:2063 case WM_RBUTTONDOWN:2064 NotifyParent(Msg, wParam, lParam);2065 rc = win32wndproc(getWindowHandle(), Msg, wParam, lParam);2066 break;2067 2068 case WM_DESTROY:2069 win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);2070 2034 rc = win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0); 2071 2035 break; … … 2079 2043 //****************************************************************************** 2080 2044 //****************************************************************************** 2045 void Win32BaseWindow::CallWindowHookProc(ULONG hooktype, ULONG Msg, WPARAM wParam, LPARAM lParam, BOOL fUnicode) 2046 { 2047 CWPSTRUCT cwp; 2048 2049 cwp.lParam = lParam; 2050 cwp.wParam = wParam; 2051 cwp.message = Msg; 2052 cwp.hwnd = getWindowHandle(); 2053 2054 switch(hooktype) { 2055 case WH_CALLWNDPROC: 2056 if(fUnicode) { 2057 HOOK_CallHooksW(WH_CALLWNDPROC, HC_ACTION, 1, (LPARAM)&cwp); 2058 } 2059 else HOOK_CallHooksA(WH_CALLWNDPROC, HC_ACTION, 1, (LPARAM)&cwp); 2060 break; 2061 } 2062 } 2063 //****************************************************************************** 2064 //****************************************************************************** 2081 2065 BOOL Win32BaseWindow::PostMessageA(ULONG msg, WPARAM wParam, LPARAM lParam) 2082 2066 { … … 2127 2111 //****************************************************************************** 2128 2112 //****************************************************************************** 2129 void Win32BaseWindow::PostMessage(POSTMSG_PACKET *packet) 2130 { 2113 ULONG Win32BaseWindow::PostMessage(POSTMSG_PACKET *packet) 2114 { 2115 ULONG rc; 2116 2131 2117 if(packet == NULL) 2132 return ;2118 return 0; 2133 2119 2134 2120 if(packet->fUnicode) { 2135 SendMessageW(packet->Msg, packet->wParam, packet->lParam);2136 } 2137 else SendMessageA(packet->Msg, packet->wParam, packet->lParam);2121 rc = SendInternalMessageW(packet->Msg, packet->wParam, packet->lParam); 2122 } 2123 else rc = SendInternalMessageA(packet->Msg, packet->wParam, packet->lParam); 2138 2124 2139 2125 free(packet); 2140 } 2141 //****************************************************************************** 2142 //Send message to window of another process 2143 //****************************************************************************** 2144 LRESULT Win32BaseWindow::SendMessageToProcess(UINT msg, WPARAM wParam, LPARAM lParam, BOOL fUnicode) 2145 { 2146 POSTMSG_PACKET *packet = (POSTMSG_PACKET *)_smalloc(sizeof(POSTMSG_PACKET)); 2147 2148 dprintf(("SendMessageToProcess %x %x %x %x", getOS2WindowHandle(), msg, wParam, lParam)); 2149 packet->Msg = msg; 2150 packet->wParam = wParam; 2151 packet->lParam = lParam; 2152 packet->fUnicode = fUnicode; 2153 return OSLibSendMessage(getOS2WindowHandle(), WIN32APP_POSTMSG, WIN32PM_MAGIC, (DWORD)packet); 2126 return rc; 2154 2127 } 2155 2128 //****************************************************************************** … … 2160 2133 Win32BaseWindow *window; 2161 2134 HWND hwnd = WNDHANDLE_MAGIC_HIGHWORD; 2162 DWORD processid, myprocessid;2163 2135 2164 2136 dprintf(("BroadCastMessageA %x %x %x", msg, wParam, lParam, GetFS())); 2165 myprocessid = GetCurrentProcessId();2166 2137 2167 2138 for(int i=0;i<MAX_WINDOW_HANDLES;i++) { … … 2172 2143 2173 2144 if(type == BROADCAST_SEND) { 2174 GetWindowThreadProcessId(hwnd, &processid); 2175 if(processid == myprocessid) { 2176 window->SendMessageA(msg, wParam, lParam); 2177 } 2178 else { 2179 window->SendMessageToProcess(msg, wParam, lParam, FALSE); 2180 } 2145 window->SendInternalMessageA(msg, wParam, lParam); 2181 2146 } 2182 2147 else window->PostMessageA(msg, wParam, lParam); … … 2193 2158 Win32BaseWindow *window; 2194 2159 HWND hwnd = WNDHANDLE_MAGIC_HIGHWORD; 2195 DWORD processid, myprocessid;2196 2160 2197 2161 2198 2162 dprintf(("BroadCastMessageW %x %x %x", msg, wParam, lParam)); 2199 myprocessid = GetCurrentProcessId();2200 2163 2201 2164 for(int i=0;i<MAX_WINDOW_HANDLES;i++) { … … 2206 2169 2207 2170 if(type == BROADCAST_SEND) { 2208 GetWindowThreadProcessId(hwnd, &processid); 2209 if(processid == myprocessid) { 2210 window->SendMessageW(msg, wParam, lParam); 2211 } 2212 else { 2213 window->SendMessageToProcess(msg, wParam, lParam, TRUE); 2214 } 2171 window->SendInternalMessageW(msg, wParam, lParam); 2215 2172 } 2216 2173 else window->PostMessageW(msg, wParam, lParam); … … 2221 2178 } 2222 2179 //****************************************************************************** 2223 //TODO: do we need to inform the parent of the parent (etc) of the child window?2224 2180 //****************************************************************************** 2225 2181 void Win32BaseWindow::NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam) … … 2235 2191 parentwindow = window->getParent(); 2236 2192 if(parentwindow) { 2237 if(Msg == WM_CREATE || Msg == WM_DESTROY) { 2238 parentwindow->SendMessageA(WM_PARENTNOTIFY, MAKEWPARAM(Msg, getWindowId()), (LPARAM)getWindowHandle()); 2239 } 2240 else parentwindow->SendMessageA(WM_PARENTNOTIFY, MAKEWPARAM(Msg, getWindowId()), lParam ); 2193 parentwindow->SendInternalMessageA(WM_PARENTNOTIFY, MAKEWPARAM(Msg, getWindowId()), lParam ); 2241 2194 } 2242 2195 } … … 2283 2236 if(OSLibWinSetIcon(OS2HwndFrame, hIcon) == TRUE) { 2284 2237 //TODO: Wine does't send these. Correct? 2285 // Send MessageA(WM_SETICON, ICON_BIG, hIcon);2238 // SendInternalMessageA(WM_SETICON, ICON_BIG, hIcon); 2286 2239 return TRUE; 2287 2240 } … … 2309 2262 wParam = SIZE_MINIMIZED; 2310 2263 2311 Send MessageA(WM_SIZE, wParam,2264 SendInternalMessageA(WM_SIZE, wParam, 2312 2265 MAKELONG(rectClient.right-rectClient.left, 2313 2266 rectClient.bottom-rectClient.top)); 2314 Send MessageA(WM_MOVE, 0, MAKELONG( rectClient.left, rectClient.top ) );2267 SendInternalMessageA(WM_MOVE, 0, MAKELONG( rectClient.left, rectClient.top ) ); 2315 2268 } 2316 2269 #else 2317 2270 if(fFirstShow) { 2318 2271 if(isFrameWindow() && IS_OVERLAPPED(getStyle()) && !isChild()) { 2319 Send MessageA(WM_SIZE, SIZE_RESTORED,2272 SendInternalMessageA(WM_SIZE, SIZE_RESTORED, 2320 2273 MAKELONG(rectClient.right-rectClient.left, 2321 2274 rectClient.bottom-rectClient.top)); 2322 Send MessageA(WM_MOVE, 0, MAKELONG( rectClient.left, rectClient.top ) );2275 SendInternalMessageA(WM_MOVE, 0, MAKELONG( rectClient.left, rectClient.top ) ); 2323 2276 2324 2277 } … … 2491 2444 } 2492 2445 //****************************************************************************** 2493 //Also destroys all the child windows (destroy parent, destroy children)2446 //Also destroys all the child windows (destroy children first, parent last) 2494 2447 //****************************************************************************** 2495 2448 BOOL Win32BaseWindow::DestroyWindow() 2496 2449 { 2450 /* Call hooks */ 2451 if(HOOK_CallHooksA( WH_CBT, HCBT_DESTROYWND, getWindowHandle(), 0L)) 2452 { 2453 return FALSE; 2454 } 2455 2456 if(!(getStyle() & WS_CHILD) && getOwner() == NULL) 2457 { 2458 HOOK_CallHooksA(WH_SHELL, HSHELL_WINDOWDESTROYED, getWindowHandle(), 0L); 2459 /* FIXME: clean up palette - see "Internals" p.352 */ 2460 } 2461 2462 if((getStyle() & WS_CHILD) && !(getExStyle() & WS_EX_NOPARENTNOTIFY)) 2463 { 2464 if(getParent()) 2465 { 2466 /* Notify the parent window only */ 2467 getParent()->SendMessageA(WM_PARENTNOTIFY, MAKEWPARAM(WM_DESTROY, getWindowId()), (LPARAM)getWindowHandle()); 2468 if( !::IsWindow(getWindowHandle()) ) 2469 { 2470 return TRUE; 2471 } 2472 } 2473 else DebugInt3(); 2474 } 2475 fDestroyWindowCalled = TRUE; 2497 2476 return OSLibWinDestroyWindow(OS2HwndFrame); 2498 2477 } … … 2590 2569 if (isIcon) 2591 2570 { 2592 SendMessageA(WM_ICONERASEBKGND, (WPARAM)hdc, 0); 2593 SendMessageA(WM_PAINTICON, 0, 0); 2594 } else 2595 { 2596 SendMessageA(WM_ERASEBKGND, (WPARAM)hdc, 0); 2597 SendMessageA(WM_PAINT, 0, 0); 2571 SendInternalMessageA(WM_ICONERASEBKGND, (WPARAM)hdc, 0); 2572 SendInternalMessageA(WM_PAINTICON, 0, 0); 2573 } 2574 else 2575 { 2576 SendInternalMessageA(WM_ERASEBKGND, (WPARAM)hdc, 0); 2577 SendInternalMessageA(WM_PAINT, 0, 0); 2598 2578 } 2599 2579 O32_ReleaseDC(OS2Hwnd, hdc); … … 2999 2979 ss.styleNew = value; 3000 2980 dprintf(("SetWindowLong GWL_EXSTYLE %x old %x new style %x", getWindowHandle(), dwExStyle, value)); 3001 Send MessageA(WM_STYLECHANGING,GWL_EXSTYLE,(LPARAM)&ss);2981 SendInternalMessageA(WM_STYLECHANGING,GWL_EXSTYLE,(LPARAM)&ss); 3002 2982 setExStyle(ss.styleNew); 3003 2983 updateWindowStyle(ss.styleOld,getStyle()); 3004 Send MessageA(WM_STYLECHANGED,GWL_EXSTYLE,(LPARAM)&ss);2984 SendInternalMessageA(WM_STYLECHANGED,GWL_EXSTYLE,(LPARAM)&ss); 3005 2985 return ss.styleOld; 3006 2986 } … … 3016 2996 ss.styleNew = value | (ss.styleOld & (WS_VISIBLE | WS_CHILD)); 3017 2997 dprintf(("SetWindowLong GWL_STYLE %x old %x new style %x", getWindowHandle(), getStyle(), value)); 3018 Send MessageA(WM_STYLECHANGING,GWL_STYLE,(LPARAM)&ss);2998 SendInternalMessageA(WM_STYLECHANGING,GWL_STYLE,(LPARAM)&ss); 3019 2999 setStyle(ss.styleNew); 3020 3000 updateWindowStyle(dwExStyle,ss.styleOld); 3021 Send MessageA(WM_STYLECHANGED,GWL_STYLE,(LPARAM)&ss);3001 SendInternalMessageA(WM_STYLECHANGED,GWL_STYLE,(LPARAM)&ss); 3022 3002 #ifdef DEBUG 3023 3003 PrintWindowStyle(ss.styleNew, 0); … … 3027 3007 case GWL_WNDPROC: 3028 3008 oldval = (LONG)WINPROC_GetProc(win32wndproc, (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A); 3029 WINPROC_SetProc((HWINDOWPROC *)&win32wndproc, (WNDPROC)value, (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A, WIN_PROC_WINDOW); 3009 //WINPROC_SetProc((HWINDOWPROC *)&win32wndproc, (WNDPROC)value, (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A, WIN_PROC_WINDOW); 3010 WINPROC_SetProc((HWINDOWPROC *)&win32wndproc, (WNDPROC)value, WINPROC_GetProcType(win32wndproc), WIN_PROC_WINDOW); 3030 3011 return oldval; 3031 3012 case GWL_HINSTANCE: -
trunk/src/user32/win32wbase.h
r2076 r2084 1 /* $Id: win32wbase.h,v 1.5 3 1999-12-14 19:13:20sandervl Exp $ */1 /* $Id: win32wbase.h,v 1.54 1999-12-16 00:11:47 sandervl Exp $ */ 2 2 /* 3 3 * Win32 Window Base Class for OS/2 … … 40 40 41 41 #define WIN32APP_USERMSGBASE 0x1000 42 #define WIN32APP_POSTMSG 0x 666642 #define WIN32APP_POSTMSG 0x1000 43 43 44 44 typedef struct … … 49 49 ULONG fUnicode; 50 50 } POSTMSG_PACKET; 51 52 #define WM_WIN32_POSTMESSAGEA 0x400053 #define WM_WIN32_POSTMESSAGEW 0x400154 51 55 52 #define BROADCAST_SEND 0 … … 213 210 LRESULT SendMessageA(ULONG msg, WPARAM wParam, LPARAM lParam); 214 211 LRESULT SendMessageW(ULONG msg, WPARAM wParam, LPARAM lParam); 215 LRESULT SendMessageToProcess(UINT msg, WPARAM wParam, LPARAM lParam, BOOL fUnicode);216 212 BOOL PostMessageA(ULONG msg, WPARAM wParam, LPARAM lParam); 217 213 BOOL PostMessageW(ULONG msg, WPARAM wParam, LPARAM lParam); 218 voidPostMessage(POSTMSG_PACKET *packet);214 ULONG PostMessage(POSTMSG_PACKET *packet); 219 215 static BOOL PostThreadMessageA(ULONG threadid, UINT msg, WPARAM wParam, LPARAM lParam); 220 216 static BOOL PostThreadMessageW(ULONG threadid, UINT msg, WPARAM wParam, LPARAM lParam); 221 217 static LRESULT BroadcastMessageA(int type, UINT msg, WPARAM wParam, LPARAM lParam); 222 218 static LRESULT BroadcastMessageW(int type, UINT msg, WPARAM wParam, LPARAM lParam); 219 void CallWindowHookProc(ULONG hooktype, ULONG Msg, WPARAM wParam, LPARAM lParam, BOOL fUnicode = FALSE); 223 220 224 221 LRESULT DefWindowProcA(UINT Msg, WPARAM wParam, LPARAM lParam); … … 306 303 BOOL fNoSizeMsg; 307 304 BOOL fIsDestroyed; 305 BOOL fDestroyWindowCalled; //DestroyWindow was called for this window 308 306 BOOL fCreated; 309 307 BOOL fTaskList; //should be listed in PM tasklist or not 310 308 BOOL fParentDC; 311 309 310 DWORD dwThreadId; //id of thread that created this window 311 DWORD dwProcessId; //id of process that created this window 312 312 PVOID pOldFrameProc; 313 313 ULONG borderWidth; -
trunk/src/user32/win32wbasepos.cpp
r1490 r2084 1 /* $Id: win32wbasepos.cpp,v 1. 6 1999-10-28 12:00:35sandervl Exp $ */1 /* $Id: win32wbasepos.cpp,v 1.7 1999-12-16 00:11:47 sandervl Exp $ */ 2 2 /* 3 3 * Win32 Window Base Class for OS/2 (nonclient/position methods) … … 28 28 #include <spy.h> 29 29 #include "wndmsg.h" 30 #include "hooks.h"31 30 #include "oslibwin.h" 32 31 #include "oslibutil.h" … … 94 93 if( dwStyle & WS_MINIMIZE ) 95 94 { 96 if( !Send MessageA(WM_QUERYOPEN, 0, 0L ) )95 if( !SendInternalMessageA(WM_QUERYOPEN, 0, 0L ) ) 97 96 return (SWP_NOSIZE | SWP_NOMOVE); 98 97 swpFlags |= SWP_NOCOPYBITS; … … 232 231 // } 233 232 234 Send MessageA(WM_GETMINMAXINFO, 0, (LPARAM)&MinMax );233 SendInternalMessageA(WM_GETMINMAXINFO, 0, (LPARAM)&MinMax ); 235 234 236 235 /* Some sanity checks */ … … 276 275 params.lppos = &winposCopy; 277 276 } 278 result = Send MessageA(WM_NCCALCSIZE, calcValidRect,277 result = SendInternalMessageA(WM_NCCALCSIZE, calcValidRect, 279 278 (LPARAM)¶ms ); 280 279 *newClientRect = params.rgrc[0]; -
trunk/src/user32/win32wmdichild.cpp
r2076 r2084 1 /* $Id: win32wmdichild.cpp,v 1.1 1 1999-12-14 19:13:20sandervl Exp $ */1 /* $Id: win32wmdichild.cpp,v 1.12 1999-12-16 00:11:48 sandervl Exp $ */ 2 2 /* 3 3 * Win32 MDI Child Window Class for OS/2 … … 30 30 #include <spy.h> 31 31 #include "wndmsg.h" 32 #include "hooks.h"33 32 #include <oslibwin.h> 34 33 #include <oslibutil.h> … … 231 230 if (wParam == '-') 232 231 { 233 Send MessageA(WM_SYSCOMMAND, (WPARAM)SC_KEYMENU, (LPARAM)(DWORD)VK_SPACE);232 SendInternalMessageA(WM_SYSCOMMAND, (WPARAM)SC_KEYMENU, (LPARAM)(DWORD)VK_SPACE); 234 233 return 0; 235 234 } … … 268 267 if (wParam == '-') 269 268 { 270 Send MessageW(WM_SYSCOMMAND, SC_KEYMENU, (LPARAM)(DWORD)VK_SPACE);269 SendInternalMessageW(WM_SYSCOMMAND, SC_KEYMENU, (LPARAM)(DWORD)VK_SPACE); 271 270 return 0; 272 271 } -
trunk/src/user32/win32wmdiclient.cpp
r2040 r2084 1 /* $Id: win32wmdiclient.cpp,v 1.1 3 1999-12-09 10:59:05sandervl Exp $ */1 /* $Id: win32wmdiclient.cpp,v 1.14 1999-12-16 00:11:48 sandervl Exp $ */ 2 2 /* 3 3 * Win32 MDI Client Window Class for OS/2 … … 26 26 #include <spy.h> 27 27 #include "wndmsg.h" 28 #include "hooks.h"29 28 #include <oslibwin.h> 30 29 #include <oslibutil.h> … … 223 222 case WM_NCACTIVATE: 224 223 if( activeChild ) 225 activeChild->Send MessageA(message, wParam, lParam);224 activeChild->SendInternalMessageA(message, wParam, lParam); 226 225 break; 227 226 … … 344 343 { 345 344 prevActive->setStyle(prevActive->getStyle() | WS_SYSMENU); 346 prevActive->Send MessageA( WM_NCACTIVATE, FALSE, 0L );347 prevActive->Send MessageA( WM_MDIACTIVATE, (WPARAM)prevActive->getWindowHandle(), (LPARAM)(child) ? child->getWindowHandle() : 0);345 prevActive->SendInternalMessageA( WM_NCACTIVATE, FALSE, 0L ); 346 prevActive->SendInternalMessageA( WM_MDIACTIVATE, (WPARAM)prevActive->getWindowHandle(), (LPARAM)(child) ? child->getWindowHandle() : 0); 348 347 349 348 /* uncheck menu item */ … … 386 385 if( isActiveFrameWnd ) 387 386 { 388 child->Send MessageA( WM_NCACTIVATE, TRUE, 0L);387 child->SendInternalMessageA( WM_NCACTIVATE, TRUE, 0L); 389 388 if( GetFocus() == getWindowHandle()) 390 Send MessageA( WM_SETFOCUS, (WPARAM)getWindowHandle(), 0L );389 SendInternalMessageA( WM_SETFOCUS, (WPARAM)getWindowHandle(), 0L ); 391 390 else 392 391 SetFocus( getWindowHandle() ); … … 394 393 395 394 /* @@@PH prevActive may be NULL actually ?! */ 396 child->Send MessageA( WM_MDIACTIVATE,395 child->SendInternalMessageA( WM_MDIACTIVATE, 397 396 prevActive ? (WPARAM)prevActive->getWindowHandle() : 0, 398 397 child->getWindowHandle()); … … 602 601 } 603 602 /********************************************************************** 604 * 603 * MDI_RestoreFrameMenu 605 604 */ 606 605 BOOL Win32MDIClientWindow::restoreFrameMenu(Win32BaseWindow *child) … … 611 610 612 611 if(!(iId == SC_RESTORE || iId == SC_CLOSE) ) 613 612 return 0; 614 613 615 614 /* … … 621 620 622 621 GetMenuItemInfoA(getParent()->GetMenu(), 623 624 625 622 0, 623 TRUE, 624 &menuInfo); 626 625 627 626 RemoveMenu(getParent()->GetMenu(),0,MF_BYPOSITION); … … 630 629 #if 0 631 630 if ((menuInfo.fType & MFT_BITMAP) && 632 633 631 (LOWORD(menuInfo.dwTypeData)!=0) && 632 (LOWORD(menuInfo.dwTypeData)!=hBmpClose) ) 634 633 { 635 634 DeleteObject((HBITMAP)LOWORD(menuInfo.dwTypeData)); … … 660 659 661 660 if (getMaximizedChild()) 662 Send MessageA(WM_MDIRESTORE, (WPARAM)getMaximizedChild()->getWindowHandle(), 0);661 SendInternalMessageA(WM_MDIRESTORE, (WPARAM)getMaximizedChild()->getWindowHandle(), 0); 663 662 664 663 if (nActiveChildren == 0) return 0; … … 706 705 707 706 if (getMaximizedChild()) 708 Send MessageA(WM_MDIRESTORE, (WPARAM)getMaximizedChild()->getWindowHandle(), 0);707 SendInternalMessageA(WM_MDIRESTORE, (WPARAM)getMaximizedChild()->getWindowHandle(), 0); 709 708 710 709 if (nActiveChildren == 0) return; -
trunk/src/user32/win32wnd.cpp
r1490 r2084 1 /* $Id: win32wnd.cpp,v 1. 2 1999-10-28 12:00:37sandervl Exp $ */1 /* $Id: win32wnd.cpp,v 1.3 1999-12-16 00:11:48 sandervl Exp $ */ 2 2 /* 3 3 * Win32 Window Class for OS/2 … … 25 25 #include <spy.h> 26 26 #include "wndmsg.h" 27 #include "hooks.h"28 27 #include <oslibwin.h> 29 28 #include <oslibutil.h> -
trunk/src/user32/window.cpp
r2033 r2084 1 /* $Id: window.cpp,v 1.4 1 1999-12-09 00:53:38 sandervl Exp $ */1 /* $Id: window.cpp,v 1.42 1999-12-16 00:11:48 sandervl Exp $ */ 2 2 /* 3 3 * Win32 window apis for OS/2 … … 394 394 { 395 395 Win32BaseWindow *window; 396 BOOL rc; 396 397 397 398 window = Win32BaseWindow::GetWindowFromHandle(hwnd); … … 401 402 return 0; 402 403 } 403 dprintf(("IsIconic %x", hwnd)); 404 return window->IsIconic(); 404 rc = window->IsIconic(); 405 dprintf(("IsIconic %x returned %d", hwnd, rc)); 406 return rc; 405 407 } 406 408 //****************************************************************************** … … 461 463 dprintf(("ShowWindow %x", hwnd)); 462 464 return window->ShowWindow(nCmdShow); 465 } 466 /***************************************************************************** 467 * Name : BOOL WIN32API ShowWindowAsync 468 * Purpose : The ShowWindowAsync function sets the show state of a window 469 * created by a different thread. 470 * Parameters: HWND hwnd handle of window 471 * int nCmdShow show state of window 472 * Variables : 473 * Result : If the window was previously visible, the return value is TRUE. 474 * If the window was previously hidden, the return value is FALSE. 475 * Remark : 476 * Status : UNTESTED STUB 477 * 478 * Author : Patrick Haller [Thu, 1998/02/26 11:55] 479 *****************************************************************************/ 480 BOOL WIN32API ShowWindowAsync (HWND hwnd, 481 int nCmdShow) 482 { 483 dprintf(("USER32:ShowWindowAsync (%08xh,%08x) not correctly implemented.\n", 484 hwnd, 485 nCmdShow)); 486 487 return ShowWindow(hwnd, nCmdShow); 463 488 } 464 489 //****************************************************************************** -
trunk/src/user32/windowmsg.cpp
r2033 r2084 1 /* $Id: windowmsg.cpp,v 1. 9 1999-12-09 00:53:38sandervl Exp $ */1 /* $Id: windowmsg.cpp,v 1.10 1999-12-16 00:11:49 sandervl Exp $ */ 2 2 /* 3 3 * Win32 window message APIs for OS/2 … … 20 20 #include <win32wbase.h> 21 21 #include <win.h> 22 #include <hooks.h>23 22 #include <heapstring.h> 24 23 #include "oslibwin.h" -
trunk/src/user32/winmenu.cpp
r1732 r2084 1 /* $Id: winmenu.cpp,v 1.1 7 1999-11-14 12:00:01sandervl Exp $ */1 /* $Id: winmenu.cpp,v 1.18 1999-12-16 00:11:49 sandervl Exp $ */ 2 2 3 3 /* … … 597 597 UINT, arg3) 598 598 { 599 dprintf(("USER32: OS2CheckMenuItem\n"));600 599 if(hMenu == 0) 601 600 {
Note:
See TracChangeset
for help on using the changeset viewer.