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