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