Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Window related functions |
| 3 | * |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 4 | * Copyright 1993, 1994 Alexandre Julliard |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 5 | */ |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 6 | |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 7 | #include <stdlib.h> |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 8 | #include <string.h> |
Jeremy White | d3e22d9 | 2000-02-10 19:03:02 +0000 | [diff] [blame] | 9 | #include "windef.h" |
Marcus Meissner | 317af32 | 1999-02-17 13:51:06 +0000 | [diff] [blame] | 10 | #include "wine/winbase16.h" |
Michael Veksler | 9d14a00 | 1999-05-08 12:40:24 +0000 | [diff] [blame] | 11 | #include "wine/winuser16.h" |
Alexandre Julliard | cb10fda | 2000-08-06 02:41:16 +0000 | [diff] [blame] | 12 | #include "wine/unicode.h" |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 13 | #include "win.h" |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 14 | #include "heap.h" |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 15 | #include "user.h" |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 16 | #include "dce.h" |
Alexandre Julliard | 91222da | 2000-12-10 23:01:33 +0000 | [diff] [blame] | 17 | #include "controls.h" |
Alexandre Julliard | af0bae5 | 1995-10-03 17:06:08 +0000 | [diff] [blame] | 18 | #include "cursoricon.h" |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 19 | #include "hook.h" |
Alexandre Julliard | ef702d8 | 1996-05-28 18:54:58 +0000 | [diff] [blame] | 20 | #include "message.h" |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 21 | #include "queue.h" |
Alexandre Julliard | 234bc24 | 1994-12-10 13:02:28 +0000 | [diff] [blame] | 22 | #include "winpos.h" |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 23 | #include "winerror.h" |
Alexandre Julliard | 4220b29 | 1999-07-11 17:20:01 +0000 | [diff] [blame] | 24 | #include "stackframe.h" |
| 25 | #include "debugtools.h" |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 26 | |
Alexandre Julliard | b8774f9 | 2000-05-30 17:50:41 +0000 | [diff] [blame] | 27 | DEFAULT_DEBUG_CHANNEL(win); |
| 28 | DECLARE_DEBUG_CHANNEL(msg); |
Patrik Stridvall | b4b9fae | 1999-04-19 14:56:29 +0000 | [diff] [blame] | 29 | |
Patrik Stridvall | b87fe2e | 1999-04-01 08:16:08 +0000 | [diff] [blame] | 30 | /**********************************************************************/ |
| 31 | |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 32 | /* Desktop window */ |
| 33 | static WND *pWndDesktop = NULL; |
| 34 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 35 | static HWND hwndSysModal = 0; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 36 | |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 37 | static WORD wDragWidth = 4; |
| 38 | static WORD wDragHeight= 3; |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 39 | |
Francois Boisvert | 93e3f90 | 1999-02-25 17:32:31 +0000 | [diff] [blame] | 40 | /* thread safeness */ |
Alexandre Julliard | ab68797 | 2000-11-15 23:41:46 +0000 | [diff] [blame] | 41 | static SYSLEVEL WIN_SysLevel = { CRITICAL_SECTION_INIT, 2 }; |
Ulrich Weigand | ef61c0b | 1999-05-08 09:45:50 +0000 | [diff] [blame] | 42 | |
| 43 | /*********************************************************************** |
Francois Boisvert | 93e3f90 | 1999-02-25 17:32:31 +0000 | [diff] [blame] | 44 | * WIN_LockWnds |
| 45 | * |
| 46 | * Locks access to all WND structures for thread safeness |
| 47 | */ |
Ulrich Weigand | c5b8b3a | 1999-05-22 16:28:47 +0000 | [diff] [blame] | 48 | void WIN_LockWnds( void ) |
Francois Boisvert | 93e3f90 | 1999-02-25 17:32:31 +0000 | [diff] [blame] | 49 | { |
Ulrich Weigand | c5b8b3a | 1999-05-22 16:28:47 +0000 | [diff] [blame] | 50 | _EnterSysLevel( &WIN_SysLevel ); |
Francois Boisvert | 93e3f90 | 1999-02-25 17:32:31 +0000 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | /*********************************************************************** |
| 54 | * WIN_UnlockWnds |
| 55 | * |
| 56 | * Unlocks access to all WND structures |
| 57 | */ |
Ulrich Weigand | c5b8b3a | 1999-05-22 16:28:47 +0000 | [diff] [blame] | 58 | void WIN_UnlockWnds( void ) |
Ove Kaaven | bcb4bb6 | 1999-05-12 10:07:02 +0000 | [diff] [blame] | 59 | { |
Ulrich Weigand | c5b8b3a | 1999-05-22 16:28:47 +0000 | [diff] [blame] | 60 | _LeaveSysLevel( &WIN_SysLevel ); |
Francois Boisvert | 93e3f90 | 1999-02-25 17:32:31 +0000 | [diff] [blame] | 61 | } |
Ulrich Weigand | c5b8b3a | 1999-05-22 16:28:47 +0000 | [diff] [blame] | 62 | |
Francois Boisvert | 93e3f90 | 1999-02-25 17:32:31 +0000 | [diff] [blame] | 63 | /*********************************************************************** |
| 64 | * WIN_SuspendWndsLock |
| 65 | * |
| 66 | * Suspend the lock on WND structures. |
| 67 | * Returns the number of locks suspended |
| 68 | */ |
Ulrich Weigand | c5b8b3a | 1999-05-22 16:28:47 +0000 | [diff] [blame] | 69 | int WIN_SuspendWndsLock( void ) |
Francois Boisvert | 93e3f90 | 1999-02-25 17:32:31 +0000 | [diff] [blame] | 70 | { |
Ulrich Weigand | c5b8b3a | 1999-05-22 16:28:47 +0000 | [diff] [blame] | 71 | int isuspendedLocks = _ConfirmSysLevel( &WIN_SysLevel ); |
| 72 | int count = isuspendedLocks; |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 73 | |
Ulrich Weigand | c5b8b3a | 1999-05-22 16:28:47 +0000 | [diff] [blame] | 74 | while ( count-- > 0 ) |
| 75 | _LeaveSysLevel( &WIN_SysLevel ); |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 76 | |
Francois Boisvert | 93e3f90 | 1999-02-25 17:32:31 +0000 | [diff] [blame] | 77 | return isuspendedLocks; |
Francois Boisvert | 93e3f90 | 1999-02-25 17:32:31 +0000 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | /*********************************************************************** |
| 81 | * WIN_RestoreWndsLock |
| 82 | * |
| 83 | * Restore the suspended locks on WND structures |
| 84 | */ |
Ulrich Weigand | c5b8b3a | 1999-05-22 16:28:47 +0000 | [diff] [blame] | 85 | void WIN_RestoreWndsLock( int ipreviousLocks ) |
Francois Boisvert | 93e3f90 | 1999-02-25 17:32:31 +0000 | [diff] [blame] | 86 | { |
Ulrich Weigand | c5b8b3a | 1999-05-22 16:28:47 +0000 | [diff] [blame] | 87 | while ( ipreviousLocks-- > 0 ) |
| 88 | _EnterSysLevel( &WIN_SysLevel ); |
Francois Boisvert | 93e3f90 | 1999-02-25 17:32:31 +0000 | [diff] [blame] | 89 | } |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 90 | |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 91 | /*********************************************************************** |
| 92 | * WIN_FindWndPtr |
| 93 | * |
| 94 | * Return a pointer to the WND structure corresponding to a HWND. |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 95 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 96 | WND * WIN_FindWndPtr( HWND hwnd ) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 97 | { |
| 98 | WND * ptr; |
| 99 | |
Francois Boisvert | 93e3f90 | 1999-02-25 17:32:31 +0000 | [diff] [blame] | 100 | if (!hwnd || HIWORD(hwnd)) goto error2; |
Alexandre Julliard | e2abbb1 | 1995-03-19 17:39:39 +0000 | [diff] [blame] | 101 | ptr = (WND *) USER_HEAP_LIN_ADDR( hwnd ); |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 102 | /* Lock all WND structures for thread safeness*/ |
| 103 | WIN_LockWnds(); |
| 104 | /*and increment destruction monitoring*/ |
Francois Boisvert | 93e3f90 | 1999-02-25 17:32:31 +0000 | [diff] [blame] | 105 | ptr->irefCount++; |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 106 | |
Eric Pouech | b9544f1 | 1999-02-14 14:09:42 +0000 | [diff] [blame] | 107 | if (ptr->dwMagic != WND_MAGIC) goto error; |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 108 | if (ptr->hwndSelf != hwnd) |
| 109 | { |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 110 | ERR("Can't happen: hwnd %04x self pointer is %04x\n",hwnd, ptr->hwndSelf ); |
Eric Pouech | b9544f1 | 1999-02-14 14:09:42 +0000 | [diff] [blame] | 111 | goto error; |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 112 | } |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 113 | /* returns a locked pointer */ |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 114 | return ptr; |
Eric Pouech | b9544f1 | 1999-02-14 14:09:42 +0000 | [diff] [blame] | 115 | error: |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 116 | /* Unlock all WND structures for thread safeness*/ |
| 117 | WIN_UnlockWnds(); |
| 118 | /* and decrement destruction monitoring value */ |
Francois Boisvert | 93e3f90 | 1999-02-25 17:32:31 +0000 | [diff] [blame] | 119 | ptr->irefCount--; |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 120 | |
Francois Boisvert | 93e3f90 | 1999-02-25 17:32:31 +0000 | [diff] [blame] | 121 | error2: |
Juergen Schmied | 1e0bc84 | 1999-02-28 11:08:13 +0000 | [diff] [blame] | 122 | if ( hwnd!=0 ) |
| 123 | SetLastError( ERROR_INVALID_WINDOW_HANDLE ); |
Eric Pouech | b9544f1 | 1999-02-14 14:09:42 +0000 | [diff] [blame] | 124 | return NULL; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 125 | } |
| 126 | |
Francois Boisvert | 93e3f90 | 1999-02-25 17:32:31 +0000 | [diff] [blame] | 127 | /*********************************************************************** |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 128 | * WIN_LockWndPtr |
| 129 | * |
| 130 | * Use in case the wnd ptr is not initialized with WIN_FindWndPtr |
| 131 | * but by initWndPtr; |
| 132 | * Returns the locked initialisation pointer |
| 133 | */ |
| 134 | WND *WIN_LockWndPtr(WND *initWndPtr) |
| 135 | { |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 136 | if(!initWndPtr) return 0; |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 137 | |
| 138 | /* Lock all WND structures for thread safeness*/ |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 139 | WIN_LockWnds(); |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 140 | /*and increment destruction monitoring*/ |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 141 | initWndPtr->irefCount++; |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 142 | |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 143 | return initWndPtr; |
| 144 | |
| 145 | } |
| 146 | |
| 147 | /*********************************************************************** |
Francois Boisvert | 93e3f90 | 1999-02-25 17:32:31 +0000 | [diff] [blame] | 148 | * WIN_ReleaseWndPtr |
| 149 | * |
| 150 | * Release the pointer to the WND structure. |
| 151 | */ |
| 152 | void WIN_ReleaseWndPtr(WND *wndPtr) |
| 153 | { |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 154 | if(!wndPtr) return; |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 155 | |
| 156 | /*Decrement destruction monitoring value*/ |
Francois Boisvert | 93e3f90 | 1999-02-25 17:32:31 +0000 | [diff] [blame] | 157 | wndPtr->irefCount--; |
Francois Boisvert | 86e2e11 | 1999-04-03 11:13:33 +0000 | [diff] [blame] | 158 | /* Check if it's time to release the memory*/ |
| 159 | if(wndPtr->irefCount == 0 && !wndPtr->dwMagic) |
Francois Boisvert | 93e3f90 | 1999-02-25 17:32:31 +0000 | [diff] [blame] | 160 | { |
Francois Boisvert | 86e2e11 | 1999-04-03 11:13:33 +0000 | [diff] [blame] | 161 | /* Release memory */ |
| 162 | USER_HEAP_FREE( wndPtr->hwndSelf); |
Francis Beaudet | 4812647 | 1999-05-22 19:21:01 +0000 | [diff] [blame] | 163 | wndPtr->hwndSelf = 0; |
Francois Boisvert | 93e3f90 | 1999-02-25 17:32:31 +0000 | [diff] [blame] | 164 | } |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 165 | else if(wndPtr->irefCount < 0) |
| 166 | { |
| 167 | /* This else if is useful to monitor the WIN_ReleaseWndPtr function */ |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 168 | ERR("forgot a Lock on %p somewhere\n",wndPtr); |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 169 | } |
| 170 | /*unlock all WND structures for thread safeness*/ |
Francois Boisvert | 93e3f90 | 1999-02-25 17:32:31 +0000 | [diff] [blame] | 171 | WIN_UnlockWnds(); |
Francois Boisvert | 93e3f90 | 1999-02-25 17:32:31 +0000 | [diff] [blame] | 172 | } |
| 173 | |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 174 | /*********************************************************************** |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 175 | * WIN_UpdateWndPtr |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 176 | * |
| 177 | * Updates the value of oldPtr to newPtr. |
| 178 | */ |
| 179 | void WIN_UpdateWndPtr(WND **oldPtr, WND *newPtr) |
| 180 | { |
| 181 | WND *tmpWnd = NULL; |
| 182 | |
| 183 | tmpWnd = WIN_LockWndPtr(newPtr); |
| 184 | WIN_ReleaseWndPtr(*oldPtr); |
| 185 | *oldPtr = tmpWnd; |
| 186 | |
| 187 | } |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 188 | |
| 189 | /*********************************************************************** |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 190 | * WIN_DumpWindow |
| 191 | * |
| 192 | * Dump the content of a window structure to stderr. |
| 193 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 194 | void WIN_DumpWindow( HWND hwnd ) |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 195 | { |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 196 | WND *ptr; |
| 197 | char className[80]; |
| 198 | int i; |
| 199 | |
| 200 | if (!(ptr = WIN_FindWndPtr( hwnd ))) |
| 201 | { |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 202 | WARN("%04x is not a window handle\n", hwnd ); |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 203 | return; |
| 204 | } |
| 205 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 206 | if (!GetClassNameA( hwnd, className, sizeof(className ) )) |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 207 | strcpy( className, "#NULL#" ); |
| 208 | |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 209 | TRACE("Window %04x (%p):\n", hwnd, ptr ); |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 210 | DPRINTF( "next=%p child=%p parent=%p owner=%p class=%p '%s'\n" |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 211 | "inst=%04x taskQ=%04x updRgn=%04x active=%04x dce=%p idmenu=%08x\n" |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 212 | "style=%08lx exstyle=%08lx wndproc=%08x text='%s'\n" |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 213 | "client=%d,%d-%d,%d window=%d,%d-%d,%d" |
Alexandre Julliard | ac9c9b0 | 1996-07-28 18:50:11 +0000 | [diff] [blame] | 214 | "sysmenu=%04x flags=%04x props=%p vscroll=%p hscroll=%p\n", |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 215 | ptr->next, ptr->child, ptr->parent, ptr->owner, |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 216 | ptr->class, className, ptr->hInstance, ptr->hmemTaskQ, |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 217 | ptr->hrgnUpdate, ptr->hwndLastActive, ptr->dce, ptr->wIDmenu, |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 218 | ptr->dwStyle, ptr->dwExStyle, (UINT)ptr->winproc, |
Dmitry Timoshkov | 04da8b8 | 2000-07-10 12:09:31 +0000 | [diff] [blame] | 219 | ptr->text ? debugstr_w(ptr->text) : "", |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 220 | ptr->rectClient.left, ptr->rectClient.top, ptr->rectClient.right, |
| 221 | ptr->rectClient.bottom, ptr->rectWindow.left, ptr->rectWindow.top, |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 222 | ptr->rectWindow.right, ptr->rectWindow.bottom, ptr->hSysMenu, |
Alexandre Julliard | ac9c9b0 | 1996-07-28 18:50:11 +0000 | [diff] [blame] | 223 | ptr->flags, ptr->pProp, ptr->pVScroll, ptr->pHScroll ); |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 224 | |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 225 | if (ptr->cbWndExtra) |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 226 | { |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 227 | DPRINTF( "extra bytes:" ); |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 228 | for (i = 0; i < ptr->cbWndExtra; i++) |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 229 | DPRINTF( " %02x", *((BYTE*)ptr->wExtra+i) ); |
| 230 | DPRINTF( "\n" ); |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 231 | } |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 232 | DPRINTF( "\n" ); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 233 | WIN_ReleaseWndPtr(ptr); |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 234 | } |
| 235 | |
| 236 | |
| 237 | /*********************************************************************** |
| 238 | * WIN_WalkWindows |
| 239 | * |
| 240 | * Walk the windows tree and print each window on stderr. |
| 241 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 242 | void WIN_WalkWindows( HWND hwnd, int indent ) |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 243 | { |
| 244 | WND *ptr; |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 245 | char className[80]; |
| 246 | |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 247 | ptr = hwnd ? WIN_FindWndPtr( hwnd ) : WIN_GetDesktop(); |
| 248 | |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 249 | if (!ptr) |
| 250 | { |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 251 | WARN("Invalid window handle %04x\n", hwnd ); |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 252 | return; |
| 253 | } |
| 254 | |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 255 | if (!indent) /* first time around */ |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 256 | DPRINTF( "%-16.16s %-8.8s %-6.6s %-17.17s %-8.8s %s\n", |
Rein Klazes | d62c62b | 1998-10-11 14:05:34 +0000 | [diff] [blame] | 257 | "hwnd", " wndPtr", "queue", "Class Name", " Style", " WndProc" |
| 258 | " Text"); |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 259 | |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 260 | while (ptr) |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 261 | { |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 262 | DPRINTF( "%*s%04x%*s", indent, "", ptr->hwndSelf, 13-indent,""); |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 263 | |
Dmitry Timoshkov | dc830b5 | 2001-03-28 18:46:08 +0000 | [diff] [blame] | 264 | GetClassNameA( ptr->hwndSelf, className, sizeof(className) ); |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 265 | DPRINTF( "%08lx %-6.4x %-17.17s %08x %08x %.14s\n", |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 266 | (DWORD)ptr, ptr->hmemTaskQ, className, |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 267 | (UINT)ptr->dwStyle, (UINT)ptr->winproc, |
Dmitry Timoshkov | 04da8b8 | 2000-07-10 12:09:31 +0000 | [diff] [blame] | 268 | ptr->text ? debugstr_w(ptr->text) : "<null>"); |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 269 | |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 270 | if (ptr->child) WIN_WalkWindows( ptr->child->hwndSelf, indent+1 ); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 271 | WIN_UpdateWndPtr(&ptr,ptr->next); |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 272 | } |
| 273 | } |
| 274 | |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 275 | /*********************************************************************** |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 276 | * WIN_UnlinkWindow |
| 277 | * |
| 278 | * Remove a window from the siblings linked list. |
| 279 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 280 | BOOL WIN_UnlinkWindow( HWND hwnd ) |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 281 | { |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 282 | WND *wndPtr, **ppWnd; |
Eric Pouech | 3be8e3b | 1999-04-18 13:13:40 +0000 | [diff] [blame] | 283 | BOOL ret = FALSE; |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 284 | |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 285 | if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return FALSE; |
| 286 | else if(!wndPtr->parent) |
| 287 | { |
| 288 | WIN_ReleaseWndPtr(wndPtr); |
| 289 | return FALSE; |
| 290 | } |
Eric Pouech | 3be8e3b | 1999-04-18 13:13:40 +0000 | [diff] [blame] | 291 | |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 292 | ppWnd = &wndPtr->parent->child; |
Eric Pouech | 3be8e3b | 1999-04-18 13:13:40 +0000 | [diff] [blame] | 293 | while (*ppWnd && *ppWnd != wndPtr) ppWnd = &(*ppWnd)->next; |
| 294 | if (*ppWnd) |
| 295 | { |
| 296 | *ppWnd = wndPtr->next; |
| 297 | ret = TRUE; |
| 298 | } |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 299 | WIN_ReleaseWndPtr(wndPtr); |
Eric Pouech | 3be8e3b | 1999-04-18 13:13:40 +0000 | [diff] [blame] | 300 | return ret; |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 301 | } |
| 302 | |
| 303 | |
| 304 | /*********************************************************************** |
| 305 | * WIN_LinkWindow |
| 306 | * |
| 307 | * Insert a window into the siblings linked list. |
| 308 | * The window is inserted after the specified window, which can also |
| 309 | * be specified as HWND_TOP or HWND_BOTTOM. |
| 310 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 311 | BOOL WIN_LinkWindow( HWND hwnd, HWND hwndInsertAfter ) |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 312 | { |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 313 | WND *wndPtr, **ppWnd; |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 314 | |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 315 | if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return FALSE; |
| 316 | else if(!wndPtr->parent) |
| 317 | { |
| 318 | WIN_ReleaseWndPtr(wndPtr); |
| 319 | return FALSE; |
| 320 | } |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 321 | if ((hwndInsertAfter == HWND_TOP) || (hwndInsertAfter == HWND_BOTTOM)) |
| 322 | { |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 323 | ppWnd = &wndPtr->parent->child; /* Point to first sibling hwnd */ |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 324 | if (hwndInsertAfter == HWND_BOTTOM) /* Find last sibling hwnd */ |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 325 | while (*ppWnd) ppWnd = &(*ppWnd)->next; |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 326 | } |
| 327 | else /* Normal case */ |
| 328 | { |
| 329 | WND * afterPtr = WIN_FindWndPtr( hwndInsertAfter ); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 330 | if (!afterPtr) |
| 331 | { |
| 332 | WIN_ReleaseWndPtr(wndPtr); |
| 333 | return FALSE; |
| 334 | } |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 335 | ppWnd = &afterPtr->next; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 336 | WIN_ReleaseWndPtr(afterPtr); |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 337 | } |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 338 | wndPtr->next = *ppWnd; |
| 339 | *ppWnd = wndPtr; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 340 | WIN_ReleaseWndPtr(wndPtr); |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 341 | return TRUE; |
| 342 | } |
| 343 | |
| 344 | |
| 345 | /*********************************************************************** |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 346 | * WIN_FindWinToRepaint |
| 347 | * |
| 348 | * Find a window that needs repaint. |
| 349 | */ |
Alexandre Julliard | 4b0343d | 2001-06-20 22:55:31 +0000 | [diff] [blame] | 350 | HWND WIN_FindWinToRepaint( HWND hwnd ) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 351 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 352 | HWND hwndRet; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 353 | WND *pWnd; |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 354 | |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 355 | /* Note: the desktop window never gets WM_PAINT messages |
| 356 | * The real reason why is because Windows DesktopWndProc |
| 357 | * does ValidateRgn inside WM_ERASEBKGND handler. |
| 358 | */ |
Alexandre Julliard | 4323004 | 2001-05-16 19:52:29 +0000 | [diff] [blame] | 359 | if (hwnd == GetDesktopWindow()) hwnd = 0; |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 360 | |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 361 | pWnd = hwnd ? WIN_FindWndPtr(hwnd) : WIN_LockWndPtr(pWndDesktop->child); |
Alexandre Julliard | c981d0b | 1996-03-31 16:40:13 +0000 | [diff] [blame] | 362 | |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 363 | for ( ; pWnd ; WIN_UpdateWndPtr(&pWnd,pWnd->next)) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 364 | { |
Alexandre Julliard | e658d82 | 1997-11-30 17:45:40 +0000 | [diff] [blame] | 365 | if (!(pWnd->dwStyle & WS_VISIBLE)) |
Alexandre Julliard | c981d0b | 1996-03-31 16:40:13 +0000 | [diff] [blame] | 366 | { |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 367 | TRACE("skipping window %04x\n", |
Alexandre Julliard | c981d0b | 1996-03-31 16:40:13 +0000 | [diff] [blame] | 368 | pWnd->hwndSelf ); |
Alexandre Julliard | c981d0b | 1996-03-31 16:40:13 +0000 | [diff] [blame] | 369 | } |
Alexandre Julliard | 4b0343d | 2001-06-20 22:55:31 +0000 | [diff] [blame] | 370 | else if ((pWnd->hrgnUpdate || (pWnd->flags & WIN_INTERNAL_PAINT)) && |
| 371 | GetWindowThreadProcessId( pWnd->hwndSelf, NULL ) == GetCurrentThreadId()) |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 372 | break; |
Alexandre Julliard | c981d0b | 1996-03-31 16:40:13 +0000 | [diff] [blame] | 373 | |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 374 | else if (pWnd->child ) |
Alexandre Julliard | 4b0343d | 2001-06-20 22:55:31 +0000 | [diff] [blame] | 375 | if ((hwndRet = WIN_FindWinToRepaint( pWnd->child->hwndSelf )) ) |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 376 | { |
| 377 | WIN_ReleaseWndPtr(pWnd); |
| 378 | return hwndRet; |
| 379 | } |
| 380 | |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 381 | } |
Alexandre Julliard | c981d0b | 1996-03-31 16:40:13 +0000 | [diff] [blame] | 382 | |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 383 | if(!pWnd) |
| 384 | { |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 385 | return 0; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 386 | } |
Alexandre Julliard | c981d0b | 1996-03-31 16:40:13 +0000 | [diff] [blame] | 387 | |
| 388 | hwndRet = pWnd->hwndSelf; |
| 389 | |
| 390 | /* look among siblings if we got a transparent window */ |
| 391 | while (pWnd && ((pWnd->dwExStyle & WS_EX_TRANSPARENT) || |
| 392 | !(pWnd->hrgnUpdate || (pWnd->flags & WIN_INTERNAL_PAINT)))) |
| 393 | { |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 394 | WIN_UpdateWndPtr(&pWnd,pWnd->next); |
Alexandre Julliard | c981d0b | 1996-03-31 16:40:13 +0000 | [diff] [blame] | 395 | } |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 396 | if (pWnd) |
| 397 | { |
| 398 | hwndRet = pWnd->hwndSelf; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 399 | WIN_ReleaseWndPtr(pWnd); |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 400 | } |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 401 | TRACE("found %04x\n",hwndRet); |
Alexandre Julliard | c981d0b | 1996-03-31 16:40:13 +0000 | [diff] [blame] | 402 | return hwndRet; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 403 | } |
| 404 | |
| 405 | |
| 406 | /*********************************************************************** |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 407 | * WIN_DestroyWindow |
| 408 | * |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 409 | * Destroy storage associated to a window. "Internals" p.358 |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 410 | * returns a locked wndPtr->next |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 411 | */ |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 412 | static WND* WIN_DestroyWindow( WND* wndPtr ) |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 413 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 414 | HWND hwnd = wndPtr->hwndSelf; |
Alexandre Julliard | 349a953 | 1997-02-02 19:01:52 +0000 | [diff] [blame] | 415 | WND *pWnd; |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 416 | |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 417 | TRACE("%04x\n", wndPtr->hwndSelf ); |
Alexandre Julliard | 75d86e1 | 1996-11-17 18:59:11 +0000 | [diff] [blame] | 418 | |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 419 | /* free child windows */ |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 420 | WIN_LockWndPtr(wndPtr->child); |
Alexandre Julliard | 349a953 | 1997-02-02 19:01:52 +0000 | [diff] [blame] | 421 | while ((pWnd = wndPtr->child)) |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 422 | { |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 423 | wndPtr->child = WIN_DestroyWindow( pWnd ); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 424 | WIN_ReleaseWndPtr(pWnd); |
| 425 | } |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 426 | |
Francis Beaudet | 7c2f0fe | 1999-03-21 08:50:41 +0000 | [diff] [blame] | 427 | /* |
| 428 | * Clear the update region to make sure no WM_PAINT messages will be |
| 429 | * generated for this window while processing the WM_NCDESTROY. |
| 430 | */ |
Alexandre Julliard | 4b0343d | 2001-06-20 22:55:31 +0000 | [diff] [blame] | 431 | RedrawWindow( wndPtr->hwndSelf, NULL, 0, |
| 432 | RDW_VALIDATE | RDW_NOFRAME | RDW_NOERASE | RDW_NOINTERNALPAINT | RDW_NOCHILDREN); |
Francis Beaudet | 7c2f0fe | 1999-03-21 08:50:41 +0000 | [diff] [blame] | 433 | |
| 434 | /* |
| 435 | * Send the WM_NCDESTROY to the window being destroyed. |
| 436 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 437 | SendMessageA( wndPtr->hwndSelf, WM_NCDESTROY, 0, 0); |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 438 | |
| 439 | /* FIXME: do we need to fake QS_MOUSEMOVE wakebit? */ |
| 440 | |
Noel Borthwick | b427856 | 1999-02-05 10:37:53 +0000 | [diff] [blame] | 441 | WINPOS_CheckInternalPos( wndPtr ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 442 | if( hwnd == GetCapture()) ReleaseCapture(); |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 443 | |
| 444 | /* free resources associated with the window */ |
| 445 | |
| 446 | TIMER_RemoveWindowTimers( wndPtr->hwndSelf ); |
Alexandre Julliard | ac9c9b0 | 1996-07-28 18:50:11 +0000 | [diff] [blame] | 447 | PROPERTY_RemoveWindowProps( wndPtr ); |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 448 | |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 449 | /* toss stale messages from the queue */ |
| 450 | |
Alexandre Julliard | 51ab43b | 2001-05-18 22:51:56 +0000 | [diff] [blame] | 451 | QUEUE_CleanupWindow( hwnd ); |
| 452 | wndPtr->hmemTaskQ = 0; |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 453 | |
| 454 | if (!(wndPtr->dwStyle & WS_CHILD)) |
Guy Albertelli | 38db098 | 2000-05-11 00:06:38 +0000 | [diff] [blame] | 455 | if (wndPtr->wIDmenu) |
| 456 | { |
| 457 | DestroyMenu( wndPtr->wIDmenu ); |
| 458 | wndPtr->wIDmenu = 0; |
| 459 | } |
| 460 | if (wndPtr->hSysMenu) |
| 461 | { |
| 462 | DestroyMenu( wndPtr->hSysMenu ); |
| 463 | wndPtr->hSysMenu = 0; |
| 464 | } |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 465 | USER_Driver.pDestroyWindow( wndPtr->hwndSelf ); |
Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 466 | DCE_FreeWindowDCE( wndPtr ); /* Always do this to catch orphaned DCs */ |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 467 | WINPROC_FreeProc( wndPtr->winproc, WIN_PROC_WINDOW ); |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 468 | CLASS_RemoveWindow( wndPtr->class ); |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 469 | wndPtr->class = NULL; |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 470 | wndPtr->dwMagic = 0; /* Mark it as invalid */ |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 471 | |
| 472 | WIN_UpdateWndPtr(&pWnd,wndPtr->next); |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 473 | |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 474 | return pWnd; |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 475 | } |
| 476 | |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 477 | /*********************************************************************** |
Alexandre Julliard | 4b0343d | 2001-06-20 22:55:31 +0000 | [diff] [blame] | 478 | * WIN_DestroyThreadWindows |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 479 | * |
Alexandre Julliard | 4b0343d | 2001-06-20 22:55:31 +0000 | [diff] [blame] | 480 | * Destroy all children of 'wnd' owned by the current thread. |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 481 | * Return TRUE if something was done. |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 482 | */ |
Alexandre Julliard | 4b0343d | 2001-06-20 22:55:31 +0000 | [diff] [blame] | 483 | BOOL WIN_DestroyThreadWindows( HWND hwnd ) |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 484 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 485 | BOOL ret = FALSE; |
Alexandre Julliard | 4b0343d | 2001-06-20 22:55:31 +0000 | [diff] [blame] | 486 | WND *wnd = WIN_FindWndPtr( hwnd ); |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 487 | |
Alexandre Julliard | 4b0343d | 2001-06-20 22:55:31 +0000 | [diff] [blame] | 488 | if (!wnd) return FALSE; |
| 489 | while (wnd->child) |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 490 | { |
Alexandre Julliard | 4b0343d | 2001-06-20 22:55:31 +0000 | [diff] [blame] | 491 | WND *tmp = WIN_LockWndPtr(wnd->child); |
| 492 | ret = FALSE; |
| 493 | while (tmp) |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 494 | { |
Alexandre Julliard | 4b0343d | 2001-06-20 22:55:31 +0000 | [diff] [blame] | 495 | if (GetWindowThreadProcessId( tmp->hwndSelf, NULL ) == GetCurrentThreadId()) |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 496 | { |
Alexandre Julliard | 4b0343d | 2001-06-20 22:55:31 +0000 | [diff] [blame] | 497 | DestroyWindow( tmp->hwndSelf ); |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 498 | ret = TRUE; |
Alexandre Julliard | 4b0343d | 2001-06-20 22:55:31 +0000 | [diff] [blame] | 499 | break; |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 500 | } |
Alexandre Julliard | 4b0343d | 2001-06-20 22:55:31 +0000 | [diff] [blame] | 501 | if (tmp->child && WIN_DestroyThreadWindows( tmp->hwndSelf )) |
| 502 | ret = TRUE; |
| 503 | else |
| 504 | WIN_UpdateWndPtr(&tmp,tmp->next); |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 505 | } |
Alexandre Julliard | 4b0343d | 2001-06-20 22:55:31 +0000 | [diff] [blame] | 506 | WIN_ReleaseWndPtr(tmp); |
| 507 | if (!ret) break; |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 508 | } |
Alexandre Julliard | 4b0343d | 2001-06-20 22:55:31 +0000 | [diff] [blame] | 509 | WIN_ReleaseWndPtr( wnd ); |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 510 | return ret; |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 511 | } |
| 512 | |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 513 | /*********************************************************************** |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 514 | * WIN_CreateDesktopWindow |
| 515 | * |
| 516 | * Create the desktop window. |
| 517 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 518 | BOOL WIN_CreateDesktopWindow(void) |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 519 | { |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 520 | struct tagCLASS *class; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 521 | HWND hwndDesktop; |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 522 | INT wndExtra; |
| 523 | DWORD clsStyle; |
| 524 | WNDPROC winproc; |
| 525 | DCE *dce; |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 526 | CREATESTRUCTA cs; |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 527 | |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 528 | TRACE("Creating desktop window\n"); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 529 | |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 530 | |
Alexandre Julliard | 91222da | 2000-12-10 23:01:33 +0000 | [diff] [blame] | 531 | if (!WINPOS_CreateInternalPosAtom() || |
| 532 | !(class = CLASS_AddWindow( (ATOM)LOWORD(DESKTOP_CLASS_ATOM), 0, WIN_PROC_32W, |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 533 | &wndExtra, &winproc, &clsStyle, &dce ))) |
| 534 | return FALSE; |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 535 | |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 536 | hwndDesktop = USER_HEAP_ALLOC( sizeof(WND) + wndExtra ); |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 537 | if (!hwndDesktop) return FALSE; |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 538 | pWndDesktop = (WND *) USER_HEAP_LIN_ADDR( hwndDesktop ); |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 539 | |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 540 | pWndDesktop->next = NULL; |
| 541 | pWndDesktop->child = NULL; |
| 542 | pWndDesktop->parent = NULL; |
| 543 | pWndDesktop->owner = NULL; |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 544 | pWndDesktop->class = class; |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 545 | pWndDesktop->dwMagic = WND_MAGIC; |
| 546 | pWndDesktop->hwndSelf = hwndDesktop; |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 547 | pWndDesktop->hInstance = 0; |
| 548 | pWndDesktop->rectWindow.left = 0; |
| 549 | pWndDesktop->rectWindow.top = 0; |
Marcus Meissner | ddca315 | 1999-05-22 11:33:23 +0000 | [diff] [blame] | 550 | pWndDesktop->rectWindow.right = GetSystemMetrics(SM_CXSCREEN); |
| 551 | pWndDesktop->rectWindow.bottom = GetSystemMetrics(SM_CYSCREEN); |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 552 | pWndDesktop->rectClient = pWndDesktop->rectWindow; |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 553 | pWndDesktop->text = NULL; |
Alexandre Julliard | 4323004 | 2001-05-16 19:52:29 +0000 | [diff] [blame] | 554 | pWndDesktop->hmemTaskQ = 0; |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 555 | pWndDesktop->hrgnUpdate = 0; |
| 556 | pWndDesktop->hwndLastActive = hwndDesktop; |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 557 | pWndDesktop->dwStyle = WS_VISIBLE | WS_CLIPCHILDREN | |
| 558 | WS_CLIPSIBLINGS; |
| 559 | pWndDesktop->dwExStyle = 0; |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 560 | pWndDesktop->clsStyle = clsStyle; |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 561 | pWndDesktop->dce = NULL; |
Alexandre Julliard | ca22b33 | 1996-07-12 19:02:39 +0000 | [diff] [blame] | 562 | pWndDesktop->pVScroll = NULL; |
| 563 | pWndDesktop->pHScroll = NULL; |
Alexandre Julliard | ac9c9b0 | 1996-07-28 18:50:11 +0000 | [diff] [blame] | 564 | pWndDesktop->pProp = NULL; |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 565 | pWndDesktop->wIDmenu = 0; |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 566 | pWndDesktop->helpContext = 0; |
Alexandre Julliard | 26320d1 | 2001-03-23 23:45:45 +0000 | [diff] [blame] | 567 | pWndDesktop->flags = 0; |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 568 | pWndDesktop->hSysMenu = 0; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 569 | pWndDesktop->userdata = 0; |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 570 | pWndDesktop->winproc = winproc; |
| 571 | pWndDesktop->cbWndExtra = wndExtra; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 572 | pWndDesktop->irefCount = 0; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 573 | |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 574 | cs.lpCreateParams = NULL; |
| 575 | cs.hInstance = 0; |
| 576 | cs.hMenu = 0; |
| 577 | cs.hwndParent = 0; |
| 578 | cs.x = 0; |
| 579 | cs.y = 0; |
| 580 | cs.cx = pWndDesktop->rectWindow.right; |
| 581 | cs.cy = pWndDesktop->rectWindow.bottom; |
| 582 | cs.style = pWndDesktop->dwStyle; |
| 583 | cs.dwExStyle = pWndDesktop->dwExStyle; |
| 584 | cs.lpszName = NULL; |
| 585 | cs.lpszClass = DESKTOP_CLASS_ATOM; |
Alexandre Julliard | 91222da | 2000-12-10 23:01:33 +0000 | [diff] [blame] | 586 | |
Gerard Patel | ad36303 | 2001-06-06 21:26:50 +0000 | [diff] [blame] | 587 | if (!USER_Driver.pCreateWindow( hwndDesktop, &cs, FALSE )) return FALSE; |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 588 | |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 589 | pWndDesktop->flags |= WIN_NEEDS_ERASEBKGND; |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 590 | return TRUE; |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 591 | } |
| 592 | |
| 593 | |
| 594 | /*********************************************************************** |
Dmitry Timoshkov | 5956b98 | 2000-11-28 23:53:08 +0000 | [diff] [blame] | 595 | * WIN_FixCoordinates |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 596 | * |
Gerard Patel | 78f52b5 | 2000-05-31 19:23:20 +0000 | [diff] [blame] | 597 | * Fix the coordinates - Helper for WIN_CreateWindowEx. |
| 598 | * returns default show mode in sw. |
| 599 | * Note: the feature presented as undocumented *is* in the MSDN since 1993. |
| 600 | */ |
| 601 | static void WIN_FixCoordinates( CREATESTRUCTA *cs, INT *sw) |
| 602 | { |
| 603 | if (cs->x == CW_USEDEFAULT || cs->x == CW_USEDEFAULT16 || |
| 604 | cs->cx == CW_USEDEFAULT || cs->cx == CW_USEDEFAULT16) |
| 605 | { |
Alexandre Julliard | 6aa2843 | 2000-06-08 01:01:09 +0000 | [diff] [blame] | 606 | if (cs->style & (WS_CHILD | WS_POPUP)) |
Gerard Patel | 78f52b5 | 2000-05-31 19:23:20 +0000 | [diff] [blame] | 607 | { |
Alexandre Julliard | 6aa2843 | 2000-06-08 01:01:09 +0000 | [diff] [blame] | 608 | if (cs->x == CW_USEDEFAULT || cs->x == CW_USEDEFAULT16) cs->x = cs->y = 0; |
| 609 | if (cs->cx == CW_USEDEFAULT || cs->cx == CW_USEDEFAULT16) cs->cx = cs->cy = 0; |
Gerard Patel | 78f52b5 | 2000-05-31 19:23:20 +0000 | [diff] [blame] | 610 | } |
Alexandre Julliard | 6aa2843 | 2000-06-08 01:01:09 +0000 | [diff] [blame] | 611 | else /* overlapped window */ |
Gerard Patel | 78f52b5 | 2000-05-31 19:23:20 +0000 | [diff] [blame] | 612 | { |
Alexandre Julliard | 6aa2843 | 2000-06-08 01:01:09 +0000 | [diff] [blame] | 613 | STARTUPINFOA info; |
| 614 | |
| 615 | GetStartupInfoA( &info ); |
| 616 | |
| 617 | if (cs->x == CW_USEDEFAULT || cs->x == CW_USEDEFAULT16) |
| 618 | { |
| 619 | /* Never believe Microsoft's documentation... CreateWindowEx doc says |
| 620 | * that if an overlapped window is created with WS_VISIBLE style bit |
| 621 | * set and the x parameter is set to CW_USEDEFAULT, the system ignores |
| 622 | * the y parameter. However, disassembling NT implementation (WIN32K.SYS) |
| 623 | * reveals that |
| 624 | * |
| 625 | * 1) not only it checks for CW_USEDEFAULT but also for CW_USEDEFAULT16 |
| 626 | * 2) it does not ignore the y parameter as the docs claim; instead, it |
| 627 | * uses it as second parameter to ShowWindow() unless y is either |
| 628 | * CW_USEDEFAULT or CW_USEDEFAULT16. |
| 629 | * |
| 630 | * The fact that we didn't do 2) caused bogus windows pop up when wine |
| 631 | * was running apps that were using this obscure feature. Example - |
| 632 | * calc.exe that comes with Win98 (only Win98, it's different from |
| 633 | * the one that comes with Win95 and NT) |
| 634 | */ |
| 635 | if (cs->y != CW_USEDEFAULT && cs->y != CW_USEDEFAULT16) *sw = cs->y; |
| 636 | cs->x = (info.dwFlags & STARTF_USEPOSITION) ? info.dwX : 0; |
| 637 | cs->y = (info.dwFlags & STARTF_USEPOSITION) ? info.dwY : 0; |
| 638 | } |
| 639 | |
| 640 | if (cs->cx == CW_USEDEFAULT || cs->cx == CW_USEDEFAULT16) |
| 641 | { |
| 642 | if (info.dwFlags & STARTF_USESIZE) |
| 643 | { |
| 644 | cs->cx = info.dwXSize; |
| 645 | cs->cy = info.dwYSize; |
| 646 | } |
| 647 | else /* if no other hint from the app, pick 3/4 of the screen real estate */ |
| 648 | { |
| 649 | RECT r; |
| 650 | SystemParametersInfoA( SPI_GETWORKAREA, 0, &r, 0); |
| 651 | cs->cx = (((r.right - r.left) * 3) / 4) - cs->x; |
| 652 | cs->cy = (((r.bottom - r.top) * 3) / 4) - cs->y; |
| 653 | } |
| 654 | } |
Gerard Patel | 78f52b5 | 2000-05-31 19:23:20 +0000 | [diff] [blame] | 655 | } |
| 656 | } |
| 657 | } |
| 658 | |
| 659 | /*********************************************************************** |
| 660 | * WIN_CreateWindowEx |
| 661 | * |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 662 | * Implementation of CreateWindowEx(). |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 663 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 664 | static HWND WIN_CreateWindowEx( CREATESTRUCTA *cs, ATOM classAtom, |
Dmitry Timoshkov | 5956b98 | 2000-11-28 23:53:08 +0000 | [diff] [blame] | 665 | WINDOWPROCTYPE type ) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 666 | { |
Slava Monich | a27807d | 1999-06-05 11:46:35 +0000 | [diff] [blame] | 667 | INT sw = SW_SHOW; |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 668 | struct tagCLASS *classPtr; |
Alexandre Julliard | d2e1c1a | 1996-03-09 16:12:43 +0000 | [diff] [blame] | 669 | WND *wndPtr; |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 670 | HWND hwnd, hwndLinkAfter; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 671 | POINT maxSize, maxPos, minTrack, maxTrack; |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 672 | INT wndExtra; |
| 673 | DWORD clsStyle; |
| 674 | WNDPROC winproc; |
| 675 | DCE *dce; |
Gerard Patel | ad36303 | 2001-06-06 21:26:50 +0000 | [diff] [blame] | 676 | BOOL unicode = (type == WIN_PROC_32W); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 677 | |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 678 | TRACE("%s %s %08lx %08lx %d,%d %dx%d %04x %04x %08x %p\n", |
Dmitry Timoshkov | 5956b98 | 2000-11-28 23:53:08 +0000 | [diff] [blame] | 679 | (type == WIN_PROC_32W) ? debugres_w((LPWSTR)cs->lpszName) : debugres_a(cs->lpszName), |
| 680 | (type == WIN_PROC_32W) ? debugres_w((LPWSTR)cs->lpszClass) : debugres_a(cs->lpszClass), |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 681 | cs->dwExStyle, cs->style, cs->x, cs->y, cs->cx, cs->cy, |
| 682 | cs->hwndParent, cs->hMenu, cs->hInstance, cs->lpCreateParams ); |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 683 | |
Dmitry Timoshkov | 5956b98 | 2000-11-28 23:53:08 +0000 | [diff] [blame] | 684 | TRACE("winproc type is %d (%s)\n", type, (type == WIN_PROC_16) ? "WIN_PROC_16" : |
| 685 | ((type == WIN_PROC_32A) ? "WIN_PROC_32A" : "WIN_PROC_32W") ); |
| 686 | |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 687 | /* Find the parent window */ |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 688 | |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 689 | if (cs->hwndParent) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 690 | { |
Alexandre Julliard | bd34d4f | 1995-06-20 19:08:12 +0000 | [diff] [blame] | 691 | /* Make sure parent is valid */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 692 | if (!IsWindow( cs->hwndParent )) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 693 | { |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 694 | WARN("Bad parent %04x\n", cs->hwndParent ); |
Alexandre Julliard | bd34d4f | 1995-06-20 19:08:12 +0000 | [diff] [blame] | 695 | return 0; |
Alexandre Julliard | fa68b75 | 1995-04-03 16:55:37 +0000 | [diff] [blame] | 696 | } |
Alexandre Julliard | 3db94ef | 1997-09-28 17:43:24 +0000 | [diff] [blame] | 697 | } else if ((cs->style & WS_CHILD) && !(cs->style & WS_POPUP)) { |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 698 | WARN("No parent for child window\n" ); |
Alexandre Julliard | 3db94ef | 1997-09-28 17:43:24 +0000 | [diff] [blame] | 699 | return 0; /* WS_CHILD needs a parent, but WS_POPUP doesn't */ |
Alexandre Julliard | bd34d4f | 1995-06-20 19:08:12 +0000 | [diff] [blame] | 700 | } |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 701 | |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 702 | /* Find the window class */ |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 703 | if (!(classPtr = CLASS_AddWindow( classAtom, cs->hInstance, type, |
| 704 | &wndExtra, &winproc, &clsStyle, &dce ))) |
Alexandre Julliard | 808cb04 | 1995-08-17 17:11:36 +0000 | [diff] [blame] | 705 | { |
Gerard Patel | 6fdb5dd | 2000-02-16 21:23:24 +0000 | [diff] [blame] | 706 | WARN("Bad class '%s'\n", cs->lpszClass ); |
Alexandre Julliard | ff8331e | 1995-09-18 11:19:54 +0000 | [diff] [blame] | 707 | return 0; |
Alexandre Julliard | bd34d4f | 1995-06-20 19:08:12 +0000 | [diff] [blame] | 708 | } |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 709 | |
Gerard Patel | 78f52b5 | 2000-05-31 19:23:20 +0000 | [diff] [blame] | 710 | WIN_FixCoordinates(cs, &sw); /* fix default coordinates */ |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 711 | |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 712 | /* Create the window structure */ |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 713 | |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 714 | if (!(hwnd = USER_HEAP_ALLOC( sizeof(*wndPtr) + wndExtra - sizeof(wndPtr->wExtra) ))) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 715 | { |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 716 | TRACE("out of memory\n" ); |
Alexandre Julliard | bd34d4f | 1995-06-20 19:08:12 +0000 | [diff] [blame] | 717 | return 0; |
| 718 | } |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 719 | |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 720 | /* Fill the window structure */ |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 721 | |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 722 | wndPtr = WIN_LockWndPtr((WND *) USER_HEAP_LIN_ADDR( hwnd )); |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 723 | wndPtr->next = NULL; |
| 724 | wndPtr->child = NULL; |
| 725 | |
Alexandre Julliard | 3db94ef | 1997-09-28 17:43:24 +0000 | [diff] [blame] | 726 | if ((cs->style & WS_CHILD) && cs->hwndParent) |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 727 | { |
| 728 | wndPtr->parent = WIN_FindWndPtr( cs->hwndParent ); |
| 729 | wndPtr->owner = NULL; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 730 | WIN_ReleaseWndPtr(wndPtr->parent); |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 731 | } |
| 732 | else |
| 733 | { |
| 734 | wndPtr->parent = pWndDesktop; |
| 735 | if (!cs->hwndParent || (cs->hwndParent == pWndDesktop->hwndSelf)) |
| 736 | wndPtr->owner = NULL; |
| 737 | else |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 738 | { |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 739 | WND *tmpWnd = WIN_FindWndPtr(cs->hwndParent); |
| 740 | wndPtr->owner = WIN_GetTopParentPtr(tmpWnd); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 741 | WIN_ReleaseWndPtr(wndPtr->owner); |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 742 | WIN_ReleaseWndPtr(tmpWnd); |
Slava Monich | a27807d | 1999-06-05 11:46:35 +0000 | [diff] [blame] | 743 | } |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 744 | } |
Slava Monich | a27807d | 1999-06-05 11:46:35 +0000 | [diff] [blame] | 745 | |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 746 | |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 747 | wndPtr->class = classPtr; |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 748 | wndPtr->winproc = winproc; |
Alexandre Julliard | bd34d4f | 1995-06-20 19:08:12 +0000 | [diff] [blame] | 749 | wndPtr->dwMagic = WND_MAGIC; |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 750 | wndPtr->hwndSelf = hwnd; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 751 | wndPtr->hInstance = cs->hInstance; |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 752 | wndPtr->text = NULL; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 753 | wndPtr->hmemTaskQ = GetFastQueue16(); |
Alexandre Julliard | bd34d4f | 1995-06-20 19:08:12 +0000 | [diff] [blame] | 754 | wndPtr->hrgnUpdate = 0; |
Huw D M Davies | a14ca86 | 2000-07-29 11:31:29 +0000 | [diff] [blame] | 755 | wndPtr->hrgnWnd = 0; |
Alexandre Julliard | bd34d4f | 1995-06-20 19:08:12 +0000 | [diff] [blame] | 756 | wndPtr->hwndLastActive = hwnd; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 757 | wndPtr->dwStyle = cs->style & ~WS_VISIBLE; |
| 758 | wndPtr->dwExStyle = cs->dwExStyle; |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 759 | wndPtr->clsStyle = clsStyle; |
Alexandre Julliard | bd34d4f | 1995-06-20 19:08:12 +0000 | [diff] [blame] | 760 | wndPtr->wIDmenu = 0; |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 761 | wndPtr->helpContext = 0; |
Dmitry Timoshkov | 5956b98 | 2000-11-28 23:53:08 +0000 | [diff] [blame] | 762 | wndPtr->flags = (type == WIN_PROC_16) ? 0 : WIN_ISWIN32; |
Alexandre Julliard | ca22b33 | 1996-07-12 19:02:39 +0000 | [diff] [blame] | 763 | wndPtr->pVScroll = NULL; |
| 764 | wndPtr->pHScroll = NULL; |
Alexandre Julliard | ac9c9b0 | 1996-07-28 18:50:11 +0000 | [diff] [blame] | 765 | wndPtr->pProp = NULL; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 766 | wndPtr->userdata = 0; |
Alexandre Julliard | 7ff1c41 | 1997-05-25 13:58:18 +0000 | [diff] [blame] | 767 | wndPtr->hSysMenu = (wndPtr->dwStyle & WS_SYSMENU) |
| 768 | ? MENU_GetSysMenu( hwnd, 0 ) : 0; |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 769 | wndPtr->cbWndExtra = wndExtra; |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 770 | wndPtr->irefCount = 1; |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 771 | |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 772 | if (wndExtra) memset( wndPtr->wExtra, 0, wndExtra); |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 773 | |
| 774 | /* Call the WH_CBT hook */ |
| 775 | |
NF Stevens | 181fa7c | 1998-12-14 14:37:06 +0000 | [diff] [blame] | 776 | hwndLinkAfter = ((cs->style & (WS_CHILD|WS_MAXIMIZE)) == WS_CHILD) |
| 777 | ? HWND_BOTTOM : HWND_TOP; |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 778 | |
Alexandre Julliard | 7e6ae4b | 1996-12-08 19:25:27 +0000 | [diff] [blame] | 779 | if (HOOK_IsHooked( WH_CBT )) |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 780 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 781 | CBT_CREATEWNDA cbtc; |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 782 | LRESULT ret; |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 783 | |
Alexandre Julliard | 7e6ae4b | 1996-12-08 19:25:27 +0000 | [diff] [blame] | 784 | cbtc.lpcs = cs; |
| 785 | cbtc.hwndInsertAfter = hwndLinkAfter; |
Dmitry Timoshkov | 5956b98 | 2000-11-28 23:53:08 +0000 | [diff] [blame] | 786 | ret = (type == WIN_PROC_32W) ? HOOK_CallHooksW(WH_CBT, HCBT_CREATEWND, hwnd, (LPARAM)&cbtc) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 787 | : HOOK_CallHooksA(WH_CBT, HCBT_CREATEWND, hwnd, (LPARAM)&cbtc); |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 788 | if (ret) |
Alexandre Julliard | 7e6ae4b | 1996-12-08 19:25:27 +0000 | [diff] [blame] | 789 | { |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 790 | TRACE("CBT-hook returned 0\n"); |
Alexandre Julliard | 7e6ae4b | 1996-12-08 19:25:27 +0000 | [diff] [blame] | 791 | USER_HEAP_FREE( hwnd ); |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 792 | CLASS_RemoveWindow( classPtr ); |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 793 | hwnd = 0; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 794 | goto end; |
Alexandre Julliard | 7e6ae4b | 1996-12-08 19:25:27 +0000 | [diff] [blame] | 795 | } |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 796 | } |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 797 | |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 798 | /* Correct the window style */ |
| 799 | |
Alex Korobka | 44a1b59 | 1999-04-01 12:03:52 +0000 | [diff] [blame] | 800 | if (!(cs->style & WS_CHILD)) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 801 | { |
Alex Korobka | 44a1b59 | 1999-04-01 12:03:52 +0000 | [diff] [blame] | 802 | wndPtr->dwStyle |= WS_CLIPSIBLINGS; |
| 803 | if (!(cs->style & WS_POPUP)) |
| 804 | { |
| 805 | wndPtr->dwStyle |= WS_CAPTION; |
| 806 | wndPtr->flags |= WIN_NEED_SIZE; |
| 807 | } |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 808 | } |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 809 | |
| 810 | /* Get class or window DC if needed */ |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 811 | |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 812 | if (clsStyle & CS_OWNDC) wndPtr->dce = DCE_AllocDCE(hwnd,DCE_WINDOW_DC); |
| 813 | else if (clsStyle & CS_CLASSDC) wndPtr->dce = dce; |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 814 | else wndPtr->dce = NULL; |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 815 | |
Alexandre Julliard | 5e9dab5 | 2000-06-07 02:03:19 +0000 | [diff] [blame] | 816 | /* Initialize the dimensions before sending WM_GETMINMAXINFO */ |
| 817 | |
| 818 | wndPtr->rectWindow.left = cs->x; |
| 819 | wndPtr->rectWindow.top = cs->y; |
| 820 | wndPtr->rectWindow.right = cs->x + cs->cx; |
| 821 | wndPtr->rectWindow.bottom = cs->y + cs->cy; |
| 822 | wndPtr->rectClient = wndPtr->rectWindow; |
| 823 | |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 824 | /* Send the WM_GETMINMAXINFO message and fix the size if needed */ |
Alexandre Julliard | 988ca97 | 1994-06-21 16:15:21 +0000 | [diff] [blame] | 825 | |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 826 | if ((cs->style & WS_THICKFRAME) || !(cs->style & (WS_POPUP | WS_CHILD))) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 827 | { |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 828 | WINPOS_GetMinMaxInfo( wndPtr, &maxSize, &maxPos, &minTrack, &maxTrack); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 829 | if (maxSize.x < cs->cx) cs->cx = maxSize.x; |
| 830 | if (maxSize.y < cs->cy) cs->cy = maxSize.y; |
Alexandre Julliard | ac9c9b0 | 1996-07-28 18:50:11 +0000 | [diff] [blame] | 831 | if (cs->cx < minTrack.x ) cs->cx = minTrack.x; |
| 832 | if (cs->cy < minTrack.y ) cs->cy = minTrack.y; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 833 | } |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 834 | |
Lawson Whitney | 68dd679 | 2000-06-25 12:53:27 +0000 | [diff] [blame] | 835 | if (cs->cx < 0) cs->cx = 0; |
| 836 | if (cs->cy < 0) cs->cy = 0; |
Alexandre Julliard | bd34d4f | 1995-06-20 19:08:12 +0000 | [diff] [blame] | 837 | |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 838 | wndPtr->rectWindow.left = cs->x; |
| 839 | wndPtr->rectWindow.top = cs->y; |
| 840 | wndPtr->rectWindow.right = cs->x + cs->cx; |
| 841 | wndPtr->rectWindow.bottom = cs->y + cs->cy; |
Alexandre Julliard | bd34d4f | 1995-06-20 19:08:12 +0000 | [diff] [blame] | 842 | wndPtr->rectClient = wndPtr->rectWindow; |
Alexandre Julliard | 940d58c | 1994-09-16 09:24:37 +0000 | [diff] [blame] | 843 | |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 844 | /* Set the window menu */ |
| 845 | |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 846 | if ((wndPtr->dwStyle & (WS_CAPTION | WS_CHILD)) == WS_CAPTION ) |
Alexandre Julliard | e2abbb1 | 1995-03-19 17:39:39 +0000 | [diff] [blame] | 847 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 848 | if (cs->hMenu) SetMenu(hwnd, cs->hMenu); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 849 | else |
| 850 | { |
Alexandre Julliard | ac7efef | 2000-11-27 21:54:01 +0000 | [diff] [blame] | 851 | LPCSTR menuName = (LPCSTR)GetClassLongA( hwnd, GCL_MENUNAME ); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 852 | if (menuName) |
| 853 | { |
Ulrich Weigand | 7df1fbb | 1998-11-01 18:01:53 +0000 | [diff] [blame] | 854 | if (HIWORD(cs->hInstance)) |
Alexandre Julliard | ac7efef | 2000-11-27 21:54:01 +0000 | [diff] [blame] | 855 | cs->hMenu = LoadMenuA(cs->hInstance,menuName); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 856 | else |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 857 | cs->hMenu = LoadMenu16(cs->hInstance,menuName); |
| 858 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 859 | if (cs->hMenu) SetMenu( hwnd, cs->hMenu ); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 860 | } |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 861 | } |
Alexandre Julliard | e2abbb1 | 1995-03-19 17:39:39 +0000 | [diff] [blame] | 862 | } |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 863 | else wndPtr->wIDmenu = (UINT)cs->hMenu; |
Alexandre Julliard | 490a27e | 1994-06-08 13:57:50 +0000 | [diff] [blame] | 864 | |
Gerard Patel | ad36303 | 2001-06-06 21:26:50 +0000 | [diff] [blame] | 865 | if (!USER_Driver.pCreateWindow( wndPtr->hwndSelf, cs, unicode)) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 866 | { |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 867 | WARN("aborted by WM_xxCREATE!\n"); |
| 868 | WIN_ReleaseWndPtr(WIN_DestroyWindow( wndPtr )); |
| 869 | CLASS_RemoveWindow( classPtr ); |
| 870 | WIN_ReleaseWndPtr(wndPtr); |
| 871 | return 0; |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 872 | } |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 873 | |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 874 | if( (wndPtr->dwStyle & WS_CHILD) && !(wndPtr->dwExStyle & WS_EX_NOPARENTNOTIFY) ) |
| 875 | { |
| 876 | /* Notify the parent window only */ |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 877 | |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 878 | SendMessageA( wndPtr->parent->hwndSelf, WM_PARENTNOTIFY, |
| 879 | MAKEWPARAM(WM_CREATE, wndPtr->wIDmenu), (LPARAM)hwnd ); |
| 880 | if( !IsWindow(hwnd) ) |
| 881 | { |
| 882 | hwnd = 0; |
| 883 | goto end; |
| 884 | } |
| 885 | } |
| 886 | |
| 887 | if (cs->style & WS_VISIBLE) |
| 888 | { |
| 889 | /* in case WS_VISIBLE got set in the meantime */ |
| 890 | wndPtr->dwStyle &= ~WS_VISIBLE; |
| 891 | ShowWindow( hwnd, sw ); |
| 892 | } |
| 893 | |
| 894 | /* Call WH_SHELL hook */ |
| 895 | |
| 896 | if (!(wndPtr->dwStyle & WS_CHILD) && !wndPtr->owner) |
| 897 | HOOK_CallHooksA( WH_SHELL, HSHELL_WINDOWCREATED, hwnd, 0 ); |
| 898 | |
| 899 | TRACE("created window %04x\n", hwnd); |
| 900 | end: |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 901 | WIN_ReleaseWndPtr(wndPtr); |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 902 | return hwnd; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 903 | } |
| 904 | |
| 905 | |
| 906 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 907 | * CreateWindow (USER.41) |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 908 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 909 | HWND16 WINAPI CreateWindow16( LPCSTR className, LPCSTR windowName, |
| 910 | DWORD style, INT16 x, INT16 y, INT16 width, |
| 911 | INT16 height, HWND16 parent, HMENU16 menu, |
| 912 | HINSTANCE16 instance, LPVOID data ) |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 913 | { |
| 914 | return CreateWindowEx16( 0, className, windowName, style, |
| 915 | x, y, width, height, parent, menu, instance, data ); |
| 916 | } |
| 917 | |
| 918 | |
| 919 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 920 | * CreateWindowEx (USER.452) |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 921 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 922 | HWND16 WINAPI CreateWindowEx16( DWORD exStyle, LPCSTR className, |
| 923 | LPCSTR windowName, DWORD style, INT16 x, |
| 924 | INT16 y, INT16 width, INT16 height, |
| 925 | HWND16 parent, HMENU16 menu, |
| 926 | HINSTANCE16 instance, LPVOID data ) |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 927 | { |
| 928 | ATOM classAtom; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 929 | CREATESTRUCTA cs; |
Alexandre Julliard | f1f6831 | 2000-01-01 22:22:21 +0000 | [diff] [blame] | 930 | char buffer[256]; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 931 | |
| 932 | /* Find the class atom */ |
| 933 | |
Gerard Patel | 6fdb5dd | 2000-02-16 21:23:24 +0000 | [diff] [blame] | 934 | if (HIWORD(className)) |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 935 | { |
Gerard Patel | 6fdb5dd | 2000-02-16 21:23:24 +0000 | [diff] [blame] | 936 | if (!(classAtom = GlobalFindAtomA( className ))) |
| 937 | { |
| 938 | ERR( "bad class name %s\n", debugres_a(className) ); |
| 939 | return 0; |
| 940 | } |
| 941 | } |
| 942 | else |
| 943 | { |
| 944 | classAtom = LOWORD(className); |
| 945 | if (!GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) )) |
| 946 | { |
| 947 | ERR( "bad atom %x\n", classAtom); |
| 948 | return 0; |
| 949 | } |
| 950 | className = buffer; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 951 | } |
| 952 | |
| 953 | /* Fix the coordinates */ |
| 954 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 955 | cs.x = (x == CW_USEDEFAULT16) ? CW_USEDEFAULT : (INT)x; |
| 956 | cs.y = (y == CW_USEDEFAULT16) ? CW_USEDEFAULT : (INT)y; |
| 957 | cs.cx = (width == CW_USEDEFAULT16) ? CW_USEDEFAULT : (INT)width; |
| 958 | cs.cy = (height == CW_USEDEFAULT16) ? CW_USEDEFAULT : (INT)height; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 959 | |
| 960 | /* Create the window */ |
| 961 | |
| 962 | cs.lpCreateParams = data; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 963 | cs.hInstance = (HINSTANCE)instance; |
| 964 | cs.hMenu = (HMENU)menu; |
| 965 | cs.hwndParent = (HWND)parent; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 966 | cs.style = style; |
| 967 | cs.lpszName = windowName; |
| 968 | cs.lpszClass = className; |
| 969 | cs.dwExStyle = exStyle; |
Alexandre Julliard | f1f6831 | 2000-01-01 22:22:21 +0000 | [diff] [blame] | 970 | |
Dmitry Timoshkov | 5956b98 | 2000-11-28 23:53:08 +0000 | [diff] [blame] | 971 | return WIN_CreateWindowEx( &cs, classAtom, WIN_PROC_16 ); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 972 | } |
| 973 | |
| 974 | |
| 975 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 976 | * CreateWindowExA (USER32.@) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 977 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 978 | HWND WINAPI CreateWindowExA( DWORD exStyle, LPCSTR className, |
| 979 | LPCSTR windowName, DWORD style, INT x, |
| 980 | INT y, INT width, INT height, |
| 981 | HWND parent, HMENU menu, |
| 982 | HINSTANCE instance, LPVOID data ) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 983 | { |
| 984 | ATOM classAtom; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 985 | CREATESTRUCTA cs; |
Alexandre Julliard | f1f6831 | 2000-01-01 22:22:21 +0000 | [diff] [blame] | 986 | char buffer[256]; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 987 | |
Rein Klazes | d4a2cee | 1999-10-23 13:57:36 +0000 | [diff] [blame] | 988 | if(!instance) |
| 989 | instance=GetModuleHandleA(NULL); |
| 990 | |
Rein Klazes | 5c6fc1b | 1998-11-01 14:50:06 +0000 | [diff] [blame] | 991 | if(exStyle & WS_EX_MDICHILD) |
Dmitry Timoshkov | 91adf0a | 2001-02-12 03:40:41 +0000 | [diff] [blame] | 992 | return CreateMDIWindowA(className, windowName, style, x, y, width, height, parent, instance, (LPARAM)data); |
Gerard Patel | 6fdb5dd | 2000-02-16 21:23:24 +0000 | [diff] [blame] | 993 | |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 994 | /* Find the class atom */ |
| 995 | |
Gerard Patel | 6fdb5dd | 2000-02-16 21:23:24 +0000 | [diff] [blame] | 996 | if (HIWORD(className)) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 997 | { |
Gerard Patel | 6fdb5dd | 2000-02-16 21:23:24 +0000 | [diff] [blame] | 998 | if (!(classAtom = GlobalFindAtomA( className ))) |
| 999 | { |
| 1000 | ERR( "bad class name %s\n", debugres_a(className) ); |
| 1001 | return 0; |
| 1002 | } |
| 1003 | } |
| 1004 | else |
| 1005 | { |
| 1006 | classAtom = LOWORD(className); |
| 1007 | if (!GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) )) |
| 1008 | { |
| 1009 | ERR( "bad atom %x\n", classAtom); |
| 1010 | return 0; |
| 1011 | } |
| 1012 | className = buffer; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1013 | } |
| 1014 | |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1015 | /* Create the window */ |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1016 | |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1017 | cs.lpCreateParams = data; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1018 | cs.hInstance = instance; |
| 1019 | cs.hMenu = menu; |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1020 | cs.hwndParent = parent; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1021 | cs.x = x; |
| 1022 | cs.y = y; |
| 1023 | cs.cx = width; |
| 1024 | cs.cy = height; |
| 1025 | cs.style = style; |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1026 | cs.lpszName = windowName; |
| 1027 | cs.lpszClass = className; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1028 | cs.dwExStyle = exStyle; |
Alexandre Julliard | f1f6831 | 2000-01-01 22:22:21 +0000 | [diff] [blame] | 1029 | |
Dmitry Timoshkov | 5956b98 | 2000-11-28 23:53:08 +0000 | [diff] [blame] | 1030 | return WIN_CreateWindowEx( &cs, classAtom, WIN_PROC_32A ); |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1031 | } |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1032 | |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1033 | |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1034 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1035 | * CreateWindowExW (USER32.@) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1036 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1037 | HWND WINAPI CreateWindowExW( DWORD exStyle, LPCWSTR className, |
| 1038 | LPCWSTR windowName, DWORD style, INT x, |
| 1039 | INT y, INT width, INT height, |
| 1040 | HWND parent, HMENU menu, |
| 1041 | HINSTANCE instance, LPVOID data ) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1042 | { |
| 1043 | ATOM classAtom; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1044 | CREATESTRUCTW cs; |
Alexandre Julliard | f1f6831 | 2000-01-01 22:22:21 +0000 | [diff] [blame] | 1045 | WCHAR buffer[256]; |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1046 | |
Rein Klazes | d4a2cee | 1999-10-23 13:57:36 +0000 | [diff] [blame] | 1047 | if(!instance) |
| 1048 | instance=GetModuleHandleA(NULL); |
| 1049 | |
Rein Klazes | 5c6fc1b | 1998-11-01 14:50:06 +0000 | [diff] [blame] | 1050 | if(exStyle & WS_EX_MDICHILD) |
Dmitry Timoshkov | 91adf0a | 2001-02-12 03:40:41 +0000 | [diff] [blame] | 1051 | return CreateMDIWindowW(className, windowName, style, x, y, width, height, parent, instance, (LPARAM)data); |
Rein Klazes | 5c6fc1b | 1998-11-01 14:50:06 +0000 | [diff] [blame] | 1052 | |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1053 | /* Find the class atom */ |
| 1054 | |
Gerard Patel | 6fdb5dd | 2000-02-16 21:23:24 +0000 | [diff] [blame] | 1055 | if (HIWORD(className)) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1056 | { |
Gerard Patel | 6fdb5dd | 2000-02-16 21:23:24 +0000 | [diff] [blame] | 1057 | if (!(classAtom = GlobalFindAtomW( className ))) |
| 1058 | { |
| 1059 | ERR( "bad class name %s\n", debugres_w(className) ); |
| 1060 | return 0; |
| 1061 | } |
| 1062 | } |
| 1063 | else |
| 1064 | { |
| 1065 | classAtom = LOWORD(className); |
| 1066 | if (!GlobalGetAtomNameW( classAtom, buffer, sizeof(buffer)/sizeof(WCHAR) )) |
| 1067 | { |
| 1068 | ERR( "bad atom %x\n", classAtom); |
| 1069 | return 0; |
| 1070 | } |
| 1071 | className = buffer; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1072 | } |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1073 | |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1074 | /* Create the window */ |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1075 | |
| 1076 | cs.lpCreateParams = data; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1077 | cs.hInstance = instance; |
| 1078 | cs.hMenu = menu; |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1079 | cs.hwndParent = parent; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1080 | cs.x = x; |
| 1081 | cs.y = y; |
| 1082 | cs.cx = width; |
| 1083 | cs.cy = height; |
| 1084 | cs.style = style; |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1085 | cs.lpszName = windowName; |
| 1086 | cs.lpszClass = className; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1087 | cs.dwExStyle = exStyle; |
Alexandre Julliard | f1f6831 | 2000-01-01 22:22:21 +0000 | [diff] [blame] | 1088 | |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame] | 1089 | /* Note: we rely on the fact that CREATESTRUCTA and */ |
| 1090 | /* CREATESTRUCTW have the same layout. */ |
Dmitry Timoshkov | 5956b98 | 2000-11-28 23:53:08 +0000 | [diff] [blame] | 1091 | return WIN_CreateWindowEx( (CREATESTRUCTA *)&cs, classAtom, WIN_PROC_32W ); |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 1092 | } |
| 1093 | |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 1094 | /*********************************************************************** |
| 1095 | * WIN_SendDestroyMsg |
| 1096 | */ |
| 1097 | static void WIN_SendDestroyMsg( WND* pWnd ) |
| 1098 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1099 | if( CARET_GetHwnd() == pWnd->hwndSelf ) DestroyCaret(); |
Alexandre Julliard | 42d20f9 | 2000-08-10 01:16:19 +0000 | [diff] [blame] | 1100 | USER_Driver.pResetSelectionOwner( pWnd, TRUE ); |
Francis Beaudet | eb6a9f0 | 1999-03-17 15:17:48 +0000 | [diff] [blame] | 1101 | |
| 1102 | /* |
| 1103 | * Send the WM_DESTROY to the window. |
| 1104 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1105 | SendMessageA( pWnd->hwndSelf, WM_DESTROY, 0, 0); |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 1106 | |
Francis Beaudet | eb6a9f0 | 1999-03-17 15:17:48 +0000 | [diff] [blame] | 1107 | /* |
| 1108 | * This WM_DESTROY message can trigger re-entrant calls to DestroyWindow |
| 1109 | * make sure that the window still exists when we come back. |
| 1110 | */ |
| 1111 | if (IsWindow(pWnd->hwndSelf)) |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 1112 | { |
Francis Beaudet | eb6a9f0 | 1999-03-17 15:17:48 +0000 | [diff] [blame] | 1113 | HWND* pWndArray = NULL; |
| 1114 | WND* pChild = NULL; |
| 1115 | int nKidCount = 0; |
| 1116 | |
| 1117 | /* |
| 1118 | * Now, if the window has kids, we have to send WM_DESTROY messages |
| 1119 | * recursively to it's kids. It seems that those calls can also |
| 1120 | * trigger re-entrant calls to DestroyWindow for the kids so we must |
| 1121 | * protect against corruption of the list of siblings. We first build |
| 1122 | * a list of HWNDs representing all the kids. |
| 1123 | */ |
| 1124 | pChild = WIN_LockWndPtr(pWnd->child); |
| 1125 | while( pChild ) |
| 1126 | { |
| 1127 | nKidCount++; |
| 1128 | WIN_UpdateWndPtr(&pChild,pChild->next); |
| 1129 | } |
| 1130 | |
| 1131 | /* |
| 1132 | * If there are no kids, we're done. |
| 1133 | */ |
| 1134 | if (nKidCount==0) |
| 1135 | return; |
| 1136 | |
| 1137 | pWndArray = HeapAlloc(GetProcessHeap(), 0, nKidCount*sizeof(HWND)); |
| 1138 | |
| 1139 | /* |
| 1140 | * Sanity check |
| 1141 | */ |
| 1142 | if (pWndArray==NULL) |
| 1143 | return; |
| 1144 | |
| 1145 | /* |
| 1146 | * Now, enumerate all the kids in a list, since we wait to make the SendMessage |
| 1147 | * call, our linked list of siblings should be safe. |
| 1148 | */ |
| 1149 | nKidCount = 0; |
| 1150 | pChild = WIN_LockWndPtr(pWnd->child); |
| 1151 | while( pChild ) |
| 1152 | { |
| 1153 | pWndArray[nKidCount] = pChild->hwndSelf; |
| 1154 | nKidCount++; |
| 1155 | WIN_UpdateWndPtr(&pChild,pChild->next); |
| 1156 | } |
| 1157 | |
| 1158 | /* |
| 1159 | * Now that we have a list, go through that list again and send the destroy |
| 1160 | * message to those windows. We are using the HWND to retrieve the |
| 1161 | * WND pointer so we are effectively checking that all the kid windows are |
| 1162 | * still valid before sending the message. |
| 1163 | */ |
| 1164 | while (nKidCount>0) |
| 1165 | { |
Pavel Roskin | c501207 | 1999-03-19 16:59:18 +0000 | [diff] [blame] | 1166 | pChild = WIN_FindWndPtr(pWndArray[--nKidCount]); |
Francis Beaudet | eb6a9f0 | 1999-03-17 15:17:48 +0000 | [diff] [blame] | 1167 | |
| 1168 | if (pChild!=NULL) |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 1169 | { |
Francis Beaudet | eb6a9f0 | 1999-03-17 15:17:48 +0000 | [diff] [blame] | 1170 | WIN_SendDestroyMsg( pChild ); |
| 1171 | WIN_ReleaseWndPtr(pChild); |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 1172 | } |
Francis Beaudet | eb6a9f0 | 1999-03-17 15:17:48 +0000 | [diff] [blame] | 1173 | } |
| 1174 | |
| 1175 | /* |
| 1176 | * Cleanup |
| 1177 | */ |
| 1178 | HeapFree(GetProcessHeap(), 0, pWndArray); |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 1179 | } |
| 1180 | else |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 1181 | WARN("\tdestroyed itself while in WM_DESTROY!\n"); |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 1182 | } |
| 1183 | |
| 1184 | |
| 1185 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1186 | * DestroyWindow (USER.53) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 1187 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 1188 | BOOL16 WINAPI DestroyWindow16( HWND16 hwnd ) |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 1189 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1190 | return DestroyWindow(hwnd); |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 1191 | } |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 1192 | |
| 1193 | |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 1194 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1195 | * DestroyWindow (USER32.@) |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 1196 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1197 | BOOL WINAPI DestroyWindow( HWND hwnd ) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 1198 | { |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1199 | WND * wndPtr; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1200 | BOOL retvalue; |
Alexandre Julliard | 1f029ea | 2000-11-02 20:08:59 +0000 | [diff] [blame] | 1201 | HWND h; |
| 1202 | BOOL bFocusSet = FALSE; |
Alexandre Julliard | 3a405ba | 1994-10-30 16:25:19 +0000 | [diff] [blame] | 1203 | |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 1204 | TRACE("(%04x)\n", hwnd); |
Alexandre Julliard | 1f029ea | 2000-11-02 20:08:59 +0000 | [diff] [blame] | 1205 | |
| 1206 | /* Initialization */ |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 1207 | |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1208 | if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return FALSE; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1209 | if (wndPtr == pWndDesktop) |
| 1210 | { |
Andreas Mohr | 1c20b39 | 2000-02-20 19:17:35 +0000 | [diff] [blame] | 1211 | retvalue = FALSE; /* Can't destroy desktop */ |
| 1212 | goto end; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1213 | } |
Alexandre Julliard | 5819953 | 1994-04-21 01:20:00 +0000 | [diff] [blame] | 1214 | |
Alexandre Julliard | 1f029ea | 2000-11-02 20:08:59 +0000 | [diff] [blame] | 1215 | /* Look whether the focus is within the tree of windows we will |
| 1216 | * be destroying. |
| 1217 | */ |
| 1218 | h = GetFocus16(); |
| 1219 | while (h && (GetWindowLongA(h,GWL_STYLE) & WS_CHILD)) |
| 1220 | { |
| 1221 | if (h == hwnd) |
| 1222 | { |
Alexandre Julliard | f88e5aa | 2001-03-21 23:55:36 +0000 | [diff] [blame] | 1223 | SetFocus(GetParent(h)); |
Alexandre Julliard | 1f029ea | 2000-11-02 20:08:59 +0000 | [diff] [blame] | 1224 | bFocusSet = TRUE; |
| 1225 | break; |
| 1226 | } |
Alexandre Julliard | f88e5aa | 2001-03-21 23:55:36 +0000 | [diff] [blame] | 1227 | h = GetParent(h); |
Alexandre Julliard | 1f029ea | 2000-11-02 20:08:59 +0000 | [diff] [blame] | 1228 | } |
| 1229 | /* If the focus is on the window we will destroy and it has no parent, |
| 1230 | * set the focus to 0. |
| 1231 | */ |
| 1232 | if (! bFocusSet && (h == hwnd)) |
| 1233 | { |
| 1234 | if (!(GetWindowLongA(h,GWL_STYLE) & WS_CHILD)) |
| 1235 | SetFocus(0); |
| 1236 | } |
| 1237 | |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 1238 | /* Call hooks */ |
| 1239 | |
Alexandre Julliard | 32ee168 | 2001-05-09 17:33:00 +0000 | [diff] [blame] | 1240 | if( HOOK_CallHooksA( WH_CBT, HCBT_DESTROYWND, hwnd, 0L) ) |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1241 | { |
| 1242 | retvalue = FALSE; |
| 1243 | goto end; |
| 1244 | } |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1245 | |
| 1246 | if (!(wndPtr->dwStyle & WS_CHILD) && !wndPtr->owner) |
| 1247 | { |
Alexandre Julliard | 32ee168 | 2001-05-09 17:33:00 +0000 | [diff] [blame] | 1248 | HOOK_CallHooksA( WH_SHELL, HSHELL_WINDOWDESTROYED, hwnd, 0L ); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1249 | /* FIXME: clean up palette - see "Internals" p.352 */ |
| 1250 | } |
| 1251 | |
Alexandre Julliard | 7ff1c41 | 1997-05-25 13:58:18 +0000 | [diff] [blame] | 1252 | if( !QUEUE_IsExitingQueue(wndPtr->hmemTaskQ) ) |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 1253 | if( wndPtr->dwStyle & WS_CHILD && !(wndPtr->dwExStyle & WS_EX_NOPARENTNOTIFY) ) |
| 1254 | { |
| 1255 | /* Notify the parent window only */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1256 | SendMessageA( wndPtr->parent->hwndSelf, WM_PARENTNOTIFY, |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 1257 | MAKEWPARAM(WM_DESTROY, wndPtr->wIDmenu), (LPARAM)hwnd ); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1258 | if( !IsWindow(hwnd) ) |
| 1259 | { |
| 1260 | retvalue = TRUE; |
| 1261 | goto end; |
| 1262 | } |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 1263 | } |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 1264 | |
Alexandre Julliard | 42d20f9 | 2000-08-10 01:16:19 +0000 | [diff] [blame] | 1265 | USER_Driver.pResetSelectionOwner( wndPtr, FALSE ); /* before the window is unmapped */ |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 1266 | |
Alexandre Julliard | 5819953 | 1994-04-21 01:20:00 +0000 | [diff] [blame] | 1267 | /* Hide the window */ |
| 1268 | |
| 1269 | if (wndPtr->dwStyle & WS_VISIBLE) |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 1270 | { |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 1271 | ShowWindow( hwnd, SW_HIDE ); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1272 | if (!IsWindow(hwnd)) |
| 1273 | { |
| 1274 | retvalue = TRUE; |
| 1275 | goto end; |
| 1276 | } |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 1277 | } |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1278 | |
Alexandre Julliard | 22945d5 | 1995-03-02 17:44:29 +0000 | [diff] [blame] | 1279 | /* Recursively destroy owned windows */ |
| 1280 | |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 1281 | if( !(wndPtr->dwStyle & WS_CHILD) ) |
Alexandre Julliard | 22945d5 | 1995-03-02 17:44:29 +0000 | [diff] [blame] | 1282 | { |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 1283 | for (;;) |
| 1284 | { |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1285 | WND *siblingPtr = WIN_LockWndPtr(wndPtr->parent->child); /* First sibling */ |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 1286 | while (siblingPtr) |
Alexandre Julliard | 22945d5 | 1995-03-02 17:44:29 +0000 | [diff] [blame] | 1287 | { |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 1288 | if (siblingPtr->owner == wndPtr) |
Patrik Stridvall | ea58472 | 1998-11-01 16:22:07 +0000 | [diff] [blame] | 1289 | { |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 1290 | if (siblingPtr->hmemTaskQ == wndPtr->hmemTaskQ) |
| 1291 | break; |
| 1292 | else |
| 1293 | siblingPtr->owner = NULL; |
Patrik Stridvall | ea58472 | 1998-11-01 16:22:07 +0000 | [diff] [blame] | 1294 | } |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1295 | WIN_UpdateWndPtr(&siblingPtr,siblingPtr->next); |
Alexandre Julliard | 22945d5 | 1995-03-02 17:44:29 +0000 | [diff] [blame] | 1296 | } |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 1297 | if (siblingPtr) |
| 1298 | { |
| 1299 | DestroyWindow( siblingPtr->hwndSelf ); |
| 1300 | WIN_ReleaseWndPtr(siblingPtr); |
| 1301 | } |
Alexandre Julliard | 22945d5 | 1995-03-02 17:44:29 +0000 | [diff] [blame] | 1302 | else break; |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 1303 | } |
| 1304 | |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 1305 | WINPOS_ActivateOtherWindow(wndPtr); |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 1306 | |
| 1307 | if( wndPtr->owner && |
| 1308 | wndPtr->owner->hwndLastActive == wndPtr->hwndSelf ) |
| 1309 | wndPtr->owner->hwndLastActive = wndPtr->owner->hwndSelf; |
Alexandre Julliard | 22945d5 | 1995-03-02 17:44:29 +0000 | [diff] [blame] | 1310 | } |
| 1311 | |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 1312 | /* Send destroy messages */ |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1313 | |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 1314 | WIN_SendDestroyMsg( wndPtr ); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1315 | if (!IsWindow(hwnd)) |
| 1316 | { |
| 1317 | retvalue = TRUE; |
| 1318 | goto end; |
| 1319 | } |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 1320 | |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 1321 | /* Unlink now so we won't bother with the children later on */ |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 1322 | |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 1323 | if( wndPtr->parent ) WIN_UnlinkWindow(hwnd); |
| 1324 | |
| 1325 | /* Destroy the window storage */ |
| 1326 | |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 1327 | WIN_ReleaseWndPtr(WIN_DestroyWindow( wndPtr )); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1328 | retvalue = TRUE; |
| 1329 | end: |
| 1330 | WIN_ReleaseWndPtr(wndPtr); |
| 1331 | return retvalue; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 1332 | } |
| 1333 | |
| 1334 | |
| 1335 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1336 | * CloseWindow (USER.43) |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 1337 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 1338 | BOOL16 WINAPI CloseWindow16( HWND16 hwnd ) |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 1339 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1340 | return CloseWindow( hwnd ); |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1341 | } |
| 1342 | |
| 1343 | |
| 1344 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1345 | * CloseWindow (USER32.@) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1346 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1347 | BOOL WINAPI CloseWindow( HWND hwnd ) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1348 | { |
| 1349 | WND * wndPtr = WIN_FindWndPtr( hwnd ); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1350 | BOOL retvalue; |
| 1351 | |
| 1352 | if (!wndPtr || (wndPtr->dwStyle & WS_CHILD)) |
| 1353 | { |
| 1354 | retvalue = FALSE; |
| 1355 | goto end; |
| 1356 | } |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1357 | ShowWindow( hwnd, SW_MINIMIZE ); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1358 | retvalue = TRUE; |
| 1359 | end: |
| 1360 | WIN_ReleaseWndPtr(wndPtr); |
| 1361 | return retvalue; |
| 1362 | |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 1363 | } |
| 1364 | |
| 1365 | |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 1366 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1367 | * OpenIcon (USER.44) |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 1368 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 1369 | BOOL16 WINAPI OpenIcon16( HWND16 hwnd ) |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 1370 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1371 | return OpenIcon( hwnd ); |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1372 | } |
| 1373 | |
| 1374 | |
| 1375 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1376 | * OpenIcon (USER32.@) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1377 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1378 | BOOL WINAPI OpenIcon( HWND hwnd ) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1379 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1380 | if (!IsIconic( hwnd )) return FALSE; |
| 1381 | ShowWindow( hwnd, SW_SHOWNORMAL ); |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1382 | return TRUE; |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 1383 | } |
| 1384 | |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1385 | |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1386 | /*********************************************************************** |
| 1387 | * WIN_FindWindow |
| 1388 | * |
| 1389 | * Implementation of FindWindow() and FindWindowEx(). |
| 1390 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1391 | static HWND WIN_FindWindow( HWND parent, HWND child, ATOM className, |
Dmitry Timoshkov | 04da8b8 | 2000-07-10 12:09:31 +0000 | [diff] [blame] | 1392 | LPCWSTR title ) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1393 | { |
| 1394 | WND *pWnd; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1395 | HWND retvalue; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1396 | |
| 1397 | if (child) |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1398 | { |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1399 | if (!(pWnd = WIN_FindWndPtr( child ))) return 0; |
| 1400 | if (parent) |
| 1401 | { |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1402 | if (!pWnd->parent || (pWnd->parent->hwndSelf != parent)) |
| 1403 | { |
| 1404 | retvalue = 0; |
| 1405 | goto end; |
| 1406 | } |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1407 | } |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1408 | else if (pWnd->parent != pWndDesktop) |
| 1409 | { |
| 1410 | retvalue = 0; |
| 1411 | goto end; |
| 1412 | } |
| 1413 | WIN_UpdateWndPtr(&pWnd,pWnd->next); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1414 | } |
| 1415 | else |
| 1416 | { |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1417 | if (!(pWnd = parent ? WIN_FindWndPtr(parent) : WIN_LockWndPtr(pWndDesktop))) |
| 1418 | { |
| 1419 | retvalue = 0; |
| 1420 | goto end; |
| 1421 | } |
| 1422 | WIN_UpdateWndPtr(&pWnd,pWnd->child); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1423 | } |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1424 | if (!pWnd) |
| 1425 | { |
| 1426 | retvalue = 0; |
| 1427 | goto end; |
| 1428 | } |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1429 | |
Pavel Roskin | 598993f | 1999-03-16 09:53:10 +0000 | [diff] [blame] | 1430 | for ( ; pWnd ; WIN_UpdateWndPtr(&pWnd,pWnd->next)) |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1431 | { |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 1432 | if (className && (GetClassWord(pWnd->hwndSelf, GCW_ATOM) != className)) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1433 | continue; /* Not the right class */ |
| 1434 | |
| 1435 | /* Now check the title */ |
| 1436 | |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1437 | if (!title) |
| 1438 | { |
| 1439 | retvalue = pWnd->hwndSelf; |
| 1440 | goto end; |
Pavel Roskin | 598993f | 1999-03-16 09:53:10 +0000 | [diff] [blame] | 1441 | } |
Alexandre Julliard | cb10fda | 2000-08-06 02:41:16 +0000 | [diff] [blame] | 1442 | if (pWnd->text && !strcmpW( pWnd->text, title )) |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1443 | { |
| 1444 | retvalue = pWnd->hwndSelf; |
| 1445 | goto end; |
Pavel Roskin | 598993f | 1999-03-16 09:53:10 +0000 | [diff] [blame] | 1446 | } |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1447 | } |
| 1448 | retvalue = 0; |
Joerg Mayer | 2563b1b | 2000-12-22 20:29:41 +0000 | [diff] [blame] | 1449 | /* In this case we need to check whether other processes |
| 1450 | own a window with the given paramters on the Desktop, |
| 1451 | but we don't, so let's at least warn about it */ |
| 1452 | FIXME("Returning 0 without checking other processes\n"); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1453 | end: |
| 1454 | WIN_ReleaseWndPtr(pWnd); |
| 1455 | return retvalue; |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 1456 | } |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1457 | |
| 1458 | |
| 1459 | |
| 1460 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1461 | * FindWindow (USER.50) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1462 | */ |
Alexandre Julliard | b849d79 | 2000-02-13 13:56:13 +0000 | [diff] [blame] | 1463 | HWND16 WINAPI FindWindow16( LPCSTR className, LPCSTR title ) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1464 | { |
Alexandre Julliard | b849d79 | 2000-02-13 13:56:13 +0000 | [diff] [blame] | 1465 | return FindWindowA( className, title ); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1466 | } |
| 1467 | |
| 1468 | |
| 1469 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1470 | * FindWindowEx (USER.427) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1471 | */ |
Alexandre Julliard | b849d79 | 2000-02-13 13:56:13 +0000 | [diff] [blame] | 1472 | HWND16 WINAPI FindWindowEx16( HWND16 parent, HWND16 child, LPCSTR className, LPCSTR title ) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1473 | { |
Alexandre Julliard | b849d79 | 2000-02-13 13:56:13 +0000 | [diff] [blame] | 1474 | return FindWindowExA( parent, child, className, title ); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1475 | } |
| 1476 | |
| 1477 | |
| 1478 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1479 | * FindWindowA (USER32.@) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1480 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1481 | HWND WINAPI FindWindowA( LPCSTR className, LPCSTR title ) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1482 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1483 | HWND ret = FindWindowExA( 0, 0, className, title ); |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 1484 | if (!ret) SetLastError (ERROR_CANNOT_FIND_WND_CLASS); |
| 1485 | return ret; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1486 | } |
| 1487 | |
| 1488 | |
| 1489 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1490 | * FindWindowExA (USER32.@) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1491 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1492 | HWND WINAPI FindWindowExA( HWND parent, HWND child, |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 1493 | LPCSTR className, LPCSTR title ) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1494 | { |
Alexandre Julliard | 0e270f4 | 1996-08-24 18:26:35 +0000 | [diff] [blame] | 1495 | ATOM atom = 0; |
Dmitry Timoshkov | 04da8b8 | 2000-07-10 12:09:31 +0000 | [diff] [blame] | 1496 | LPWSTR buffer; |
| 1497 | HWND hwnd; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1498 | |
Alexandre Julliard | 0e270f4 | 1996-08-24 18:26:35 +0000 | [diff] [blame] | 1499 | if (className) |
| 1500 | { |
| 1501 | /* If the atom doesn't exist, then no class */ |
| 1502 | /* with this name exists either. */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1503 | if (!(atom = GlobalFindAtomA( className ))) |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 1504 | { |
| 1505 | SetLastError (ERROR_CANNOT_FIND_WND_CLASS); |
| 1506 | return 0; |
| 1507 | } |
Alexandre Julliard | 0e270f4 | 1996-08-24 18:26:35 +0000 | [diff] [blame] | 1508 | } |
Dmitry Timoshkov | 04da8b8 | 2000-07-10 12:09:31 +0000 | [diff] [blame] | 1509 | |
| 1510 | buffer = HEAP_strdupAtoW( GetProcessHeap(), 0, title ); |
| 1511 | hwnd = WIN_FindWindow( parent, child, atom, buffer ); |
| 1512 | HeapFree( GetProcessHeap(), 0, buffer ); |
| 1513 | return hwnd; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1514 | } |
| 1515 | |
| 1516 | |
| 1517 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1518 | * FindWindowExW (USER32.@) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1519 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1520 | HWND WINAPI FindWindowExW( HWND parent, HWND child, |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 1521 | LPCWSTR className, LPCWSTR title ) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1522 | { |
Alexandre Julliard | 0e270f4 | 1996-08-24 18:26:35 +0000 | [diff] [blame] | 1523 | ATOM atom = 0; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1524 | |
Alexandre Julliard | 0e270f4 | 1996-08-24 18:26:35 +0000 | [diff] [blame] | 1525 | if (className) |
| 1526 | { |
| 1527 | /* If the atom doesn't exist, then no class */ |
| 1528 | /* with this name exists either. */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1529 | if (!(atom = GlobalFindAtomW( className ))) |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 1530 | { |
| 1531 | SetLastError (ERROR_CANNOT_FIND_WND_CLASS); |
| 1532 | return 0; |
| 1533 | } |
Alexandre Julliard | 0e270f4 | 1996-08-24 18:26:35 +0000 | [diff] [blame] | 1534 | } |
Dmitry Timoshkov | 04da8b8 | 2000-07-10 12:09:31 +0000 | [diff] [blame] | 1535 | return WIN_FindWindow( parent, child, atom, title ); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1536 | } |
| 1537 | |
| 1538 | |
| 1539 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1540 | * FindWindowW (USER32.@) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1541 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1542 | HWND WINAPI FindWindowW( LPCWSTR className, LPCWSTR title ) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1543 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1544 | return FindWindowExW( 0, 0, className, title ); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1545 | } |
| 1546 | |
| 1547 | |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 1548 | /********************************************************************** |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 1549 | * WIN_GetDesktop |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1550 | * returns a locked pointer |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 1551 | */ |
| 1552 | WND *WIN_GetDesktop(void) |
| 1553 | { |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1554 | return WIN_LockWndPtr(pWndDesktop); |
| 1555 | } |
| 1556 | /********************************************************************** |
| 1557 | * WIN_ReleaseDesktop |
| 1558 | * unlock the desktop pointer |
| 1559 | */ |
| 1560 | void WIN_ReleaseDesktop(void) |
| 1561 | { |
| 1562 | WIN_ReleaseWndPtr(pWndDesktop); |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 1563 | } |
| 1564 | |
| 1565 | |
| 1566 | /********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1567 | * GetDesktopWindow (USER.286) |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 1568 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 1569 | HWND16 WINAPI GetDesktopWindow16(void) |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 1570 | { |
| 1571 | return (HWND16)pWndDesktop->hwndSelf; |
| 1572 | } |
| 1573 | |
| 1574 | |
| 1575 | /********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1576 | * GetDesktopWindow (USER32.@) |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 1577 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1578 | HWND WINAPI GetDesktopWindow(void) |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 1579 | { |
Uwe Bonnes | 7361916 | 1999-10-24 20:42:39 +0000 | [diff] [blame] | 1580 | if (pWndDesktop) return pWndDesktop->hwndSelf; |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 1581 | ERR( "You need the -desktop option when running with native USER\n" ); |
Uwe Bonnes | 7361916 | 1999-10-24 20:42:39 +0000 | [diff] [blame] | 1582 | ExitProcess(1); |
Huw D M Davies | 238b6d7 | 1999-10-31 01:56:51 +0000 | [diff] [blame] | 1583 | return 0; |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 1584 | } |
| 1585 | |
| 1586 | |
Alexandre Julliard | 02ed4c2 | 1996-03-02 19:34:10 +0000 | [diff] [blame] | 1587 | /********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1588 | * GetDesktopHwnd (USER.278) |
Alexandre Julliard | 02ed4c2 | 1996-03-02 19:34:10 +0000 | [diff] [blame] | 1589 | * |
| 1590 | * Exactly the same thing as GetDesktopWindow(), but not documented. |
| 1591 | * Don't ask me why... |
| 1592 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1593 | HWND16 WINAPI GetDesktopHwnd16(void) |
Alexandre Julliard | 02ed4c2 | 1996-03-02 19:34:10 +0000 | [diff] [blame] | 1594 | { |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 1595 | return (HWND16)pWndDesktop->hwndSelf; |
Alexandre Julliard | 02ed4c2 | 1996-03-02 19:34:10 +0000 | [diff] [blame] | 1596 | } |
| 1597 | |
| 1598 | |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1599 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1600 | * EnableWindow (USER.34) |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1601 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 1602 | BOOL16 WINAPI EnableWindow16( HWND16 hwnd, BOOL16 enable ) |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 1603 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1604 | return EnableWindow( hwnd, enable ); |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 1605 | } |
| 1606 | |
| 1607 | |
| 1608 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1609 | * EnableWindow (USER32.@) |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 1610 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1611 | BOOL WINAPI EnableWindow( HWND hwnd, BOOL enable ) |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1612 | { |
| 1613 | WND *wndPtr; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1614 | BOOL retvalue; |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1615 | |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 1616 | TRACE("( %x, %d )\n", hwnd, enable); |
| 1617 | |
| 1618 | if (USER_Driver.pEnableWindow) |
| 1619 | return USER_Driver.pEnableWindow( hwnd, enable ); |
| 1620 | |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1621 | if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return FALSE; |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 1622 | |
| 1623 | retvalue = ((wndPtr->dwStyle & WS_DISABLED) != 0); |
| 1624 | |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1625 | if (enable && (wndPtr->dwStyle & WS_DISABLED)) |
| 1626 | { |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 1627 | wndPtr->dwStyle &= ~WS_DISABLED; /* Enable window */ |
| 1628 | SendMessageA( hwnd, WM_ENABLE, TRUE, 0 ); |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1629 | } |
| 1630 | else if (!enable && !(wndPtr->dwStyle & WS_DISABLED)) |
| 1631 | { |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 1632 | SendMessageA( wndPtr->hwndSelf, WM_CANCELMODE, 0, 0); |
Alex Korobka | 4f1ac05 | 1999-03-28 09:37:57 +0000 | [diff] [blame] | 1633 | |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 1634 | wndPtr->dwStyle |= WS_DISABLED; /* Disable window */ |
Alex Korobka | 4f1ac05 | 1999-03-28 09:37:57 +0000 | [diff] [blame] | 1635 | |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 1636 | if (hwnd == GetFocus()) |
| 1637 | SetFocus( 0 ); /* A disabled window can't have the focus */ |
Alex Korobka | 4f1ac05 | 1999-03-28 09:37:57 +0000 | [diff] [blame] | 1638 | |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 1639 | if (hwnd == GetCapture()) |
| 1640 | ReleaseCapture(); /* A disabled window can't capture the mouse */ |
| 1641 | |
| 1642 | SendMessageA( hwnd, WM_ENABLE, FALSE, 0 ); |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1643 | } |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1644 | WIN_ReleaseWndPtr(wndPtr); |
| 1645 | return retvalue; |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1646 | } |
| 1647 | |
| 1648 | |
| 1649 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1650 | * IsWindowEnabled (USER.35) |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1651 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 1652 | BOOL16 WINAPI IsWindowEnabled16(HWND16 hWnd) |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 1653 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1654 | return IsWindowEnabled(hWnd); |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 1655 | } |
| 1656 | |
| 1657 | |
| 1658 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1659 | * IsWindowEnabled (USER32.@) |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 1660 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1661 | BOOL WINAPI IsWindowEnabled(HWND hWnd) |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1662 | { |
| 1663 | WND * wndPtr; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1664 | BOOL retvalue; |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1665 | |
| 1666 | if (!(wndPtr = WIN_FindWndPtr(hWnd))) return FALSE; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1667 | retvalue = !(wndPtr->dwStyle & WS_DISABLED); |
| 1668 | WIN_ReleaseWndPtr(wndPtr); |
| 1669 | return retvalue; |
| 1670 | |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1671 | } |
| 1672 | |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 1673 | |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1674 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1675 | * IsWindowUnicode (USER32.@) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1676 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1677 | BOOL WINAPI IsWindowUnicode( HWND hwnd ) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1678 | { |
| 1679 | WND * wndPtr; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1680 | BOOL retvalue; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1681 | |
| 1682 | if (!(wndPtr = WIN_FindWndPtr(hwnd))) return FALSE; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1683 | retvalue = (WINPROC_GetProcType( wndPtr->winproc ) == WIN_PROC_32W); |
| 1684 | WIN_ReleaseWndPtr(wndPtr); |
| 1685 | return retvalue; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1686 | } |
| 1687 | |
| 1688 | |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 1689 | /********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1690 | * GetWindowWord (USER.133) |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 1691 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 1692 | WORD WINAPI GetWindowWord16( HWND16 hwnd, INT16 offset ) |
Alexandre Julliard | 2197901 | 1997-03-05 08:22:35 +0000 | [diff] [blame] | 1693 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1694 | return GetWindowWord( hwnd, offset ); |
Alexandre Julliard | 2197901 | 1997-03-05 08:22:35 +0000 | [diff] [blame] | 1695 | } |
| 1696 | |
| 1697 | |
| 1698 | /********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1699 | * GetWindowWord (USER32.@) |
Alexandre Julliard | 2197901 | 1997-03-05 08:22:35 +0000 | [diff] [blame] | 1700 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1701 | WORD WINAPI GetWindowWord( HWND hwnd, INT offset ) |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 1702 | { |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1703 | WORD retvalue; |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 1704 | WND * wndPtr = WIN_FindWndPtr( hwnd ); |
| 1705 | if (!wndPtr) return 0; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1706 | if (offset >= 0) |
| 1707 | { |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 1708 | if (offset + sizeof(WORD) > wndPtr->cbWndExtra) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1709 | { |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 1710 | WARN("Invalid offset %d\n", offset ); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1711 | retvalue = 0; |
| 1712 | goto end; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1713 | } |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1714 | retvalue = *(WORD *)(((char *)wndPtr->wExtra) + offset); |
| 1715 | goto end; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1716 | } |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 1717 | switch(offset) |
| 1718 | { |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 1719 | case GWW_ID: |
| 1720 | if (HIWORD(wndPtr->wIDmenu)) |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 1721 | WARN("GWW_ID: discards high bits of 0x%08x!\n", |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 1722 | wndPtr->wIDmenu); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1723 | retvalue = (WORD)wndPtr->wIDmenu; |
| 1724 | goto end; |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 1725 | case GWW_HWNDPARENT: |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1726 | retvalue = GetParent(hwnd); |
| 1727 | goto end; |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 1728 | case GWW_HINSTANCE: |
| 1729 | if (HIWORD(wndPtr->hInstance)) |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 1730 | WARN("GWW_HINSTANCE: discards high bits of 0x%08x!\n", |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 1731 | wndPtr->hInstance); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1732 | retvalue = (WORD)wndPtr->hInstance; |
| 1733 | goto end; |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1734 | default: |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 1735 | WARN("Invalid offset %d\n", offset ); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1736 | retvalue = 0; |
| 1737 | goto end; |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 1738 | } |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1739 | end: |
| 1740 | WIN_ReleaseWndPtr(wndPtr); |
| 1741 | return retvalue; |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 1742 | } |
| 1743 | |
Alexandre Julliard | af0bae5 | 1995-10-03 17:06:08 +0000 | [diff] [blame] | 1744 | /********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1745 | * SetWindowWord (USER.134) |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 1746 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 1747 | WORD WINAPI SetWindowWord16( HWND16 hwnd, INT16 offset, WORD newval ) |
Alexandre Julliard | 2197901 | 1997-03-05 08:22:35 +0000 | [diff] [blame] | 1748 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1749 | return SetWindowWord( hwnd, offset, newval ); |
Alexandre Julliard | 2197901 | 1997-03-05 08:22:35 +0000 | [diff] [blame] | 1750 | } |
| 1751 | |
| 1752 | |
| 1753 | /********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1754 | * SetWindowWord (USER32.@) |
Alexandre Julliard | 2197901 | 1997-03-05 08:22:35 +0000 | [diff] [blame] | 1755 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1756 | WORD WINAPI SetWindowWord( HWND hwnd, INT offset, WORD newval ) |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 1757 | { |
| 1758 | WORD *ptr, retval; |
| 1759 | WND * wndPtr = WIN_FindWndPtr( hwnd ); |
| 1760 | if (!wndPtr) return 0; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1761 | if (offset >= 0) |
| 1762 | { |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 1763 | if (offset + sizeof(WORD) > wndPtr->cbWndExtra) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1764 | { |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 1765 | WARN("Invalid offset %d\n", offset ); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1766 | retval = 0; |
| 1767 | goto end; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1768 | } |
| 1769 | ptr = (WORD *)(((char *)wndPtr->wExtra) + offset); |
| 1770 | } |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 1771 | else switch(offset) |
| 1772 | { |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1773 | case GWW_ID: ptr = (WORD *)&wndPtr->wIDmenu; break; |
| 1774 | case GWW_HINSTANCE: ptr = (WORD *)&wndPtr->hInstance; break; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1775 | case GWW_HWNDPARENT: retval = SetParent( hwnd, newval ); |
| 1776 | goto end; |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1777 | default: |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 1778 | WARN("Invalid offset %d\n", offset ); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1779 | retval = 0; |
| 1780 | goto end; |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 1781 | } |
| 1782 | retval = *ptr; |
| 1783 | *ptr = newval; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1784 | end: |
| 1785 | WIN_ReleaseWndPtr(wndPtr); |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 1786 | return retval; |
| 1787 | } |
| 1788 | |
| 1789 | |
| 1790 | /********************************************************************** |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1791 | * WIN_GetWindowLong |
| 1792 | * |
| 1793 | * Helper function for GetWindowLong(). |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 1794 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1795 | static LONG WIN_GetWindowLong( HWND hwnd, INT offset, WINDOWPROCTYPE type ) |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1796 | { |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1797 | LONG retvalue; |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 1798 | WND * wndPtr = WIN_FindWndPtr( hwnd ); |
| 1799 | if (!wndPtr) return 0; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1800 | if (offset >= 0) |
| 1801 | { |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 1802 | if (offset + sizeof(LONG) > wndPtr->cbWndExtra) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1803 | { |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 1804 | WARN("Invalid offset %d\n", offset ); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1805 | retvalue = 0; |
| 1806 | goto end; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1807 | } |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1808 | retvalue = *(LONG *)(((char *)wndPtr->wExtra) + offset); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1809 | /* Special case for dialog window procedure */ |
| 1810 | if ((offset == DWL_DLGPROC) && (wndPtr->flags & WIN_ISDIALOG)) |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1811 | { |
| 1812 | retvalue = (LONG)WINPROC_GetProc( (HWINDOWPROC)retvalue, type ); |
| 1813 | goto end; |
| 1814 | } |
| 1815 | goto end; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1816 | } |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 1817 | switch(offset) |
| 1818 | { |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1819 | case GWL_USERDATA: retvalue = wndPtr->userdata; |
| 1820 | goto end; |
| 1821 | case GWL_STYLE: retvalue = wndPtr->dwStyle; |
| 1822 | goto end; |
| 1823 | case GWL_EXSTYLE: retvalue = wndPtr->dwExStyle; |
| 1824 | goto end; |
| 1825 | case GWL_ID: retvalue = (LONG)wndPtr->wIDmenu; |
| 1826 | goto end; |
| 1827 | case GWL_WNDPROC: retvalue = (LONG)WINPROC_GetProc( wndPtr->winproc, |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1828 | type ); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1829 | goto end; |
| 1830 | case GWL_HWNDPARENT: retvalue = GetParent(hwnd); |
| 1831 | goto end; |
| 1832 | case GWL_HINSTANCE: retvalue = wndPtr->hInstance; |
| 1833 | goto end; |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1834 | default: |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 1835 | WARN("Unknown offset %d\n", offset ); |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 1836 | } |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1837 | retvalue = 0; |
| 1838 | end: |
| 1839 | WIN_ReleaseWndPtr(wndPtr); |
| 1840 | return retvalue; |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 1841 | } |
| 1842 | |
| 1843 | |
| 1844 | /********************************************************************** |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1845 | * WIN_SetWindowLong |
| 1846 | * |
| 1847 | * Helper function for SetWindowLong(). |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 1848 | * |
| 1849 | * 0 is the failure code. However, in the case of failure SetLastError |
| 1850 | * must be set to distinguish between a 0 return value and a failure. |
| 1851 | * |
| 1852 | * FIXME: The error values for SetLastError may not be right. Can |
| 1853 | * someone check with the real thing? |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1854 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1855 | static LONG WIN_SetWindowLong( HWND hwnd, INT offset, LONG newval, |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1856 | WINDOWPROCTYPE type ) |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 1857 | { |
| 1858 | LONG *ptr, retval; |
| 1859 | WND * wndPtr = WIN_FindWndPtr( hwnd ); |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 1860 | STYLESTRUCT style; |
| 1861 | |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 1862 | TRACE("%x=%p %x %lx %x\n",hwnd, wndPtr, offset, newval, type); |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 1863 | |
| 1864 | if (!wndPtr) |
| 1865 | { |
| 1866 | /* Is this the right error? */ |
| 1867 | SetLastError( ERROR_INVALID_WINDOW_HANDLE ); |
| 1868 | return 0; |
| 1869 | } |
| 1870 | |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1871 | if (offset >= 0) |
| 1872 | { |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 1873 | if (offset + sizeof(LONG) > wndPtr->cbWndExtra) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1874 | { |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 1875 | WARN("Invalid offset %d\n", offset ); |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 1876 | |
| 1877 | /* Is this the right error? */ |
| 1878 | SetLastError( ERROR_OUTOFMEMORY ); |
| 1879 | |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1880 | retval = 0; |
| 1881 | goto end; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1882 | } |
| 1883 | ptr = (LONG *)(((char *)wndPtr->wExtra) + offset); |
| 1884 | /* Special case for dialog window procedure */ |
| 1885 | if ((offset == DWL_DLGPROC) && (wndPtr->flags & WIN_ISDIALOG)) |
| 1886 | { |
| 1887 | retval = (LONG)WINPROC_GetProc( (HWINDOWPROC)*ptr, type ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1888 | WINPROC_SetProc( (HWINDOWPROC *)ptr, (WNDPROC16)newval, |
| 1889 | type, WIN_PROC_WINDOW ); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1890 | goto end; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1891 | } |
| 1892 | } |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 1893 | else switch(offset) |
| 1894 | { |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 1895 | case GWL_ID: |
| 1896 | ptr = (DWORD*)&wndPtr->wIDmenu; |
| 1897 | break; |
| 1898 | case GWL_HINSTANCE: |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1899 | retval = SetWindowWord( hwnd, offset, newval ); |
| 1900 | goto end; |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1901 | case GWL_WNDPROC: |
Dmitry Timoshkov | 5956b98 | 2000-11-28 23:53:08 +0000 | [diff] [blame] | 1902 | retval = (LONG)WINPROC_GetProc( wndPtr->winproc, type ); |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 1903 | WINPROC_SetProc( &wndPtr->winproc, (WNDPROC16)newval, |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1904 | type, WIN_PROC_WINDOW ); |
Andreas Mohr | 1c20b39 | 2000-02-20 19:17:35 +0000 | [diff] [blame] | 1905 | goto end; |
Alexandre Julliard | ca22b33 | 1996-07-12 19:02:39 +0000 | [diff] [blame] | 1906 | case GWL_STYLE: |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 1907 | style.styleOld = wndPtr->dwStyle; |
Alexandre Julliard | f88e5aa | 2001-03-21 23:55:36 +0000 | [diff] [blame] | 1908 | style.styleNew = newval; |
Alexandre Julliard | 4b0343d | 2001-06-20 22:55:31 +0000 | [diff] [blame] | 1909 | SendMessageA(hwnd,WM_STYLECHANGING,GWL_STYLE,(LPARAM)&style); |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 1910 | wndPtr->dwStyle = style.styleNew; |
Alexandre Julliard | 4b0343d | 2001-06-20 22:55:31 +0000 | [diff] [blame] | 1911 | SendMessageA(hwnd,WM_STYLECHANGED,GWL_STYLE,(LPARAM)&style); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1912 | retval = style.styleOld; |
| 1913 | goto end; |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 1914 | |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 1915 | case GWL_USERDATA: |
| 1916 | ptr = &wndPtr->userdata; |
| 1917 | break; |
| 1918 | case GWL_EXSTYLE: |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 1919 | style.styleOld = wndPtr->dwExStyle; |
| 1920 | style.styleNew = newval; |
Alexandre Julliard | 4b0343d | 2001-06-20 22:55:31 +0000 | [diff] [blame] | 1921 | SendMessageA(hwnd,WM_STYLECHANGING,GWL_EXSTYLE,(LPARAM)&style); |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 1922 | wndPtr->dwExStyle = newval; |
Alexandre Julliard | 4b0343d | 2001-06-20 22:55:31 +0000 | [diff] [blame] | 1923 | SendMessageA(hwnd,WM_STYLECHANGED,GWL_EXSTYLE,(LPARAM)&style); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1924 | retval = style.styleOld; |
| 1925 | goto end; |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 1926 | |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1927 | default: |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 1928 | WARN("Invalid offset %d\n", offset ); |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 1929 | |
| 1930 | /* Don't think this is right error but it should do */ |
| 1931 | SetLastError( ERROR_OUTOFMEMORY ); |
| 1932 | |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1933 | retval = 0; |
| 1934 | goto end; |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 1935 | } |
| 1936 | retval = *ptr; |
| 1937 | *ptr = newval; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1938 | end: |
| 1939 | WIN_ReleaseWndPtr(wndPtr); |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 1940 | return retval; |
| 1941 | } |
| 1942 | |
| 1943 | |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1944 | /********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1945 | * GetWindowLong (USER.135) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1946 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 1947 | LONG WINAPI GetWindowLong16( HWND16 hwnd, INT16 offset ) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1948 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1949 | return WIN_GetWindowLong( (HWND)hwnd, offset, WIN_PROC_16 ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1950 | } |
| 1951 | |
| 1952 | |
| 1953 | /********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1954 | * GetWindowLongA (USER32.@) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1955 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1956 | LONG WINAPI GetWindowLongA( HWND hwnd, INT offset ) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1957 | { |
| 1958 | return WIN_GetWindowLong( hwnd, offset, WIN_PROC_32A ); |
| 1959 | } |
| 1960 | |
| 1961 | |
| 1962 | /********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1963 | * GetWindowLongW (USER32.@) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1964 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1965 | LONG WINAPI GetWindowLongW( HWND hwnd, INT offset ) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1966 | { |
| 1967 | return WIN_GetWindowLong( hwnd, offset, WIN_PROC_32W ); |
| 1968 | } |
| 1969 | |
| 1970 | |
| 1971 | /********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1972 | * SetWindowLong (USER.136) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1973 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 1974 | LONG WINAPI SetWindowLong16( HWND16 hwnd, INT16 offset, LONG newval ) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1975 | { |
| 1976 | return WIN_SetWindowLong( hwnd, offset, newval, WIN_PROC_16 ); |
| 1977 | } |
| 1978 | |
| 1979 | |
| 1980 | /********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1981 | * SetWindowLongA (USER32.@) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1982 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1983 | LONG WINAPI SetWindowLongA( HWND hwnd, INT offset, LONG newval ) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1984 | { |
| 1985 | return WIN_SetWindowLong( hwnd, offset, newval, WIN_PROC_32A ); |
| 1986 | } |
| 1987 | |
| 1988 | |
| 1989 | /********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1990 | * SetWindowLongW (USER32.@) Set window attribute |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 1991 | * |
| 1992 | * SetWindowLong() alters one of a window's attributes or sets a 32-bit (long) |
| 1993 | * value in a window's extra memory. |
| 1994 | * |
| 1995 | * The _hwnd_ parameter specifies the window. is the handle to a |
| 1996 | * window that has extra memory. The _newval_ parameter contains the |
| 1997 | * new attribute or extra memory value. If positive, the _offset_ |
| 1998 | * parameter is the byte-addressed location in the window's extra |
| 1999 | * memory to set. If negative, _offset_ specifies the window |
| 2000 | * attribute to set, and should be one of the following values: |
| 2001 | * |
| 2002 | * GWL_EXSTYLE The window's extended window style |
| 2003 | * |
| 2004 | * GWL_STYLE The window's window style. |
| 2005 | * |
| 2006 | * GWL_WNDPROC Pointer to the window's window procedure. |
| 2007 | * |
| 2008 | * GWL_HINSTANCE The window's pplication instance handle. |
| 2009 | * |
| 2010 | * GWL_ID The window's identifier. |
| 2011 | * |
| 2012 | * GWL_USERDATA The window's user-specified data. |
| 2013 | * |
| 2014 | * If the window is a dialog box, the _offset_ parameter can be one of |
| 2015 | * the following values: |
| 2016 | * |
| 2017 | * DWL_DLGPROC The address of the window's dialog box procedure. |
| 2018 | * |
| 2019 | * DWL_MSGRESULT The return value of a message |
| 2020 | * that the dialog box procedure processed. |
| 2021 | * |
| 2022 | * DWL_USER Application specific information. |
| 2023 | * |
| 2024 | * RETURNS |
| 2025 | * |
| 2026 | * If successful, returns the previous value located at _offset_. Otherwise, |
| 2027 | * returns 0. |
| 2028 | * |
| 2029 | * NOTES |
| 2030 | * |
| 2031 | * Extra memory for a window class is specified by a nonzero cbWndExtra |
| 2032 | * parameter of the WNDCLASS structure passed to RegisterClass() at the |
| 2033 | * time of class creation. |
| 2034 | * |
| 2035 | * Using GWL_WNDPROC to set a new window procedure effectively creates |
| 2036 | * a window subclass. Use CallWindowProc() in the new windows procedure |
| 2037 | * to pass messages to the superclass's window procedure. |
| 2038 | * |
| 2039 | * The user data is reserved for use by the application which created |
| 2040 | * the window. |
| 2041 | * |
| 2042 | * Do not use GWL_STYLE to change the window's WS_DISABLE style; |
| 2043 | * instead, call the EnableWindow() function to change the window's |
| 2044 | * disabled state. |
| 2045 | * |
| 2046 | * Do not use GWL_HWNDPARENT to reset the window's parent, use |
| 2047 | * SetParent() instead. |
| 2048 | * |
Alexandre Julliard | 638f169 | 1999-01-17 16:32:32 +0000 | [diff] [blame] | 2049 | * Win95: |
| 2050 | * When offset is GWL_STYLE and the calling app's ver is 4.0, |
| 2051 | * it sends WM_STYLECHANGING before changing the settings |
| 2052 | * and WM_STYLECHANGED afterwards. |
| 2053 | * App ver 4.0 can't use SetWindowLong to change WS_EX_TOPMOST. |
| 2054 | * |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 2055 | * BUGS |
| 2056 | * |
Alexandre Julliard | 638f169 | 1999-01-17 16:32:32 +0000 | [diff] [blame] | 2057 | * GWL_STYLE does not dispatch WM_STYLE... messages. |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 2058 | * |
| 2059 | * CONFORMANCE |
| 2060 | * |
| 2061 | * ECMA-234, Win32 |
| 2062 | * |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 2063 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2064 | LONG WINAPI SetWindowLongW( |
Patrik Stridvall | 2b3aa61 | 2000-12-01 23:58:28 +0000 | [diff] [blame] | 2065 | HWND hwnd, /* [in] window to alter */ |
| 2066 | INT offset, /* [in] offset, in bytes, of location to alter */ |
| 2067 | LONG newval /* [in] new value of location */ |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 2068 | ) { |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2069 | return WIN_SetWindowLong( hwnd, offset, newval, WIN_PROC_32W ); |
Alexandre Julliard | e2abbb1 | 1995-03-19 17:39:39 +0000 | [diff] [blame] | 2070 | } |
| 2071 | |
| 2072 | |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 2073 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2074 | * GetWindowText (USER.36) |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 2075 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 2076 | INT16 WINAPI GetWindowText16( HWND16 hwnd, SEGPTR lpString, INT16 nMaxCount ) |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 2077 | { |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2078 | return (INT16)SendMessage16(hwnd, WM_GETTEXT, nMaxCount, (LPARAM)lpString); |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 2079 | } |
| 2080 | |
Alexandre Julliard | e2abbb1 | 1995-03-19 17:39:39 +0000 | [diff] [blame] | 2081 | |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2082 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2083 | * GetWindowTextA (USER32.@) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2084 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2085 | INT WINAPI GetWindowTextA( HWND hwnd, LPSTR lpString, INT nMaxCount ) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2086 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2087 | return (INT)SendMessageA( hwnd, WM_GETTEXT, nMaxCount, |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2088 | (LPARAM)lpString ); |
| 2089 | } |
| 2090 | |
Alexandre Julliard | f90efa9 | 1998-06-14 15:24:15 +0000 | [diff] [blame] | 2091 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2092 | * InternalGetWindowText (USER32.@) |
Alexandre Julliard | f90efa9 | 1998-06-14 15:24:15 +0000 | [diff] [blame] | 2093 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2094 | INT WINAPI InternalGetWindowText(HWND hwnd,LPWSTR lpString,INT nMaxCount ) |
Alexandre Julliard | f90efa9 | 1998-06-14 15:24:15 +0000 | [diff] [blame] | 2095 | { |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 2096 | WND *win = WIN_FindWndPtr( hwnd ); |
| 2097 | if (!win) return 0; |
| 2098 | if (win->text) lstrcpynW( lpString, win->text, nMaxCount ); |
| 2099 | else lpString[0] = 0; |
| 2100 | WIN_ReleaseWndPtr( win ); |
| 2101 | return strlenW(lpString); |
Alexandre Julliard | f90efa9 | 1998-06-14 15:24:15 +0000 | [diff] [blame] | 2102 | } |
| 2103 | |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2104 | |
| 2105 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2106 | * GetWindowTextW (USER32.@) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2107 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2108 | INT WINAPI GetWindowTextW( HWND hwnd, LPWSTR lpString, INT nMaxCount ) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2109 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2110 | return (INT)SendMessageW( hwnd, WM_GETTEXT, nMaxCount, |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2111 | (LPARAM)lpString ); |
| 2112 | } |
| 2113 | |
| 2114 | |
| 2115 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2116 | * SetWindowText (USER.37) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2117 | */ |
Paul Quinn | 1beaae5 | 1998-12-15 15:38:36 +0000 | [diff] [blame] | 2118 | BOOL16 WINAPI SetWindowText16( HWND16 hwnd, SEGPTR lpString ) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2119 | { |
Paul Quinn | 1beaae5 | 1998-12-15 15:38:36 +0000 | [diff] [blame] | 2120 | return (BOOL16)SendMessage16( hwnd, WM_SETTEXT, 0, (LPARAM)lpString ); |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2121 | } |
| 2122 | |
| 2123 | |
| 2124 | /******************************************************************* |
Patrik Stridvall | 17fd4e3 | 2001-06-28 18:04:41 +0000 | [diff] [blame] | 2125 | * SetWindowText (USER32.@) |
| 2126 | * SetWindowTextA (USER32.@) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2127 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2128 | BOOL WINAPI SetWindowTextA( HWND hwnd, LPCSTR lpString ) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2129 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2130 | return (BOOL)SendMessageA( hwnd, WM_SETTEXT, 0, (LPARAM)lpString ); |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2131 | } |
| 2132 | |
| 2133 | |
| 2134 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2135 | * SetWindowTextW (USER32.@) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2136 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2137 | BOOL WINAPI SetWindowTextW( HWND hwnd, LPCWSTR lpString ) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2138 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2139 | return (BOOL)SendMessageW( hwnd, WM_SETTEXT, 0, (LPARAM)lpString ); |
Alexandre Julliard | e2abbb1 | 1995-03-19 17:39:39 +0000 | [diff] [blame] | 2140 | } |
| 2141 | |
| 2142 | |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 2143 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2144 | * GetWindowTextLength (USER.38) |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 2145 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 2146 | INT16 WINAPI GetWindowTextLength16( HWND16 hwnd ) |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 2147 | { |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 2148 | return (INT16)SendMessage16( hwnd, WM_GETTEXTLENGTH, 0, 0 ); |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 2149 | } |
| 2150 | |
| 2151 | |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 2152 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2153 | * GetWindowTextLengthA (USER32.@) |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 2154 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2155 | INT WINAPI GetWindowTextLengthA( HWND hwnd ) |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 2156 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2157 | return SendMessageA( hwnd, WM_GETTEXTLENGTH, 0, 0 ); |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 2158 | } |
| 2159 | |
| 2160 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2161 | * GetWindowTextLengthW (USER32.@) |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 2162 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2163 | INT WINAPI GetWindowTextLengthW( HWND hwnd ) |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 2164 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2165 | return SendMessageW( hwnd, WM_GETTEXTLENGTH, 0, 0 ); |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 2166 | } |
| 2167 | |
Alexandre Julliard | 2197901 | 1997-03-05 08:22:35 +0000 | [diff] [blame] | 2168 | |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 2169 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2170 | * IsWindow (USER.47) |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 2171 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 2172 | BOOL16 WINAPI IsWindow16( HWND16 hwnd ) |
Alexandre Julliard | 2197901 | 1997-03-05 08:22:35 +0000 | [diff] [blame] | 2173 | { |
Alexandre Julliard | 4220b29 | 1999-07-11 17:20:01 +0000 | [diff] [blame] | 2174 | CURRENT_STACK16->es = USER_HeapSel; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2175 | return IsWindow( hwnd ); |
Alexandre Julliard | 2197901 | 1997-03-05 08:22:35 +0000 | [diff] [blame] | 2176 | } |
| 2177 | |
| 2178 | |
| 2179 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2180 | * IsWindow (USER32.@) |
Alexandre Julliard | 2197901 | 1997-03-05 08:22:35 +0000 | [diff] [blame] | 2181 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2182 | BOOL WINAPI IsWindow( HWND hwnd ) |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 2183 | { |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2184 | WND * wndPtr; |
| 2185 | BOOL retvalue; |
| 2186 | |
| 2187 | if(!(wndPtr = WIN_FindWndPtr( hwnd ))) return FALSE; |
| 2188 | retvalue = (wndPtr->dwMagic == WND_MAGIC); |
| 2189 | WIN_ReleaseWndPtr(wndPtr); |
| 2190 | return retvalue; |
| 2191 | |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 2192 | } |
| 2193 | |
| 2194 | |
| 2195 | /***************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2196 | * GetParent (USER.46) |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 2197 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 2198 | HWND16 WINAPI GetParent16( HWND16 hwnd ) |
Alexandre Julliard | d1ce8b2 | 1996-09-02 16:46:30 +0000 | [diff] [blame] | 2199 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2200 | return (HWND16)GetParent( hwnd ); |
Alexandre Julliard | d1ce8b2 | 1996-09-02 16:46:30 +0000 | [diff] [blame] | 2201 | } |
| 2202 | |
| 2203 | |
| 2204 | /***************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2205 | * GetParent (USER32.@) |
Alexandre Julliard | d1ce8b2 | 1996-09-02 16:46:30 +0000 | [diff] [blame] | 2206 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2207 | HWND WINAPI GetParent( HWND hwnd ) |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 2208 | { |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2209 | WND *wndPtr; |
Andreas Mohr | 1c20b39 | 2000-02-20 19:17:35 +0000 | [diff] [blame] | 2210 | HWND retvalue = 0; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2211 | |
| 2212 | if(!(wndPtr = WIN_FindWndPtr(hwnd))) return 0; |
| 2213 | if ((!(wndPtr->dwStyle & (WS_POPUP|WS_CHILD)))) |
Andreas Mohr | 1c20b39 | 2000-02-20 19:17:35 +0000 | [diff] [blame] | 2214 | goto end; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2215 | |
Andreas Mohr | 1c20b39 | 2000-02-20 19:17:35 +0000 | [diff] [blame] | 2216 | WIN_UpdateWndPtr(&wndPtr,((wndPtr->dwStyle & WS_CHILD) ? wndPtr->parent : wndPtr->owner)); |
| 2217 | if (wndPtr) |
| 2218 | retvalue = wndPtr->hwndSelf; |
| 2219 | |
| 2220 | end: |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2221 | WIN_ReleaseWndPtr(wndPtr); |
| 2222 | return retvalue; |
| 2223 | |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 2224 | } |
| 2225 | |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 2226 | /***************************************************************** |
| 2227 | * WIN_GetTopParent |
| 2228 | * |
| 2229 | * Get the top-level parent for a child window. |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2230 | * returns a locked pointer |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 2231 | */ |
| 2232 | WND* WIN_GetTopParentPtr( WND* pWnd ) |
| 2233 | { |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 2234 | WND *tmpWnd = WIN_LockWndPtr(pWnd); |
| 2235 | |
| 2236 | while( tmpWnd && (tmpWnd->dwStyle & WS_CHILD)) |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2237 | { |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 2238 | WIN_UpdateWndPtr(&tmpWnd,tmpWnd->parent); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2239 | } |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 2240 | return tmpWnd; |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 2241 | } |
Alexandre Julliard | e2991ea | 1995-07-29 13:09:43 +0000 | [diff] [blame] | 2242 | |
| 2243 | /***************************************************************** |
| 2244 | * WIN_GetTopParent |
| 2245 | * |
| 2246 | * Get the top-level parent for a child window. |
| 2247 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2248 | HWND WIN_GetTopParent( HWND hwnd ) |
Alexandre Julliard | e2991ea | 1995-07-29 13:09:43 +0000 | [diff] [blame] | 2249 | { |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2250 | HWND retvalue; |
| 2251 | WND *tmpPtr = WIN_FindWndPtr(hwnd); |
| 2252 | WND *wndPtr = WIN_GetTopParentPtr (tmpPtr ); |
| 2253 | |
| 2254 | retvalue = wndPtr ? wndPtr->hwndSelf : 0; |
| 2255 | WIN_ReleaseWndPtr(tmpPtr); |
| 2256 | WIN_ReleaseWndPtr(wndPtr); |
| 2257 | return retvalue; |
Alexandre Julliard | e2991ea | 1995-07-29 13:09:43 +0000 | [diff] [blame] | 2258 | } |
| 2259 | |
| 2260 | |
Alexandre Julliard | 940d58c | 1994-09-16 09:24:37 +0000 | [diff] [blame] | 2261 | /***************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2262 | * SetParent (USER.233) |
Alexandre Julliard | 940d58c | 1994-09-16 09:24:37 +0000 | [diff] [blame] | 2263 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 2264 | HWND16 WINAPI SetParent16( HWND16 hwndChild, HWND16 hwndNewParent ) |
Alexandre Julliard | 940d58c | 1994-09-16 09:24:37 +0000 | [diff] [blame] | 2265 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2266 | return SetParent( hwndChild, hwndNewParent ); |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2267 | } |
Alexandre Julliard | 940d58c | 1994-09-16 09:24:37 +0000 | [diff] [blame] | 2268 | |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2269 | |
| 2270 | /***************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2271 | * SetParent (USER32.@) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2272 | */ |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 2273 | HWND WINAPI SetParent( HWND hwnd, HWND parent ) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2274 | { |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 2275 | WND *wndPtr; |
| 2276 | WND *pWndParent; |
| 2277 | DWORD dwStyle; |
| 2278 | HWND retvalue; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2279 | |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 2280 | if (hwnd == GetDesktopWindow()) /* sanity check */ |
| 2281 | { |
| 2282 | SetLastError( ERROR_INVALID_WINDOW_HANDLE ); |
| 2283 | return 0; |
| 2284 | } |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2285 | |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 2286 | if (USER_Driver.pSetParent) |
| 2287 | return USER_Driver.pSetParent( hwnd, parent ); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2288 | |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 2289 | if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2290 | |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 2291 | dwStyle = wndPtr->dwStyle; |
Ove Kaaven | 72d8dbe | 1999-02-13 09:02:17 +0000 | [diff] [blame] | 2292 | |
Alexandre Julliard | b19c57c | 2001-05-10 21:06:56 +0000 | [diff] [blame] | 2293 | if (!parent) parent = GetDesktopWindow(); |
| 2294 | |
| 2295 | if (!(pWndParent = WIN_FindWndPtr(parent))) |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 2296 | { |
| 2297 | WIN_ReleaseWndPtr( wndPtr ); |
| 2298 | return 0; |
| 2299 | } |
Ove Kaaven | 72d8dbe | 1999-02-13 09:02:17 +0000 | [diff] [blame] | 2300 | |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 2301 | /* Windows hides the window first, then shows it again |
| 2302 | * including the WM_SHOWWINDOW messages and all */ |
| 2303 | if (dwStyle & WS_VISIBLE) ShowWindow( hwnd, SW_HIDE ); |
Alexandre Julliard | 940d58c | 1994-09-16 09:24:37 +0000 | [diff] [blame] | 2304 | |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 2305 | retvalue = wndPtr->parent->hwndSelf; /* old parent */ |
| 2306 | if (pWndParent != wndPtr->parent) |
| 2307 | { |
| 2308 | WIN_UnlinkWindow(wndPtr->hwndSelf); |
| 2309 | wndPtr->parent = pWndParent; |
Ove Kaaven | 72d8dbe | 1999-02-13 09:02:17 +0000 | [diff] [blame] | 2310 | |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 2311 | if (parent != GetDesktopWindow()) /* a child window */ |
| 2312 | { |
| 2313 | if( !( wndPtr->dwStyle & WS_CHILD ) ) |
| 2314 | { |
| 2315 | if( wndPtr->wIDmenu != 0) |
| 2316 | { |
| 2317 | DestroyMenu( (HMENU) wndPtr->wIDmenu ); |
| 2318 | wndPtr->wIDmenu = 0; |
| 2319 | } |
| 2320 | } |
| 2321 | } |
| 2322 | WIN_LinkWindow(wndPtr->hwndSelf, HWND_TOP); |
| 2323 | } |
| 2324 | WIN_ReleaseWndPtr( pWndParent ); |
| 2325 | WIN_ReleaseWndPtr( wndPtr ); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2326 | |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 2327 | /* SetParent additionally needs to make hwnd the topmost window |
| 2328 | in the x-order and send the expected WM_WINDOWPOSCHANGING and |
| 2329 | WM_WINDOWPOSCHANGED notification messages. |
| 2330 | */ |
| 2331 | SetWindowPos( hwnd, HWND_TOPMOST, 0, 0, 0, 0, |
| 2332 | SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE| |
| 2333 | ((dwStyle & WS_VISIBLE)?SWP_SHOWWINDOW:0)); |
| 2334 | /* FIXME: a WM_MOVE is also generated (in the DefWindowProc handler |
| 2335 | * for WM_WINDOWPOSCHANGED) in Windows, should probably remove SWP_NOMOVE */ |
| 2336 | return retvalue; |
Alexandre Julliard | 940d58c | 1994-09-16 09:24:37 +0000 | [diff] [blame] | 2337 | } |
| 2338 | |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 2339 | |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 2340 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2341 | * IsChild (USER.48) |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 2342 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 2343 | BOOL16 WINAPI IsChild16( HWND16 parent, HWND16 child ) |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 2344 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2345 | return IsChild(parent,child); |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 2346 | } |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2347 | |
| 2348 | |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 2349 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2350 | * IsChild (USER32.@) |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 2351 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2352 | BOOL WINAPI IsChild( HWND parent, HWND child ) |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 2353 | { |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 2354 | WND * wndPtr = WIN_FindWndPtr( child ); |
Alexandre Julliard | f88e5aa | 2001-03-21 23:55:36 +0000 | [diff] [blame] | 2355 | while (wndPtr && wndPtr->parent) |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 2356 | { |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2357 | WIN_UpdateWndPtr(&wndPtr,wndPtr->parent); |
Alexandre Julliard | f88e5aa | 2001-03-21 23:55:36 +0000 | [diff] [blame] | 2358 | if (wndPtr->hwndSelf == GetDesktopWindow()) break; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2359 | if (wndPtr->hwndSelf == parent) |
Andreas Mohr | 1c20b39 | 2000-02-20 19:17:35 +0000 | [diff] [blame] | 2360 | { |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2361 | WIN_ReleaseWndPtr(wndPtr); |
| 2362 | return TRUE; |
| 2363 | } |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 2364 | } |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2365 | WIN_ReleaseWndPtr(wndPtr); |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 2366 | return FALSE; |
| 2367 | } |
| 2368 | |
| 2369 | |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 2370 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2371 | * IsWindowVisible (USER.49) |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 2372 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 2373 | BOOL16 WINAPI IsWindowVisible16( HWND16 hwnd ) |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 2374 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2375 | return IsWindowVisible(hwnd); |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 2376 | } |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2377 | |
| 2378 | |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 2379 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2380 | * IsWindowVisible (USER32.@) |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 2381 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2382 | BOOL WINAPI IsWindowVisible( HWND hwnd ) |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 2383 | { |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2384 | BOOL retval; |
Alexandre Julliard | ded3038 | 1995-07-06 17:18:27 +0000 | [diff] [blame] | 2385 | WND *wndPtr = WIN_FindWndPtr( hwnd ); |
Alexandre Julliard | f88e5aa | 2001-03-21 23:55:36 +0000 | [diff] [blame] | 2386 | while (wndPtr && wndPtr->parent) |
Alexandre Julliard | ded3038 | 1995-07-06 17:18:27 +0000 | [diff] [blame] | 2387 | { |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2388 | if (!(wndPtr->dwStyle & WS_VISIBLE)) |
| 2389 | { |
| 2390 | WIN_ReleaseWndPtr(wndPtr); |
| 2391 | return FALSE; |
| 2392 | } |
| 2393 | WIN_UpdateWndPtr(&wndPtr,wndPtr->parent); |
Alexandre Julliard | ded3038 | 1995-07-06 17:18:27 +0000 | [diff] [blame] | 2394 | } |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2395 | retval = (wndPtr && (wndPtr->dwStyle & WS_VISIBLE)); |
| 2396 | WIN_ReleaseWndPtr(wndPtr); |
| 2397 | return retval; |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 2398 | } |
| 2399 | |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2400 | |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 2401 | /*********************************************************************** |
| 2402 | * WIN_IsWindowDrawable |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 2403 | * |
| 2404 | * hwnd is drawable when it is visible, all parents are not |
| 2405 | * minimized, and it is itself not minimized unless we are |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 2406 | * trying to draw its default class icon. |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 2407 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2408 | BOOL WIN_IsWindowDrawable( WND* wnd, BOOL icon ) |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 2409 | { |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 2410 | if (!(wnd->dwStyle & WS_VISIBLE)) return FALSE; |
| 2411 | if ((wnd->dwStyle & WS_MINIMIZE) && |
| 2412 | icon && GetClassLongA( wnd->hwndSelf, GCL_HICON )) return FALSE; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 2413 | for(wnd = wnd->parent; wnd; wnd = wnd->parent) |
| 2414 | if( wnd->dwStyle & WS_MINIMIZE || |
| 2415 | !(wnd->dwStyle & WS_VISIBLE) ) break; |
| 2416 | return (wnd == NULL); |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 2417 | } |
| 2418 | |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 2419 | |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 2420 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2421 | * GetTopWindow (USER.229) |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 2422 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 2423 | HWND16 WINAPI GetTopWindow16( HWND16 hwnd ) |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 2424 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2425 | return GetTopWindow(hwnd); |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 2426 | } |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2427 | |
| 2428 | |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 2429 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2430 | * GetTopWindow (USER32.@) |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 2431 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2432 | HWND WINAPI GetTopWindow( HWND hwnd ) |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 2433 | { |
Andreas Mohr | 1c20b39 | 2000-02-20 19:17:35 +0000 | [diff] [blame] | 2434 | HWND retval = 0; |
| 2435 | WND * wndPtr = (hwnd) ? |
| 2436 | WIN_FindWndPtr( hwnd ) : WIN_GetDesktop(); |
Francis Beaudet | b7e8e80 | 1999-05-22 10:46:30 +0000 | [diff] [blame] | 2437 | |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2438 | if (wndPtr && wndPtr->child) |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2439 | retval = wndPtr->child->hwndSelf; |
Andreas Mohr | 1c20b39 | 2000-02-20 19:17:35 +0000 | [diff] [blame] | 2440 | |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2441 | WIN_ReleaseWndPtr(wndPtr); |
| 2442 | return retval; |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 2443 | } |
| 2444 | |
| 2445 | |
| 2446 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2447 | * GetWindow (USER.262) |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 2448 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 2449 | HWND16 WINAPI GetWindow16( HWND16 hwnd, WORD rel ) |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 2450 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2451 | return GetWindow( hwnd,rel ); |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 2452 | } |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2453 | |
| 2454 | |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 2455 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2456 | * GetWindow (USER32.@) |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 2457 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2458 | HWND WINAPI GetWindow( HWND hwnd, WORD rel ) |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 2459 | { |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2460 | HWND retval; |
| 2461 | |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 2462 | WND * wndPtr = WIN_FindWndPtr( hwnd ); |
| 2463 | if (!wndPtr) return 0; |
| 2464 | switch(rel) |
| 2465 | { |
| 2466 | case GW_HWNDFIRST: |
Andreas Mohr | 1c20b39 | 2000-02-20 19:17:35 +0000 | [diff] [blame] | 2467 | retval = wndPtr->parent ? wndPtr->parent->child->hwndSelf : 0; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2468 | goto end; |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 2469 | |
| 2470 | case GW_HWNDLAST: |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2471 | if (!wndPtr->parent) |
| 2472 | { |
| 2473 | retval = 0; /* Desktop window */ |
| 2474 | goto end; |
| 2475 | } |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 2476 | while (wndPtr->next) |
| 2477 | { |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2478 | WIN_UpdateWndPtr(&wndPtr,wndPtr->next); |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 2479 | } |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2480 | retval = wndPtr->hwndSelf; |
| 2481 | goto end; |
| 2482 | |
| 2483 | case GW_HWNDNEXT: |
Andreas Mohr | 1c20b39 | 2000-02-20 19:17:35 +0000 | [diff] [blame] | 2484 | retval = wndPtr->next ? wndPtr->next->hwndSelf : 0; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2485 | goto end; |
| 2486 | |
| 2487 | case GW_HWNDPREV: |
| 2488 | if (!wndPtr->parent) |
| 2489 | { |
| 2490 | retval = 0; /* Desktop window */ |
| 2491 | goto end; |
| 2492 | } |
| 2493 | WIN_UpdateWndPtr(&wndPtr,wndPtr->parent->child); /* First sibling */ |
| 2494 | if (wndPtr->hwndSelf == hwnd) |
| 2495 | { |
| 2496 | retval = 0; /* First in list */ |
| 2497 | goto end; |
| 2498 | } |
| 2499 | while (wndPtr->next) |
| 2500 | { |
| 2501 | if (wndPtr->next->hwndSelf == hwnd) |
Andreas Mohr | 1c20b39 | 2000-02-20 19:17:35 +0000 | [diff] [blame] | 2502 | { |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2503 | retval = wndPtr->hwndSelf; |
| 2504 | goto end; |
Andreas Mohr | 1c20b39 | 2000-02-20 19:17:35 +0000 | [diff] [blame] | 2505 | } |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2506 | WIN_UpdateWndPtr(&wndPtr,wndPtr->next); |
| 2507 | } |
| 2508 | retval = 0; |
| 2509 | goto end; |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 2510 | |
| 2511 | case GW_OWNER: |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2512 | retval = wndPtr->owner ? wndPtr->owner->hwndSelf : 0; |
| 2513 | goto end; |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 2514 | |
| 2515 | case GW_CHILD: |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2516 | retval = wndPtr->child ? wndPtr->child->hwndSelf : 0; |
| 2517 | goto end; |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 2518 | } |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2519 | retval = 0; |
| 2520 | end: |
| 2521 | WIN_ReleaseWndPtr(wndPtr); |
| 2522 | return retval; |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 2523 | } |
| 2524 | |
| 2525 | |
| 2526 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2527 | * GetNextWindow (USER.230) |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 2528 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 2529 | HWND16 WINAPI GetNextWindow16( HWND16 hwnd, WORD flag ) |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 2530 | { |
| 2531 | if ((flag != GW_HWNDNEXT) && (flag != GW_HWNDPREV)) return 0; |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 2532 | return GetWindow16( hwnd, flag ); |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 2533 | } |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 2534 | |
Louis Philippe Gagnon | 06057e7 | 2000-08-20 03:40:59 +0000 | [diff] [blame] | 2535 | /*********************************************************************** |
| 2536 | * WIN_InternalShowOwnedPopups |
| 2537 | * |
| 2538 | * Internal version of ShowOwnedPopups; Wine functions should use this |
| 2539 | * to avoid interfering with application calls to ShowOwnedPopups |
| 2540 | * and to make sure the application can't prevent showing/hiding. |
| 2541 | * |
| 2542 | * Set unmanagedOnly to TRUE to show/hide unmanaged windows only. |
| 2543 | * |
| 2544 | */ |
| 2545 | |
| 2546 | BOOL WIN_InternalShowOwnedPopups( HWND owner, BOOL fShow, BOOL unmanagedOnly ) |
| 2547 | { |
| 2548 | INT totalChild=0, count=0; |
| 2549 | |
| 2550 | WND **pWnd = WIN_BuildWinArray(WIN_GetDesktop(), 0, &totalChild); |
| 2551 | |
| 2552 | if (!pWnd) return TRUE; |
| 2553 | |
| 2554 | /* |
| 2555 | * Show windows Lowest first, Highest last to preserve Z-Order |
| 2556 | */ |
| 2557 | for (count = totalChild-1 ; count >=0; count--) |
| 2558 | { |
| 2559 | if (pWnd[count]->owner && (pWnd[count]->owner->hwndSelf == owner) && (pWnd[count]->dwStyle & WS_POPUP)) |
| 2560 | { |
| 2561 | if (fShow) |
| 2562 | { |
| 2563 | /* check in window was flagged for showing in previous WIN_InternalShowOwnedPopups call */ |
| 2564 | if (pWnd[count]->flags & WIN_NEEDS_INTERNALSOP) |
| 2565 | { |
| 2566 | /* |
| 2567 | * Call ShowWindow directly because an application can intercept WM_SHOWWINDOW messages |
| 2568 | */ |
| 2569 | ShowWindow(pWnd[count]->hwndSelf,SW_SHOW); |
| 2570 | pWnd[count]->flags &= ~WIN_NEEDS_INTERNALSOP; /* remove the flag */ |
| 2571 | } |
| 2572 | } |
| 2573 | else |
| 2574 | { |
| 2575 | if ( IsWindowVisible(pWnd[count]->hwndSelf) && /* hide only if window is visible */ |
| 2576 | !( pWnd[count]->flags & WIN_NEEDS_INTERNALSOP ) && /* don't hide if previous call already did it */ |
Susan Farley | 557066d | 2000-10-13 17:07:08 +0000 | [diff] [blame] | 2577 | !( unmanagedOnly && (pWnd[count]->dwExStyle & WS_EX_MANAGED) ) ) /* don't hide managed windows if unmanagedOnly is TRUE */ |
Louis Philippe Gagnon | 06057e7 | 2000-08-20 03:40:59 +0000 | [diff] [blame] | 2578 | { |
| 2579 | /* |
| 2580 | * Call ShowWindow directly because an application can intercept WM_SHOWWINDOW messages |
| 2581 | */ |
| 2582 | ShowWindow(pWnd[count]->hwndSelf,SW_HIDE); |
| 2583 | /* flag the window for showing on next WIN_InternalShowOwnedPopups call */ |
| 2584 | pWnd[count]->flags |= WIN_NEEDS_INTERNALSOP; |
| 2585 | } |
| 2586 | } |
| 2587 | } |
| 2588 | } |
| 2589 | WIN_ReleaseDesktop(); |
| 2590 | WIN_ReleaseWinArray(pWnd); |
| 2591 | |
| 2592 | return TRUE; |
| 2593 | } |
| 2594 | |
Alexandre Julliard | e2991ea | 1995-07-29 13:09:43 +0000 | [diff] [blame] | 2595 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2596 | * ShowOwnedPopups (USER.265) |
Alexandre Julliard | e2991ea | 1995-07-29 13:09:43 +0000 | [diff] [blame] | 2597 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 2598 | void WINAPI ShowOwnedPopups16( HWND16 owner, BOOL16 fShow ) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2599 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2600 | ShowOwnedPopups( owner, fShow ); |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2601 | } |
| 2602 | |
| 2603 | |
| 2604 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2605 | * ShowOwnedPopups (USER32.@) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2606 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2607 | BOOL WINAPI ShowOwnedPopups( HWND owner, BOOL fShow ) |
Alexandre Julliard | e2991ea | 1995-07-29 13:09:43 +0000 | [diff] [blame] | 2608 | { |
Noomen Hamza | a018d85 | 1999-09-28 16:26:09 +0000 | [diff] [blame] | 2609 | UINT totalChild=0, count=0; |
| 2610 | |
| 2611 | WND **pWnd = WIN_BuildWinArray(WIN_GetDesktop(), 0, &totalChild); |
| 2612 | |
| 2613 | if (!pWnd) return TRUE; |
| 2614 | |
| 2615 | for (; count < totalChild; count++) |
Alexandre Julliard | e2991ea | 1995-07-29 13:09:43 +0000 | [diff] [blame] | 2616 | { |
Noomen Hamza | a018d85 | 1999-09-28 16:26:09 +0000 | [diff] [blame] | 2617 | if (pWnd[count]->owner && (pWnd[count]->owner->hwndSelf == owner) && (pWnd[count]->dwStyle & WS_POPUP)) |
Noomen Hamza | ff72776 | 2000-02-18 19:11:04 +0000 | [diff] [blame] | 2618 | { |
| 2619 | if (fShow) |
| 2620 | { |
| 2621 | if (pWnd[count]->flags & WIN_NEEDS_SHOW_OWNEDPOPUP) |
| 2622 | { |
Louis Philippe Gagnon | 06057e7 | 2000-08-20 03:40:59 +0000 | [diff] [blame] | 2623 | /* |
| 2624 | * In Windows, ShowOwnedPopups(TRUE) generates WM_SHOWWINDOW messages with SW_PARENTOPENING, |
| 2625 | * regardless of the state of the owner |
| 2626 | */ |
| 2627 | SendMessageA(pWnd[count]->hwndSelf, WM_SHOWWINDOW, SW_SHOW, SW_PARENTOPENING); |
Noomen Hamza | ff72776 | 2000-02-18 19:11:04 +0000 | [diff] [blame] | 2628 | pWnd[count]->flags &= ~WIN_NEEDS_SHOW_OWNEDPOPUP; |
| 2629 | } |
| 2630 | } |
| 2631 | else |
| 2632 | { |
| 2633 | if (IsWindowVisible(pWnd[count]->hwndSelf)) |
| 2634 | { |
Louis Philippe Gagnon | 06057e7 | 2000-08-20 03:40:59 +0000 | [diff] [blame] | 2635 | /* |
| 2636 | * In Windows, ShowOwnedPopups(FALSE) generates WM_SHOWWINDOW messages with SW_PARENTCLOSING, |
| 2637 | * regardless of the state of the owner |
| 2638 | */ |
| 2639 | SendMessageA(pWnd[count]->hwndSelf, WM_SHOWWINDOW, SW_HIDE, SW_PARENTCLOSING); |
Noomen Hamza | ff72776 | 2000-02-18 19:11:04 +0000 | [diff] [blame] | 2640 | pWnd[count]->flags |= WIN_NEEDS_SHOW_OWNEDPOPUP; |
| 2641 | } |
| 2642 | } |
| 2643 | } |
Alexandre Julliard | e2991ea | 1995-07-29 13:09:43 +0000 | [diff] [blame] | 2644 | } |
Noomen Hamza | a018d85 | 1999-09-28 16:26:09 +0000 | [diff] [blame] | 2645 | |
| 2646 | WIN_ReleaseDesktop(); |
| 2647 | WIN_ReleaseWinArray(pWnd); |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2648 | return TRUE; |
Alexandre Julliard | e2991ea | 1995-07-29 13:09:43 +0000 | [diff] [blame] | 2649 | } |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 2650 | |
| 2651 | |
Alexandre Julliard | 3a405ba | 1994-10-30 16:25:19 +0000 | [diff] [blame] | 2652 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2653 | * GetLastActivePopup (USER.287) |
Alexandre Julliard | 3a405ba | 1994-10-30 16:25:19 +0000 | [diff] [blame] | 2654 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 2655 | HWND16 WINAPI GetLastActivePopup16( HWND16 hwnd ) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2656 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2657 | return GetLastActivePopup( hwnd ); |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2658 | } |
| 2659 | |
| 2660 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2661 | * GetLastActivePopup (USER32.@) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2662 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2663 | HWND WINAPI GetLastActivePopup( HWND hwnd ) |
Alexandre Julliard | 3a405ba | 1994-10-30 16:25:19 +0000 | [diff] [blame] | 2664 | { |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2665 | HWND retval; |
Andreas Mohr | 1c20b39 | 2000-02-20 19:17:35 +0000 | [diff] [blame] | 2666 | WND *wndPtr =WIN_FindWndPtr(hwnd); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2667 | if (!wndPtr) return hwnd; |
| 2668 | retval = wndPtr->hwndLastActive; |
| 2669 | WIN_ReleaseWndPtr(wndPtr); |
Gerard Patel | ef456af | 2000-12-15 21:29:13 +0000 | [diff] [blame] | 2670 | if ((retval != hwnd) && (!IsWindow(retval))) |
| 2671 | retval = hwnd; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2672 | return retval; |
Alexandre Julliard | 3a405ba | 1994-10-30 16:25:19 +0000 | [diff] [blame] | 2673 | } |
| 2674 | |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 2675 | |
| 2676 | /******************************************************************* |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2677 | * WIN_BuildWinArray |
| 2678 | * |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 2679 | * Build an array of pointers to the children of a given window. |
Alexandre Julliard | 90476d6 | 2000-02-16 22:47:24 +0000 | [diff] [blame] | 2680 | * The array must be freed with WIN_ReleaseWinArray. Return NULL |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 2681 | * when no windows are found. |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 2682 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2683 | WND **WIN_BuildWinArray( WND *wndPtr, UINT bwaFlags, UINT* pTotal ) |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 2684 | { |
Andreas Mohr | 1c20b39 | 2000-02-20 19:17:35 +0000 | [diff] [blame] | 2685 | /* Future: this function will lock all windows associated with this array */ |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2686 | |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2687 | WND **list, **ppWnd; |
| 2688 | WND *pWnd; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2689 | UINT count = 0, skipOwned, skipHidden; |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 2690 | DWORD skipFlags; |
| 2691 | |
| 2692 | skipHidden = bwaFlags & BWA_SKIPHIDDEN; |
| 2693 | skipOwned = bwaFlags & BWA_SKIPOWNED; |
| 2694 | skipFlags = (bwaFlags & BWA_SKIPDISABLED) ? WS_DISABLED : 0; |
| 2695 | if( bwaFlags & BWA_SKIPICONIC ) skipFlags |= WS_MINIMIZE; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2696 | |
| 2697 | /* First count the windows */ |
| 2698 | |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2699 | if (!wndPtr) |
| 2700 | wndPtr = WIN_GetDesktop(); |
| 2701 | |
| 2702 | pWnd = WIN_LockWndPtr(wndPtr->child); |
| 2703 | while (pWnd) |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 2704 | { |
Alex Korobka | 44a1b59 | 1999-04-01 12:03:52 +0000 | [diff] [blame] | 2705 | if( !(pWnd->dwStyle & skipFlags) && !(skipOwned && pWnd->owner) && |
| 2706 | (!skipHidden || (pWnd->dwStyle & WS_VISIBLE)) ) |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2707 | count++; |
Alex Korobka | 44a1b59 | 1999-04-01 12:03:52 +0000 | [diff] [blame] | 2708 | WIN_UpdateWndPtr(&pWnd,pWnd->next); |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 2709 | } |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2710 | |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 2711 | if( count ) |
| 2712 | { |
| 2713 | /* Now build the list of all windows */ |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2714 | |
Alexandre Julliard | 90476d6 | 2000-02-16 22:47:24 +0000 | [diff] [blame] | 2715 | if ((list = (WND **)HeapAlloc( GetProcessHeap(), 0, sizeof(WND *) * (count + 1)))) |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 2716 | { |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2717 | for (pWnd = WIN_LockWndPtr(wndPtr->child), ppWnd = list, count = 0; pWnd; WIN_UpdateWndPtr(&pWnd,pWnd->next)) |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 2718 | { |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2719 | if( (pWnd->dwStyle & skipFlags) || (skipOwned && pWnd->owner) ); |
| 2720 | else if( !skipHidden || pWnd->dwStyle & WS_VISIBLE ) |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 2721 | { |
| 2722 | *ppWnd++ = pWnd; |
| 2723 | count++; |
| 2724 | } |
| 2725 | } |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2726 | WIN_ReleaseWndPtr(pWnd); |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 2727 | *ppWnd = NULL; |
| 2728 | } |
| 2729 | else count = 0; |
| 2730 | } else list = NULL; |
| 2731 | |
| 2732 | if( pTotal ) *pTotal = count; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2733 | return list; |
| 2734 | } |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2735 | /******************************************************************* |
| 2736 | * WIN_ReleaseWinArray |
| 2737 | */ |
| 2738 | void WIN_ReleaseWinArray(WND **wndArray) |
| 2739 | { |
Andreas Mohr | 1c20b39 | 2000-02-20 19:17:35 +0000 | [diff] [blame] | 2740 | /* Future: this function will also unlock all windows associated with wndArray */ |
Alexandre Julliard | 90476d6 | 2000-02-16 22:47:24 +0000 | [diff] [blame] | 2741 | HeapFree( GetProcessHeap(), 0, wndArray ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2742 | |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2743 | } |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2744 | |
| 2745 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2746 | * EnumWindows (USER32.@) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2747 | */ |
Alexandre Julliard | d6c0d86 | 2000-03-24 21:38:30 +0000 | [diff] [blame] | 2748 | BOOL WINAPI EnumWindows( WNDENUMPROC lpEnumFunc, LPARAM lParam ) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2749 | { |
| 2750 | WND **list, **ppWnd; |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 2751 | |
Alexandre Julliard | 594997c | 1995-04-30 10:05:20 +0000 | [diff] [blame] | 2752 | /* We have to build a list of all windows first, to avoid */ |
Andreas Mohr | 1c20b39 | 2000-02-20 19:17:35 +0000 | [diff] [blame] | 2753 | /* unpleasant side-effects, for instance if the callback */ |
| 2754 | /* function changes the Z-order of the windows. */ |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 2755 | |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2756 | if (!(list = WIN_BuildWinArray(WIN_GetDesktop(), 0, NULL ))) |
| 2757 | { |
| 2758 | WIN_ReleaseDesktop(); |
| 2759 | return FALSE; |
| 2760 | } |
Alexandre Julliard | 594997c | 1995-04-30 10:05:20 +0000 | [diff] [blame] | 2761 | |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2762 | /* Now call the callback function for every window */ |
Alexandre Julliard | 594997c | 1995-04-30 10:05:20 +0000 | [diff] [blame] | 2763 | |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2764 | for (ppWnd = list; *ppWnd; ppWnd++) |
Alexandre Julliard | 594997c | 1995-04-30 10:05:20 +0000 | [diff] [blame] | 2765 | { |
Francois Boisvert | d96bc15 | 1999-04-02 10:34:43 +0000 | [diff] [blame] | 2766 | LRESULT lpEnumFuncRetval; |
| 2767 | int iWndsLocks = 0; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2768 | /* Make sure that the window still exists */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2769 | if (!IsWindow((*ppWnd)->hwndSelf)) continue; |
Francois Boisvert | d96bc15 | 1999-04-02 10:34:43 +0000 | [diff] [blame] | 2770 | |
| 2771 | /* To avoid any deadlocks, all the locks on the windows |
| 2772 | structures must be suspended before the control |
| 2773 | is passed to the application */ |
| 2774 | iWndsLocks = WIN_SuspendWndsLock(); |
| 2775 | lpEnumFuncRetval = lpEnumFunc( (*ppWnd)->hwndSelf, lParam); |
| 2776 | WIN_RestoreWndsLock(iWndsLocks); |
| 2777 | |
| 2778 | if (!lpEnumFuncRetval) break; |
Alexandre Julliard | 594997c | 1995-04-30 10:05:20 +0000 | [diff] [blame] | 2779 | } |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2780 | WIN_ReleaseWinArray(list); |
| 2781 | WIN_ReleaseDesktop(); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2782 | return TRUE; |
| 2783 | } |
| 2784 | |
| 2785 | |
Alexandre Julliard | 594997c | 1995-04-30 10:05:20 +0000 | [diff] [blame] | 2786 | /********************************************************************** |
Alexandre Julliard | 66ffa17 | 2001-04-04 18:32:14 +0000 | [diff] [blame] | 2787 | * WIN_EnumQueueWindows |
| 2788 | * |
| 2789 | * Helper for EnumTaskWindows16 and EnumThreadWindows. |
Alexandre Julliard | 594997c | 1995-04-30 10:05:20 +0000 | [diff] [blame] | 2790 | */ |
Alexandre Julliard | 66ffa17 | 2001-04-04 18:32:14 +0000 | [diff] [blame] | 2791 | static BOOL WIN_EnumQueueWindows( HQUEUE16 queue, WNDENUMPROC func, LPARAM lParam ) |
Alexandre Julliard | 594997c | 1995-04-30 10:05:20 +0000 | [diff] [blame] | 2792 | { |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2793 | WND **list, **ppWnd; |
Alexandre Julliard | 594997c | 1995-04-30 10:05:20 +0000 | [diff] [blame] | 2794 | |
| 2795 | /* This function is the same as EnumWindows(), */ |
Per Ångström | a47bc3a | 1998-11-14 17:00:37 +0000 | [diff] [blame] | 2796 | /* except for an added check on the window's task. */ |
Alexandre Julliard | 594997c | 1995-04-30 10:05:20 +0000 | [diff] [blame] | 2797 | |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2798 | if (!(list = WIN_BuildWinArray( WIN_GetDesktop(), 0, NULL ))) |
| 2799 | { |
| 2800 | WIN_ReleaseDesktop(); |
| 2801 | return FALSE; |
| 2802 | } |
Alexandre Julliard | 594997c | 1995-04-30 10:05:20 +0000 | [diff] [blame] | 2803 | |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2804 | /* Now call the callback function for every window */ |
Alexandre Julliard | 594997c | 1995-04-30 10:05:20 +0000 | [diff] [blame] | 2805 | |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2806 | for (ppWnd = list; *ppWnd; ppWnd++) |
Alexandre Julliard | 594997c | 1995-04-30 10:05:20 +0000 | [diff] [blame] | 2807 | { |
Francois Boisvert | d96bc15 | 1999-04-02 10:34:43 +0000 | [diff] [blame] | 2808 | LRESULT funcRetval; |
| 2809 | int iWndsLocks = 0; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2810 | /* Make sure that the window still exists */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2811 | if (!IsWindow((*ppWnd)->hwndSelf)) continue; |
Alexandre Julliard | 66ffa17 | 2001-04-04 18:32:14 +0000 | [diff] [blame] | 2812 | if ((*ppWnd)->hmemTaskQ != queue) continue; |
| 2813 | |
Francois Boisvert | d96bc15 | 1999-04-02 10:34:43 +0000 | [diff] [blame] | 2814 | /* To avoid any deadlocks, all the locks on the windows |
| 2815 | structures must be suspended before the control |
| 2816 | is passed to the application */ |
| 2817 | iWndsLocks = WIN_SuspendWndsLock(); |
| 2818 | funcRetval = func( (*ppWnd)->hwndSelf, lParam ); |
| 2819 | WIN_RestoreWndsLock(iWndsLocks); |
Alexandre Julliard | 66ffa17 | 2001-04-04 18:32:14 +0000 | [diff] [blame] | 2820 | |
Francois Boisvert | d96bc15 | 1999-04-02 10:34:43 +0000 | [diff] [blame] | 2821 | if (!funcRetval) break; |
Alexandre Julliard | 594997c | 1995-04-30 10:05:20 +0000 | [diff] [blame] | 2822 | } |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2823 | WIN_ReleaseWinArray(list); |
| 2824 | WIN_ReleaseDesktop(); |
Alexandre Julliard | 594997c | 1995-04-30 10:05:20 +0000 | [diff] [blame] | 2825 | return TRUE; |
| 2826 | } |
| 2827 | |
| 2828 | |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2829 | /********************************************************************** |
Alexandre Julliard | 66ffa17 | 2001-04-04 18:32:14 +0000 | [diff] [blame] | 2830 | * EnumTaskWindows16 (USER.225) |
| 2831 | */ |
| 2832 | BOOL16 WINAPI EnumTaskWindows16( HTASK16 hTask, WNDENUMPROC16 func, |
| 2833 | LPARAM lParam ) |
| 2834 | { |
| 2835 | HQUEUE16 queue = GetTaskQueue16( hTask ); |
| 2836 | if (!queue) return FALSE; |
| 2837 | return WIN_EnumQueueWindows( queue, (WNDENUMPROC)func, lParam ); |
| 2838 | } |
| 2839 | |
| 2840 | |
| 2841 | /********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2842 | * EnumThreadWindows (USER32.@) |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 2843 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2844 | BOOL WINAPI EnumThreadWindows( DWORD id, WNDENUMPROC func, LPARAM lParam ) |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 2845 | { |
Alexandre Julliard | 66ffa17 | 2001-04-04 18:32:14 +0000 | [diff] [blame] | 2846 | HQUEUE16 queue = GetThreadQueue16( id ); |
| 2847 | if (!queue) return FALSE; |
| 2848 | return WIN_EnumQueueWindows( queue, func, lParam ); |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 2849 | } |
| 2850 | |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 2851 | |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2852 | /********************************************************************** |
Alexandre Julliard | f1aa303 | 1996-08-05 17:42:43 +0000 | [diff] [blame] | 2853 | * WIN_EnumChildWindows |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 2854 | * |
Alexandre Julliard | f1aa303 | 1996-08-05 17:42:43 +0000 | [diff] [blame] | 2855 | * Helper function for EnumChildWindows(). |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 2856 | */ |
Alexandre Julliard | d6c0d86 | 2000-03-24 21:38:30 +0000 | [diff] [blame] | 2857 | static BOOL16 WIN_EnumChildWindows( WND **ppWnd, WNDENUMPROC func, LPARAM lParam ) |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 2858 | { |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2859 | WND **childList; |
| 2860 | BOOL16 ret = FALSE; |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 2861 | |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 2862 | for ( ; *ppWnd; ppWnd++) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2863 | { |
Francois Boisvert | d96bc15 | 1999-04-02 10:34:43 +0000 | [diff] [blame] | 2864 | int iWndsLocks = 0; |
| 2865 | |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2866 | /* Make sure that the window still exists */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2867 | if (!IsWindow((*ppWnd)->hwndSelf)) continue; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2868 | /* Build children list first */ |
Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 2869 | childList = WIN_BuildWinArray( *ppWnd, BWA_SKIPOWNED, NULL ); |
Francois Boisvert | d96bc15 | 1999-04-02 10:34:43 +0000 | [diff] [blame] | 2870 | |
| 2871 | /* To avoid any deadlocks, all the locks on the windows |
| 2872 | structures must be suspended before the control |
| 2873 | is passed to the application */ |
| 2874 | iWndsLocks = WIN_SuspendWndsLock(); |
Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 2875 | ret = func( (*ppWnd)->hwndSelf, lParam ); |
Francois Boisvert | d96bc15 | 1999-04-02 10:34:43 +0000 | [diff] [blame] | 2876 | WIN_RestoreWndsLock(iWndsLocks); |
| 2877 | |
Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 2878 | if (childList) |
| 2879 | { |
| 2880 | if (ret) ret = WIN_EnumChildWindows( childList, func, lParam ); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2881 | WIN_ReleaseWinArray(childList); |
Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 2882 | } |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2883 | if (!ret) return FALSE; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2884 | } |
| 2885 | return TRUE; |
| 2886 | } |
| 2887 | |
| 2888 | |
| 2889 | /********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2890 | * EnumChildWindows (USER32.@) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2891 | */ |
Alexandre Julliard | d6c0d86 | 2000-03-24 21:38:30 +0000 | [diff] [blame] | 2892 | BOOL WINAPI EnumChildWindows( HWND parent, WNDENUMPROC func, |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 2893 | LPARAM lParam ) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2894 | { |
| 2895 | WND **list, *pParent; |
| 2896 | |
| 2897 | if (!(pParent = WIN_FindWndPtr( parent ))) return FALSE; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2898 | if (!(list = WIN_BuildWinArray( pParent, BWA_SKIPOWNED, NULL ))) |
| 2899 | { |
| 2900 | WIN_ReleaseWndPtr(pParent); |
| 2901 | return FALSE; |
| 2902 | } |
Alexandre Julliard | f1aa303 | 1996-08-05 17:42:43 +0000 | [diff] [blame] | 2903 | WIN_EnumChildWindows( list, func, lParam ); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2904 | WIN_ReleaseWinArray(list); |
| 2905 | WIN_ReleaseWndPtr(pParent); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2906 | return TRUE; |
| 2907 | } |
| 2908 | |
| 2909 | |
Alexandre Julliard | 5819953 | 1994-04-21 01:20:00 +0000 | [diff] [blame] | 2910 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2911 | * AnyPopup (USER.52) |
Alexandre Julliard | d18872d | 1994-05-11 12:18:19 +0000 | [diff] [blame] | 2912 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 2913 | BOOL16 WINAPI AnyPopup16(void) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2914 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2915 | return AnyPopup(); |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2916 | } |
| 2917 | |
| 2918 | |
| 2919 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2920 | * AnyPopup (USER32.@) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2921 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2922 | BOOL WINAPI AnyPopup(void) |
Alexandre Julliard | d18872d | 1994-05-11 12:18:19 +0000 | [diff] [blame] | 2923 | { |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2924 | WND *wndPtr = WIN_LockWndPtr(pWndDesktop->child); |
| 2925 | BOOL retvalue; |
| 2926 | |
| 2927 | while (wndPtr) |
| 2928 | { |
| 2929 | if (wndPtr->owner && (wndPtr->dwStyle & WS_VISIBLE)) |
| 2930 | { |
| 2931 | retvalue = TRUE; |
| 2932 | goto end; |
Andreas Mohr | 1c20b39 | 2000-02-20 19:17:35 +0000 | [diff] [blame] | 2933 | } |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2934 | WIN_UpdateWndPtr(&wndPtr,wndPtr->next); |
| 2935 | } |
| 2936 | retvalue = FALSE; |
| 2937 | end: |
| 2938 | WIN_ReleaseWndPtr(wndPtr); |
| 2939 | return retvalue; |
Alexandre Julliard | d18872d | 1994-05-11 12:18:19 +0000 | [diff] [blame] | 2940 | } |
| 2941 | |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2942 | |
Alexandre Julliard | 73450d6 | 1994-05-18 18:29:32 +0000 | [diff] [blame] | 2943 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2944 | * FlashWindow (USER.105) |
Alexandre Julliard | 73450d6 | 1994-05-18 18:29:32 +0000 | [diff] [blame] | 2945 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 2946 | BOOL16 WINAPI FlashWindow16( HWND16 hWnd, BOOL16 bInvert ) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2947 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2948 | return FlashWindow( hWnd, bInvert ); |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2949 | } |
| 2950 | |
| 2951 | |
| 2952 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2953 | * FlashWindow (USER32.@) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2954 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2955 | BOOL WINAPI FlashWindow( HWND hWnd, BOOL bInvert ) |
Alexandre Julliard | 73450d6 | 1994-05-18 18:29:32 +0000 | [diff] [blame] | 2956 | { |
Alexandre Julliard | 7d654eb | 1996-02-25 11:36:22 +0000 | [diff] [blame] | 2957 | WND *wndPtr = WIN_FindWndPtr(hWnd); |
| 2958 | |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 2959 | TRACE("%04x\n", hWnd); |
Alexandre Julliard | 7d654eb | 1996-02-25 11:36:22 +0000 | [diff] [blame] | 2960 | |
| 2961 | if (!wndPtr) return FALSE; |
| 2962 | |
| 2963 | if (wndPtr->dwStyle & WS_MINIMIZE) |
| 2964 | { |
| 2965 | if (bInvert && !(wndPtr->flags & WIN_NCACTIVATED)) |
| 2966 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2967 | HDC hDC = GetDC(hWnd); |
Alexandre Julliard | 7d654eb | 1996-02-25 11:36:22 +0000 | [diff] [blame] | 2968 | |
Alexandre Julliard | 530ee84 | 1996-10-23 16:59:13 +0000 | [diff] [blame] | 2969 | if (!SendMessage16( hWnd, WM_ERASEBKGND, (WPARAM16)hDC, 0 )) |
Alexandre Julliard | 7d654eb | 1996-02-25 11:36:22 +0000 | [diff] [blame] | 2970 | wndPtr->flags |= WIN_NEEDS_ERASEBKGND; |
| 2971 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2972 | ReleaseDC( hWnd, hDC ); |
Alexandre Julliard | 7d654eb | 1996-02-25 11:36:22 +0000 | [diff] [blame] | 2973 | wndPtr->flags |= WIN_NCACTIVATED; |
| 2974 | } |
| 2975 | else |
| 2976 | { |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 2977 | RedrawWindow( hWnd, 0, 0, RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW | RDW_FRAME ); |
Alexandre Julliard | 7d654eb | 1996-02-25 11:36:22 +0000 | [diff] [blame] | 2978 | wndPtr->flags &= ~WIN_NCACTIVATED; |
| 2979 | } |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2980 | WIN_ReleaseWndPtr(wndPtr); |
Alexandre Julliard | 7d654eb | 1996-02-25 11:36:22 +0000 | [diff] [blame] | 2981 | return TRUE; |
| 2982 | } |
| 2983 | else |
| 2984 | { |
Alexandre Julliard | 530ee84 | 1996-10-23 16:59:13 +0000 | [diff] [blame] | 2985 | WPARAM16 wparam; |
Alexandre Julliard | 7d654eb | 1996-02-25 11:36:22 +0000 | [diff] [blame] | 2986 | if (bInvert) wparam = !(wndPtr->flags & WIN_NCACTIVATED); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2987 | else wparam = (hWnd == GetActiveWindow()); |
Alexandre Julliard | 7d654eb | 1996-02-25 11:36:22 +0000 | [diff] [blame] | 2988 | |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2989 | SendMessage16( hWnd, WM_NCACTIVATE, wparam, (LPARAM)0 ); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2990 | WIN_ReleaseWndPtr(wndPtr); |
Alexandre Julliard | 7d654eb | 1996-02-25 11:36:22 +0000 | [diff] [blame] | 2991 | return wparam; |
| 2992 | } |
Alexandre Julliard | 73450d6 | 1994-05-18 18:29:32 +0000 | [diff] [blame] | 2993 | } |
| 2994 | |
Alexandre Julliard | d18872d | 1994-05-11 12:18:19 +0000 | [diff] [blame] | 2995 | |
| 2996 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2997 | * SetSysModalWindow (USER.188) |
Alexandre Julliard | 5819953 | 1994-04-21 01:20:00 +0000 | [diff] [blame] | 2998 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 2999 | HWND16 WINAPI SetSysModalWindow16( HWND16 hWnd ) |
Alexandre Julliard | 5819953 | 1994-04-21 01:20:00 +0000 | [diff] [blame] | 3000 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 3001 | HWND hWndOldModal = hwndSysModal; |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 3002 | hwndSysModal = hWnd; |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 3003 | FIXME("EMPTY STUB !! SetSysModalWindow(%04x) !\n", hWnd); |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 3004 | return hWndOldModal; |
Alexandre Julliard | 5819953 | 1994-04-21 01:20:00 +0000 | [diff] [blame] | 3005 | } |
| 3006 | |
Alexandre Julliard | d18872d | 1994-05-11 12:18:19 +0000 | [diff] [blame] | 3007 | |
Alexandre Julliard | 1d62f6b | 1994-05-04 19:15:00 +0000 | [diff] [blame] | 3008 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 3009 | * GetSysModalWindow (USER.189) |
Alexandre Julliard | 1d62f6b | 1994-05-04 19:15:00 +0000 | [diff] [blame] | 3010 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 3011 | HWND16 WINAPI GetSysModalWindow16(void) |
Alexandre Julliard | 1d62f6b | 1994-05-04 19:15:00 +0000 | [diff] [blame] | 3012 | { |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 3013 | return hwndSysModal; |
Alexandre Julliard | 1d62f6b | 1994-05-04 19:15:00 +0000 | [diff] [blame] | 3014 | } |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3015 | |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 3016 | |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3017 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 3018 | * GetWindowContextHelpId (USER32.@) |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 3019 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 3020 | DWORD WINAPI GetWindowContextHelpId( HWND hwnd ) |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 3021 | { |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 3022 | DWORD retval; |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 3023 | WND *wnd = WIN_FindWndPtr( hwnd ); |
| 3024 | if (!wnd) return 0; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 3025 | retval = wnd->helpContext; |
| 3026 | WIN_ReleaseWndPtr(wnd); |
| 3027 | return retval; |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 3028 | } |
| 3029 | |
| 3030 | |
| 3031 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 3032 | * SetWindowContextHelpId (USER32.@) |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 3033 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 3034 | BOOL WINAPI SetWindowContextHelpId( HWND hwnd, DWORD id ) |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 3035 | { |
| 3036 | WND *wnd = WIN_FindWndPtr( hwnd ); |
| 3037 | if (!wnd) return FALSE; |
| 3038 | wnd->helpContext = id; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 3039 | WIN_ReleaseWndPtr(wnd); |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 3040 | return TRUE; |
| 3041 | } |
| 3042 | |
| 3043 | |
| 3044 | /******************************************************************* |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3045 | * DRAG_QueryUpdate |
| 3046 | * |
| 3047 | * recursively find a child that contains spDragInfo->pt point |
| 3048 | * and send WM_QUERYDROPOBJECT |
| 3049 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 3050 | BOOL16 DRAG_QueryUpdate( HWND hQueryWnd, SEGPTR spDragInfo, BOOL bNoSend ) |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3051 | { |
Andreas Mohr | 1c20b39 | 2000-02-20 19:17:35 +0000 | [diff] [blame] | 3052 | BOOL16 wParam, bResult = 0; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 3053 | POINT pt; |
Alexandre Julliard | 982a223 | 2000-12-13 20:20:09 +0000 | [diff] [blame] | 3054 | LPDRAGINFO16 ptrDragInfo = MapSL(spDragInfo); |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3055 | WND *ptrQueryWnd = WIN_FindWndPtr(hQueryWnd),*ptrWnd; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 3056 | RECT tempRect; |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3057 | |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 3058 | if( !ptrQueryWnd || !ptrDragInfo ) |
Andreas Mohr | 1c20b39 | 2000-02-20 19:17:35 +0000 | [diff] [blame] | 3059 | goto end; |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3060 | |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 3061 | CONV_POINT16TO32( &ptrDragInfo->pt, &pt ); |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3062 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 3063 | GetWindowRect(hQueryWnd,&tempRect); |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3064 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 3065 | if( !PtInRect(&tempRect,pt) || |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3066 | (ptrQueryWnd->dwStyle & WS_DISABLED) ) |
Andreas Mohr | 1c20b39 | 2000-02-20 19:17:35 +0000 | [diff] [blame] | 3067 | goto end; |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3068 | |
| 3069 | if( !(ptrQueryWnd->dwStyle & WS_MINIMIZE) ) |
| 3070 | { |
| 3071 | tempRect = ptrQueryWnd->rectClient; |
Alexandre Julliard | f88e5aa | 2001-03-21 23:55:36 +0000 | [diff] [blame] | 3072 | if(ptrQueryWnd->parent) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 3073 | MapWindowPoints( ptrQueryWnd->parent->hwndSelf, 0, |
| 3074 | (LPPOINT)&tempRect, 2 ); |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3075 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 3076 | if (PtInRect( &tempRect, pt)) |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3077 | { |
| 3078 | wParam = 0; |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 3079 | |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 3080 | for (ptrWnd = WIN_LockWndPtr(ptrQueryWnd->child); ptrWnd ;WIN_UpdateWndPtr(&ptrWnd,ptrWnd->next)) |
| 3081 | { |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 3082 | if( ptrWnd->dwStyle & WS_VISIBLE ) |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3083 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 3084 | GetWindowRect( ptrWnd->hwndSelf, &tempRect ); |
| 3085 | if (PtInRect( &tempRect, pt )) break; |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3086 | } |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 3087 | } |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3088 | |
| 3089 | if(ptrWnd) |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 3090 | { |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 3091 | TRACE_(msg)("hwnd = %04x, %d %d - %d %d\n", |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 3092 | ptrWnd->hwndSelf, ptrWnd->rectWindow.left, ptrWnd->rectWindow.top, |
| 3093 | ptrWnd->rectWindow.right, ptrWnd->rectWindow.bottom ); |
| 3094 | if( !(ptrWnd->dwStyle & WS_DISABLED) ) |
Alexandre Julliard | 75d86e1 | 1996-11-17 18:59:11 +0000 | [diff] [blame] | 3095 | bResult = DRAG_QueryUpdate(ptrWnd->hwndSelf, spDragInfo, bNoSend); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 3096 | |
| 3097 | WIN_ReleaseWndPtr(ptrWnd); |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 3098 | } |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3099 | |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 3100 | if(bResult) |
Andreas Mohr | 1c20b39 | 2000-02-20 19:17:35 +0000 | [diff] [blame] | 3101 | goto end; |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3102 | } |
| 3103 | else wParam = 1; |
| 3104 | } |
| 3105 | else wParam = 1; |
| 3106 | |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 3107 | ScreenToClient16(hQueryWnd,&ptrDragInfo->pt); |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3108 | |
| 3109 | ptrDragInfo->hScope = hQueryWnd; |
| 3110 | |
Alexandre Julliard | 75d86e1 | 1996-11-17 18:59:11 +0000 | [diff] [blame] | 3111 | bResult = ( bNoSend ) |
| 3112 | ? ptrQueryWnd->dwExStyle & WS_EX_ACCEPTFILES |
| 3113 | : SendMessage16( hQueryWnd ,WM_QUERYDROPOBJECT , |
Alexandre Julliard | 530ee84 | 1996-10-23 16:59:13 +0000 | [diff] [blame] | 3114 | (WPARAM16)wParam ,(LPARAM) spDragInfo ); |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3115 | if( !bResult ) |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 3116 | CONV_POINT32TO16( &pt, &ptrDragInfo->pt ); |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3117 | |
Andreas Mohr | 1c20b39 | 2000-02-20 19:17:35 +0000 | [diff] [blame] | 3118 | end: |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 3119 | WIN_ReleaseWndPtr(ptrQueryWnd); |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3120 | return bResult; |
| 3121 | } |
| 3122 | |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 3123 | |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3124 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 3125 | * DragDetect (USER.465) |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3126 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 3127 | BOOL16 WINAPI DragDetect16( HWND16 hWnd, POINT16 pt ) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 3128 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 3129 | POINT pt32; |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 3130 | CONV_POINT16TO32( &pt, &pt32 ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 3131 | return DragDetect( hWnd, pt32 ); |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 3132 | } |
| 3133 | |
| 3134 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 3135 | * DragDetect (USER32.@) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 3136 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 3137 | BOOL WINAPI DragDetect( HWND hWnd, POINT pt ) |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3138 | { |
Alexandre Julliard | 0ff083b | 2000-09-24 19:51:15 +0000 | [diff] [blame] | 3139 | MSG msg; |
| 3140 | RECT rect; |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3141 | |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3142 | rect.left = pt.x - wDragWidth; |
| 3143 | rect.right = pt.x + wDragWidth; |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3144 | |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3145 | rect.top = pt.y - wDragHeight; |
| 3146 | rect.bottom = pt.y + wDragHeight; |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3147 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 3148 | SetCapture(hWnd); |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3149 | |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3150 | while(1) |
| 3151 | { |
Alexandre Julliard | 0ff083b | 2000-09-24 19:51:15 +0000 | [diff] [blame] | 3152 | while(PeekMessageA(&msg ,0 ,WM_MOUSEFIRST ,WM_MOUSELAST ,PM_REMOVE)) |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3153 | { |
| 3154 | if( msg.message == WM_LBUTTONUP ) |
| 3155 | { |
| 3156 | ReleaseCapture(); |
| 3157 | return 0; |
| 3158 | } |
| 3159 | if( msg.message == WM_MOUSEMOVE ) |
| 3160 | { |
Alexandre Julliard | 0ff083b | 2000-09-24 19:51:15 +0000 | [diff] [blame] | 3161 | POINT tmp; |
| 3162 | tmp.x = LOWORD(msg.lParam); |
| 3163 | tmp.y = HIWORD(msg.lParam); |
| 3164 | if( !PtInRect( &rect, tmp )) |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3165 | { |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3166 | ReleaseCapture(); |
| 3167 | return 1; |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3168 | } |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3169 | } |
| 3170 | } |
| 3171 | WaitMessage(); |
| 3172 | } |
| 3173 | return 0; |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3174 | } |
| 3175 | |
| 3176 | /****************************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 3177 | * DragObject (USER.464) |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3178 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 3179 | DWORD WINAPI DragObject16( HWND16 hwndScope, HWND16 hWnd, UINT16 wObj, |
| 3180 | HANDLE16 hOfStruct, WORD szList, HCURSOR16 hCursor ) |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3181 | { |
Alexandre Julliard | 0ff083b | 2000-09-24 19:51:15 +0000 | [diff] [blame] | 3182 | MSG msg; |
Alexandre Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 3183 | LPDRAGINFO16 lpDragInfo; |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3184 | SEGPTR spDragInfo; |
| 3185 | HCURSOR16 hDragCursor=0, hOldCursor=0, hBummer=0; |
Alexandre Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 3186 | HGLOBAL16 hDragInfo = GlobalAlloc16( GMEM_SHARE | GMEM_ZEROINIT, 2*sizeof(DRAGINFO16)); |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3187 | WND *wndPtr = WIN_FindWndPtr(hWnd); |
| 3188 | HCURSOR16 hCurrentCursor = 0; |
| 3189 | HWND16 hCurrentWnd = 0; |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3190 | |
Alexandre Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 3191 | lpDragInfo = (LPDRAGINFO16) GlobalLock16(hDragInfo); |
Alexandre Julliard | 5801723 | 2000-12-22 01:09:26 +0000 | [diff] [blame] | 3192 | spDragInfo = K32WOWGlobalLock16(hDragInfo); |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3193 | |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 3194 | if( !lpDragInfo || !spDragInfo ) |
| 3195 | { |
| 3196 | WIN_ReleaseWndPtr(wndPtr); |
| 3197 | return 0L; |
| 3198 | } |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3199 | |
Alexandre Julliard | 8bb7fb9 | 2001-01-20 02:48:30 +0000 | [diff] [blame] | 3200 | hBummer = LoadCursorA(0, MAKEINTRESOURCEA(OCR_NO)); |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3201 | |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3202 | if( !hBummer || !wndPtr ) |
| 3203 | { |
Alexandre Julliard | 1285c2f | 1996-05-06 16:06:24 +0000 | [diff] [blame] | 3204 | GlobalFree16(hDragInfo); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 3205 | WIN_ReleaseWndPtr(wndPtr); |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3206 | return 0L; |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3207 | } |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3208 | |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3209 | if(hCursor) |
| 3210 | { |
Alexandre Julliard | 75d86e1 | 1996-11-17 18:59:11 +0000 | [diff] [blame] | 3211 | if( !(hDragCursor = CURSORICON_IconToCursor(hCursor, FALSE)) ) |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3212 | { |
| 3213 | GlobalFree16(hDragInfo); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 3214 | WIN_ReleaseWndPtr(wndPtr); |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3215 | return 0L; |
| 3216 | } |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3217 | |
| 3218 | if( hDragCursor == hCursor ) hDragCursor = 0; |
| 3219 | else hCursor = hDragCursor; |
| 3220 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 3221 | hOldCursor = SetCursor(hDragCursor); |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3222 | } |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3223 | |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3224 | lpDragInfo->hWnd = hWnd; |
| 3225 | lpDragInfo->hScope = 0; |
| 3226 | lpDragInfo->wFlags = wObj; |
| 3227 | lpDragInfo->hList = szList; /* near pointer! */ |
| 3228 | lpDragInfo->hOfStruct = hOfStruct; |
| 3229 | lpDragInfo->l = 0L; |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3230 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 3231 | SetCapture(hWnd); |
| 3232 | ShowCursor( TRUE ); |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3233 | |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3234 | do |
| 3235 | { |
| 3236 | do{ WaitMessage(); } |
Alexandre Julliard | 0ff083b | 2000-09-24 19:51:15 +0000 | [diff] [blame] | 3237 | while( !PeekMessageA(&msg,0,WM_MOUSEFIRST,WM_MOUSELAST,PM_REMOVE) ); |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3238 | |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3239 | *(lpDragInfo+1) = *lpDragInfo; |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3240 | |
Alexandre Julliard | 0ff083b | 2000-09-24 19:51:15 +0000 | [diff] [blame] | 3241 | lpDragInfo->pt.x = msg.pt.x; |
| 3242 | lpDragInfo->pt.y = msg.pt.y; |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3243 | |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3244 | /* update DRAGINFO struct */ |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 3245 | TRACE_(msg)("lpDI->hScope = %04x\n",lpDragInfo->hScope); |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3246 | |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3247 | if( DRAG_QueryUpdate(hwndScope, spDragInfo, FALSE) > 0 ) |
| 3248 | hCurrentCursor = hCursor; |
| 3249 | else |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3250 | { |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3251 | hCurrentCursor = hBummer; |
| 3252 | lpDragInfo->hScope = 0; |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3253 | } |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3254 | if( hCurrentCursor ) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 3255 | SetCursor(hCurrentCursor); |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3256 | |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3257 | /* send WM_DRAGLOOP */ |
| 3258 | SendMessage16( hWnd, WM_DRAGLOOP, (WPARAM16)(hCurrentCursor != hBummer), |
| 3259 | (LPARAM) spDragInfo ); |
| 3260 | /* send WM_DRAGSELECT or WM_DRAGMOVE */ |
| 3261 | if( hCurrentWnd != lpDragInfo->hScope ) |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3262 | { |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3263 | if( hCurrentWnd ) |
| 3264 | SendMessage16( hCurrentWnd, WM_DRAGSELECT, 0, |
Alexandre Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 3265 | (LPARAM)MAKELONG(LOWORD(spDragInfo)+sizeof(DRAGINFO16), |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3266 | HIWORD(spDragInfo)) ); |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3267 | hCurrentWnd = lpDragInfo->hScope; |
| 3268 | if( hCurrentWnd ) |
| 3269 | SendMessage16( hCurrentWnd, WM_DRAGSELECT, 1, (LPARAM)spDragInfo); |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3270 | } |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3271 | else |
| 3272 | if( hCurrentWnd ) |
| 3273 | SendMessage16( hCurrentWnd, WM_DRAGMOVE, 0, (LPARAM)spDragInfo); |
| 3274 | |
| 3275 | } while( msg.message != WM_LBUTTONUP && msg.message != WM_NCLBUTTONUP ); |
| 3276 | |
| 3277 | ReleaseCapture(); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 3278 | ShowCursor( FALSE ); |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3279 | |
| 3280 | if( hCursor ) |
| 3281 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 3282 | SetCursor( hOldCursor ); |
| 3283 | if (hDragCursor) DestroyCursor( hDragCursor ); |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3284 | } |
| 3285 | |
| 3286 | if( hCurrentCursor != hBummer ) |
| 3287 | msg.lParam = SendMessage16( lpDragInfo->hScope, WM_DROPOBJECT, |
| 3288 | (WPARAM16)hWnd, (LPARAM)spDragInfo ); |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3289 | else |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3290 | msg.lParam = 0; |
| 3291 | GlobalFree16(hDragInfo); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 3292 | WIN_ReleaseWndPtr(wndPtr); |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3293 | |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3294 | return (DWORD)(msg.lParam); |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3295 | } |
Eric Kohl | ca6c9a6 | 2001-03-20 01:53:51 +0000 | [diff] [blame] | 3296 | |
| 3297 | |
| 3298 | /****************************************************************************** |
| 3299 | * GetWindowModuleFileNameA (USER32.@) |
| 3300 | */ |
| 3301 | UINT WINAPI GetWindowModuleFileNameA( HWND hwnd, LPSTR lpszFileName, UINT cchFileNameMax) |
| 3302 | { |
| 3303 | FIXME("GetWindowModuleFileNameA(hwnd 0x%x, lpszFileName %p, cchFileNameMax %u) stub!\n", |
| 3304 | hwnd, lpszFileName, cchFileNameMax); |
| 3305 | return 0; |
| 3306 | } |
| 3307 | |
| 3308 | /****************************************************************************** |
| 3309 | * GetWindowModuleFileNameW (USER32.@) |
| 3310 | */ |
| 3311 | UINT WINAPI GetWindowModuleFileNameW( HWND hwnd, LPSTR lpszFileName, UINT cchFileNameMax) |
| 3312 | { |
| 3313 | FIXME("GetWindowModuleFileNameW(hwnd 0x%x, lpszFileName %p, cchFileNameMax %u) stub!\n", |
| 3314 | hwnd, lpszFileName, cchFileNameMax); |
| 3315 | return 0; |
| 3316 | } |