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