2 * Window related functions
4 * Copyright 1993, 1994 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "wine/port.h"
30 #include "wine/winbase16.h"
31 #include "wine/winuser16.h"
33 #include "wine/server.h"
34 #include "wine/unicode.h"
39 #include "cursoricon.h"
43 #include "wine/debug.h"
45 WINE_DEFAULT_DEBUG_CHANNEL(win
);
46 WINE_DECLARE_DEBUG_CHANNEL(msg
);
48 #define NB_USER_HANDLES ((LAST_USER_HANDLE - FIRST_USER_HANDLE + 1) >> 1)
49 #define USER_HANDLE_TO_INDEX(hwnd) ((LOWORD(hwnd) - FIRST_USER_HANDLE) >> 1)
51 /**********************************************************************/
54 static WND
*pWndDesktop
= NULL
;
56 static WORD wDragWidth
= 4;
57 static WORD wDragHeight
= 3;
59 static void *user_handles
[NB_USER_HANDLES
];
61 /***********************************************************************
62 * create_window_handle
64 * Create a window handle with the server.
66 static WND
*create_window_handle( HWND parent
, HWND owner
, ATOM atom
,
67 HINSTANCE instance
, WINDOWPROCTYPE type
)
71 struct tagCLASS
*class = NULL
;
72 user_handle_t handle
= 0;
75 /* if 16-bit instance, map to module handle */
76 if (instance
&& !HIWORD(instance
))
77 instance
= HINSTANCE_32(GetExePtr(HINSTANCE_16(instance
)));
79 SERVER_START_REQ( create_window
)
84 req
->instance
= instance
;
85 if (!wine_server_call_err( req
))
87 handle
= reply
->handle
;
88 extra_bytes
= reply
->extra
;
89 class = reply
->class_ptr
;
96 WARN( "error %ld creating window\n", GetLastError() );
100 if (!(win
= HeapAlloc( GetProcessHeap(), 0, sizeof(WND
) + extra_bytes
- sizeof(win
->wExtra
) )))
102 SERVER_START_REQ( destroy_window
)
104 req
->handle
= handle
;
105 wine_server_call( req
);
108 SetLastError( ERROR_NOT_ENOUGH_MEMORY
);
114 index
= USER_HANDLE_TO_INDEX(handle
);
115 assert( index
< NB_USER_HANDLES
);
116 user_handles
[index
] = win
;
117 win
->hwndSelf
= handle
;
118 win
->dwMagic
= WND_MAGIC
;
120 win
->cbWndExtra
= extra_bytes
;
121 memset( win
->wExtra
, 0, extra_bytes
);
122 CLASS_AddWindow( class, win
, type
);
127 /***********************************************************************
130 * Free a window handle.
132 static WND
*free_window_handle( HWND hwnd
)
135 WORD index
= USER_HANDLE_TO_INDEX(hwnd
);
137 if (index
>= NB_USER_HANDLES
) return NULL
;
139 if ((ptr
= user_handles
[index
]))
141 SERVER_START_REQ( destroy_window
)
144 if (!wine_server_call_err( req
))
145 user_handles
[index
] = NULL
;
152 if (ptr
) HeapFree( GetProcessHeap(), 0, ptr
);
157 /*******************************************************************
158 * list_window_children
160 * Build an array of the children of a given window. The array must be
161 * freed with HeapFree. Returns NULL when no windows are found.
163 static HWND
*list_window_children( HWND hwnd
, ATOM atom
, DWORD tid
)
172 if (!(list
= HeapAlloc( GetProcessHeap(), 0, size
* sizeof(HWND
) ))) break;
174 SERVER_START_REQ( get_window_children
)
179 wine_server_set_reply( req
, list
, (size
-1) * sizeof(HWND
) );
180 if (!wine_server_call( req
)) count
= reply
->count
;
183 if (count
&& count
< size
)
188 HeapFree( GetProcessHeap(), 0, list
);
190 size
= count
+ 1; /* restart with a large enough buffer */
196 /*******************************************************************
199 static void send_parent_notify( HWND hwnd
, UINT msg
)
201 if ((GetWindowLongW( hwnd
, GWL_STYLE
) & (WS_CHILD
| WS_POPUP
)) == WS_CHILD
&&
202 !(GetWindowLongW( hwnd
, GWL_EXSTYLE
) & WS_EX_NOPARENTNOTIFY
))
203 SendMessageW( GetParent(hwnd
), WM_PARENTNOTIFY
,
204 MAKEWPARAM( msg
, GetWindowLongW( hwnd
, GWL_ID
)), (LPARAM
)hwnd
);
208 /*******************************************************************
209 * get_server_window_text
211 * Retrieve the window text from the server.
213 static void get_server_window_text( HWND hwnd
, LPWSTR text
, INT count
)
217 SERVER_START_REQ( get_window_text
)
220 wine_server_set_reply( req
, text
, (count
- 1) * sizeof(WCHAR
) );
221 if (!wine_server_call_err( req
)) len
= wine_server_reply_size(reply
);
224 text
[len
/ sizeof(WCHAR
)] = 0;
228 /***********************************************************************
231 * Return a pointer to the WND structure if local to the process,
232 * or WND_OTHER_PROCESS if handle may be valid in other process.
233 * If ret value is a valid pointer, it must be released with WIN_ReleasePtr.
235 WND
*WIN_GetPtr( HWND hwnd
)
238 WORD index
= USER_HANDLE_TO_INDEX(hwnd
);
240 if (index
>= NB_USER_HANDLES
) return NULL
;
243 if ((ptr
= user_handles
[index
]))
245 if (ptr
->dwMagic
== WND_MAGIC
&& (!HIWORD(hwnd
) || hwnd
== ptr
->hwndSelf
))
249 else ptr
= WND_OTHER_PROCESS
;
255 /***********************************************************************
256 * WIN_IsCurrentProcess
258 * Check whether a given window belongs to the current process (and return the full handle).
260 HWND
WIN_IsCurrentProcess( HWND hwnd
)
265 if (!(ptr
= WIN_GetPtr( hwnd
)) || ptr
== WND_OTHER_PROCESS
) return 0;
267 WIN_ReleasePtr( ptr
);
272 /***********************************************************************
273 * WIN_IsCurrentThread
275 * Check whether a given window belongs to the current thread (and return the full handle).
277 HWND
WIN_IsCurrentThread( HWND hwnd
)
282 if ((ptr
= WIN_GetPtr( hwnd
)) && ptr
!= WND_OTHER_PROCESS
)
284 if (ptr
->tid
== GetCurrentThreadId()) ret
= ptr
->hwndSelf
;
285 WIN_ReleasePtr( ptr
);
291 /***********************************************************************
294 * Convert a 16-bit window handle to a full 32-bit handle.
296 HWND
WIN_Handle32( HWND16 hwnd16
)
299 HWND hwnd
= (HWND
)(ULONG_PTR
)hwnd16
;
301 if (hwnd16
<= 1 || hwnd16
== 0xffff) return hwnd
;
302 /* do sign extension for -2 and -3 */
303 if (hwnd16
>= (HWND16
)-3) return (HWND
)(LONG_PTR
)(INT16
)hwnd16
;
305 if (!(ptr
= WIN_GetPtr( hwnd
))) return hwnd
;
307 if (ptr
!= WND_OTHER_PROCESS
)
309 hwnd
= ptr
->hwndSelf
;
310 WIN_ReleasePtr( ptr
);
312 else /* may belong to another process */
314 SERVER_START_REQ( get_window_info
)
317 if (!wine_server_call_err( req
)) hwnd
= reply
->full_handle
;
325 /***********************************************************************
328 * Return a pointer to the WND structure corresponding to a HWND.
330 WND
* WIN_FindWndPtr( HWND hwnd
)
334 if (!hwnd
) return NULL
;
336 if ((ptr
= WIN_GetPtr( hwnd
)))
338 if (ptr
!= WND_OTHER_PROCESS
)
340 /* increment destruction monitoring */
344 if (IsWindow( hwnd
)) /* check other processes */
346 ERR( "window %p belongs to other process\n", hwnd
);
347 /* DbgBreakPoint(); */
350 SetLastError( ERROR_INVALID_WINDOW_HANDLE
);
355 /***********************************************************************
358 * Release the pointer to the WND structure.
360 void WIN_ReleaseWndPtr(WND
*wndPtr
)
364 /* Decrement destruction monitoring value */
366 /* Check if it's time to release the memory */
367 if(wndPtr
->irefCount
== 0 && !wndPtr
->dwMagic
)
370 free_window_handle( wndPtr
->hwndSelf
);
372 else if(wndPtr
->irefCount
< 0)
374 /* This else if is useful to monitor the WIN_ReleaseWndPtr function */
375 ERR("forgot a Lock on %p somewhere\n",wndPtr
);
377 /* unlock all WND structures for thread safeness */
382 /***********************************************************************
385 * Remove a window from the siblings linked list.
387 void WIN_UnlinkWindow( HWND hwnd
)
389 WIN_LinkWindow( hwnd
, 0, 0 );
393 /***********************************************************************
396 * Insert a window into the siblings linked list.
397 * The window is inserted after the specified window, which can also
398 * be specified as HWND_TOP or HWND_BOTTOM.
399 * If parent is 0, window is unlinked from the tree.
401 void WIN_LinkWindow( HWND hwnd
, HWND parent
, HWND hwndInsertAfter
)
403 WND
*wndPtr
= WIN_GetPtr( hwnd
);
406 if (wndPtr
== WND_OTHER_PROCESS
)
408 if (IsWindow(hwnd
)) ERR(" cannot link other process window %p\n", hwnd
);
412 SERVER_START_REQ( link_window
)
415 req
->parent
= parent
;
416 req
->previous
= hwndInsertAfter
;
417 if (!wine_server_call( req
))
419 if (reply
->full_parent
) wndPtr
->parent
= reply
->full_parent
;
424 WIN_ReleasePtr( wndPtr
);
428 /***********************************************************************
431 * Change the owner of a window.
433 HWND
WIN_SetOwner( HWND hwnd
, HWND owner
)
435 WND
*win
= WIN_GetPtr( hwnd
);
439 if (win
== WND_OTHER_PROCESS
)
441 if (IsWindow(hwnd
)) ERR( "cannot set owner %p on other process window %p\n", owner
, hwnd
);
444 SERVER_START_REQ( set_window_owner
)
448 if (!wine_server_call( req
))
450 win
->owner
= reply
->full_owner
;
451 ret
= reply
->prev_owner
;
455 WIN_ReleasePtr( win
);
460 /***********************************************************************
463 * Change the style of a window.
465 LONG
WIN_SetStyle( HWND hwnd
, LONG style
)
469 WND
*win
= WIN_GetPtr( hwnd
);
472 if (win
== WND_OTHER_PROCESS
)
475 ERR( "cannot set style %lx on other process window %p\n", style
, hwnd
);
478 if (style
== win
->dwStyle
)
480 WIN_ReleasePtr( win
);
483 SERVER_START_REQ( set_window_info
)
486 req
->flags
= SET_WIN_STYLE
;
488 req
->extra_offset
= -1;
489 if ((ok
= !wine_server_call( req
)))
491 ret
= reply
->old_style
;
492 win
->dwStyle
= style
;
496 WIN_ReleasePtr( win
);
497 if (ok
&& USER_Driver
.pSetWindowStyle
) USER_Driver
.pSetWindowStyle( hwnd
, ret
);
502 /***********************************************************************
505 * Change the extended style of a window.
507 LONG
WIN_SetExStyle( HWND hwnd
, LONG style
)
510 WND
*win
= WIN_GetPtr( hwnd
);
513 if (win
== WND_OTHER_PROCESS
)
516 ERR( "cannot set exstyle %lx on other process window %p\n", style
, hwnd
);
519 if (style
== win
->dwExStyle
)
521 WIN_ReleasePtr( win
);
524 SERVER_START_REQ( set_window_info
)
527 req
->flags
= SET_WIN_EXSTYLE
;
528 req
->ex_style
= style
;
529 req
->extra_offset
= -1;
530 if (!wine_server_call( req
))
532 ret
= reply
->old_ex_style
;
533 win
->dwExStyle
= style
;
537 WIN_ReleasePtr( win
);
542 /***********************************************************************
545 * Get the window and client rectangles.
547 BOOL
WIN_GetRectangles( HWND hwnd
, RECT
*rectWindow
, RECT
*rectClient
)
549 WND
*win
= WIN_GetPtr( hwnd
);
552 if (!win
) return FALSE
;
553 if (win
== WND_OTHER_PROCESS
)
555 SERVER_START_REQ( get_window_rectangles
)
558 if ((ret
= !wine_server_call( req
)))
562 rectWindow
->left
= reply
->window
.left
;
563 rectWindow
->top
= reply
->window
.top
;
564 rectWindow
->right
= reply
->window
.right
;
565 rectWindow
->bottom
= reply
->window
.bottom
;
569 rectClient
->left
= reply
->client
.left
;
570 rectClient
->top
= reply
->client
.top
;
571 rectClient
->right
= reply
->client
.right
;
572 rectClient
->bottom
= reply
->client
.bottom
;
580 if (rectWindow
) *rectWindow
= win
->rectWindow
;
581 if (rectClient
) *rectClient
= win
->rectClient
;
582 WIN_ReleasePtr( win
);
588 /***********************************************************************
591 * Destroy storage associated to a window. "Internals" p.358
593 LRESULT
WIN_DestroyWindow( HWND hwnd
)
598 TRACE("%p\n", hwnd
);
600 if (!(hwnd
= WIN_IsCurrentThread( hwnd
)))
602 ERR( "window doesn't belong to current thread\n" );
606 /* free child windows */
607 if ((list
= WIN_ListChildren( hwnd
)))
610 for (i
= 0; list
[i
]; i
++)
612 if (WIN_IsCurrentThread( list
[i
] )) WIN_DestroyWindow( list
[i
] );
613 else SendMessageW( list
[i
], WM_WINE_DESTROYWINDOW
, 0, 0 );
615 HeapFree( GetProcessHeap(), 0, list
);
619 * Clear the update region to make sure no WM_PAINT messages will be
620 * generated for this window while processing the WM_NCDESTROY.
622 RedrawWindow( hwnd
, NULL
, 0,
623 RDW_VALIDATE
| RDW_NOFRAME
| RDW_NOERASE
| RDW_NOINTERNALPAINT
| RDW_NOCHILDREN
);
626 * Send the WM_NCDESTROY to the window being destroyed.
628 SendMessageA( hwnd
, WM_NCDESTROY
, 0, 0);
630 /* FIXME: do we need to fake QS_MOUSEMOVE wakebit? */
632 WINPOS_CheckInternalPos( hwnd
);
633 if( hwnd
== GetCapture()) ReleaseCapture();
635 /* free resources associated with the window */
637 TIMER_RemoveWindowTimers( hwnd
);
639 if (!(wndPtr
= WIN_FindWndPtr( hwnd
))) return 0;
641 if (!(wndPtr
->dwStyle
& WS_CHILD
))
643 HMENU menu
= (HMENU
)SetWindowLongW( hwnd
, GWL_ID
, 0 );
644 if (menu
) DestroyMenu( menu
);
646 if (wndPtr
->hSysMenu
)
648 DestroyMenu( wndPtr
->hSysMenu
);
649 wndPtr
->hSysMenu
= 0;
651 DCE_FreeWindowDCE( hwnd
); /* Always do this to catch orphaned DCs */
652 USER_Driver
.pDestroyWindow( hwnd
);
653 WINPROC_FreeProc( wndPtr
->winproc
, WIN_PROC_WINDOW
);
654 wndPtr
->class = NULL
;
655 wndPtr
->dwMagic
= 0; /* Mark it as invalid */
656 WIN_ReleaseWndPtr( wndPtr
);
660 /***********************************************************************
661 * WIN_DestroyThreadWindows
663 * Destroy all children of 'wnd' owned by the current thread.
664 * Return TRUE if something was done.
666 void WIN_DestroyThreadWindows( HWND hwnd
)
671 if (!(list
= WIN_ListChildren( hwnd
))) return;
672 for (i
= 0; list
[i
]; i
++)
674 if (WIN_IsCurrentThread( list
[i
] ))
675 DestroyWindow( list
[i
] );
677 WIN_DestroyThreadWindows( list
[i
] );
679 HeapFree( GetProcessHeap(), 0, list
);
682 /***********************************************************************
683 * WIN_CreateDesktopWindow
685 * Create the desktop window.
687 BOOL
WIN_CreateDesktopWindow(void)
692 TRACE("Creating desktop window\n");
694 if (!WINPOS_CreateInternalPosAtom()) return FALSE
;
696 pWndDesktop
= create_window_handle( 0, 0, LOWORD(DESKTOP_CLASS_ATOM
), 0, WIN_PROC_32W
);
697 if (!pWndDesktop
) return FALSE
;
698 hwndDesktop
= pWndDesktop
->hwndSelf
;
700 pWndDesktop
->tid
= 0; /* nobody owns the desktop */
701 pWndDesktop
->parent
= 0;
702 pWndDesktop
->owner
= 0;
703 pWndDesktop
->text
= NULL
;
704 pWndDesktop
->hrgnUpdate
= 0;
705 pWndDesktop
->pVScroll
= NULL
;
706 pWndDesktop
->pHScroll
= NULL
;
707 pWndDesktop
->helpContext
= 0;
708 pWndDesktop
->flags
= 0;
709 pWndDesktop
->hSysMenu
= 0;
711 cs
.lpCreateParams
= NULL
;
717 cs
.cx
= GetSystemMetrics( SM_CXSCREEN
);
718 cs
.cy
= GetSystemMetrics( SM_CYSCREEN
);
719 cs
.style
= pWndDesktop
->dwStyle
;
720 cs
.dwExStyle
= pWndDesktop
->dwExStyle
;
722 cs
.lpszClass
= DESKTOP_CLASS_ATOM
;
724 SERVER_START_REQ( set_window_info
)
726 req
->handle
= hwndDesktop
;
727 req
->flags
= 0; /* don't set anything, just retrieve */
728 req
->extra_offset
= -1;
729 wine_server_call( req
);
730 pWndDesktop
->dwStyle
= reply
->old_style
;
731 pWndDesktop
->dwExStyle
= reply
->old_ex_style
;
732 pWndDesktop
->hInstance
= (HINSTANCE
)reply
->old_instance
;
733 pWndDesktop
->userdata
= (ULONG_PTR
)reply
->old_user_data
;
734 pWndDesktop
->wIDmenu
= reply
->old_id
;
738 if (!USER_Driver
.pCreateWindow( hwndDesktop
, &cs
, FALSE
))
740 WIN_ReleaseWndPtr( pWndDesktop
);
744 pWndDesktop
->flags
|= WIN_NEEDS_ERASEBKGND
;
745 WIN_ReleaseWndPtr( pWndDesktop
);
750 /***********************************************************************
753 * Fix the coordinates - Helper for WIN_CreateWindowEx.
754 * returns default show mode in sw.
755 * Note: the feature presented as undocumented *is* in the MSDN since 1993.
757 static void WIN_FixCoordinates( CREATESTRUCTA
*cs
, INT
*sw
)
759 if (cs
->x
== CW_USEDEFAULT
|| cs
->x
== CW_USEDEFAULT16
||
760 cs
->cx
== CW_USEDEFAULT
|| cs
->cx
== CW_USEDEFAULT16
)
762 if (cs
->style
& (WS_CHILD
| WS_POPUP
))
764 if (cs
->dwExStyle
& WS_EX_MDICHILD
)
768 MDI_CalcDefaultChildPos(cs
->hwndParent
, -1, pos
, 0);
770 if (cs
->x
== CW_USEDEFAULT
|| cs
->x
== CW_USEDEFAULT16
)
775 if (cs
->cx
== CW_USEDEFAULT
|| cs
->cx
== CW_USEDEFAULT16
|| !cs
->cx
)
777 if (cs
->cy
== CW_USEDEFAULT
|| cs
->cy
== CW_USEDEFAULT16
|| !cs
->cy
)
782 if (cs
->x
== CW_USEDEFAULT
|| cs
->x
== CW_USEDEFAULT16
)
784 if (cs
->cx
== CW_USEDEFAULT
|| cs
->cx
== CW_USEDEFAULT16
)
788 else /* overlapped window */
792 GetStartupInfoA( &info
);
794 if (cs
->x
== CW_USEDEFAULT
|| cs
->x
== CW_USEDEFAULT16
)
796 /* Never believe Microsoft's documentation... CreateWindowEx doc says
797 * that if an overlapped window is created with WS_VISIBLE style bit
798 * set and the x parameter is set to CW_USEDEFAULT, the system ignores
799 * the y parameter. However, disassembling NT implementation (WIN32K.SYS)
802 * 1) not only it checks for CW_USEDEFAULT but also for CW_USEDEFAULT16
803 * 2) it does not ignore the y parameter as the docs claim; instead, it
804 * uses it as second parameter to ShowWindow() unless y is either
805 * CW_USEDEFAULT or CW_USEDEFAULT16.
807 * The fact that we didn't do 2) caused bogus windows pop up when wine
808 * was running apps that were using this obscure feature. Example -
809 * calc.exe that comes with Win98 (only Win98, it's different from
810 * the one that comes with Win95 and NT)
812 if (cs
->y
!= CW_USEDEFAULT
&& cs
->y
!= CW_USEDEFAULT16
) *sw
= cs
->y
;
813 cs
->x
= (info
.dwFlags
& STARTF_USEPOSITION
) ? info
.dwX
: 0;
814 cs
->y
= (info
.dwFlags
& STARTF_USEPOSITION
) ? info
.dwY
: 0;
817 if (cs
->cx
== CW_USEDEFAULT
|| cs
->cx
== CW_USEDEFAULT16
)
819 if (info
.dwFlags
& STARTF_USESIZE
)
821 cs
->cx
= info
.dwXSize
;
822 cs
->cy
= info
.dwYSize
;
824 else /* if no other hint from the app, pick 3/4 of the screen real estate */
827 SystemParametersInfoA( SPI_GETWORKAREA
, 0, &r
, 0);
828 cs
->cx
= (((r
.right
- r
.left
) * 3) / 4) - cs
->x
;
829 cs
->cy
= (((r
.bottom
- r
.top
) * 3) / 4) - cs
->y
;
836 /* neither x nor cx are default. Check the y values .
837 * In the trace we see Outlook and Outlook Express using
838 * cy set to CW_USEDEFAULT when opening the address book.
840 if (cs
->cy
== CW_USEDEFAULT
|| cs
->cy
== CW_USEDEFAULT16
) {
842 FIXME("Strange use of CW_USEDEFAULT in nHeight\n");
843 SystemParametersInfoA( SPI_GETWORKAREA
, 0, &r
, 0);
844 cs
->cy
= (((r
.bottom
- r
.top
) * 3) / 4) - cs
->y
;
849 /***********************************************************************
852 static void dump_window_styles( DWORD style
, DWORD exstyle
)
855 if(style
& WS_POPUP
) TRACE(" WS_POPUP");
856 if(style
& WS_CHILD
) TRACE(" WS_CHILD");
857 if(style
& WS_MINIMIZE
) TRACE(" WS_MINIMIZE");
858 if(style
& WS_VISIBLE
) TRACE(" WS_VISIBLE");
859 if(style
& WS_DISABLED
) TRACE(" WS_DISABLED");
860 if(style
& WS_CLIPSIBLINGS
) TRACE(" WS_CLIPSIBLINGS");
861 if(style
& WS_CLIPCHILDREN
) TRACE(" WS_CLIPCHILDREN");
862 if(style
& WS_MAXIMIZE
) TRACE(" WS_MAXIMIZE");
863 if((style
& WS_CAPTION
) == WS_CAPTION
) TRACE(" WS_CAPTION");
866 if(style
& WS_BORDER
) TRACE(" WS_BORDER");
867 if(style
& WS_DLGFRAME
) TRACE(" WS_DLGFRAME");
869 if(style
& WS_VSCROLL
) TRACE(" WS_VSCROLL");
870 if(style
& WS_HSCROLL
) TRACE(" WS_HSCROLL");
871 if(style
& WS_SYSMENU
) TRACE(" WS_SYSMENU");
872 if(style
& WS_THICKFRAME
) TRACE(" WS_THICKFRAME");
873 if(style
& WS_GROUP
) TRACE(" WS_GROUP");
874 if(style
& WS_TABSTOP
) TRACE(" WS_TABSTOP");
875 if(style
& WS_MINIMIZEBOX
) TRACE(" WS_MINIMIZEBOX");
876 if(style
& WS_MAXIMIZEBOX
) TRACE(" WS_MAXIMIZEBOX");
878 /* FIXME: Add dumping of BS_/ES_/SBS_/LBS_/CBS_/DS_/etc. styles */
879 #define DUMPED_STYLES \
899 if(style
& ~DUMPED_STYLES
) TRACE(" %08lx", style
& ~DUMPED_STYLES
);
904 if(exstyle
& WS_EX_DLGMODALFRAME
) TRACE(" WS_EX_DLGMODALFRAME");
905 if(exstyle
& WS_EX_DRAGDETECT
) TRACE(" WS_EX_DRAGDETECT");
906 if(exstyle
& WS_EX_NOPARENTNOTIFY
) TRACE(" WS_EX_NOPARENTNOTIFY");
907 if(exstyle
& WS_EX_TOPMOST
) TRACE(" WS_EX_TOPMOST");
908 if(exstyle
& WS_EX_ACCEPTFILES
) TRACE(" WS_EX_ACCEPTFILES");
909 if(exstyle
& WS_EX_TRANSPARENT
) TRACE(" WS_EX_TRANSPARENT");
910 if(exstyle
& WS_EX_MDICHILD
) TRACE(" WS_EX_MDICHILD");
911 if(exstyle
& WS_EX_TOOLWINDOW
) TRACE(" WS_EX_TOOLWINDOW");
912 if(exstyle
& WS_EX_WINDOWEDGE
) TRACE(" WS_EX_WINDOWEDGE");
913 if(exstyle
& WS_EX_CLIENTEDGE
) TRACE(" WS_EX_CLIENTEDGE");
914 if(exstyle
& WS_EX_CONTEXTHELP
) TRACE(" WS_EX_CONTEXTHELP");
915 if(exstyle
& WS_EX_RIGHT
) TRACE(" WS_EX_RIGHT");
916 if(exstyle
& WS_EX_RTLREADING
) TRACE(" WS_EX_RTLREADING");
917 if(exstyle
& WS_EX_LEFTSCROLLBAR
) TRACE(" WS_EX_LEFTSCROLLBAR");
918 if(exstyle
& WS_EX_CONTROLPARENT
) TRACE(" WS_EX_CONTROLPARENT");
919 if(exstyle
& WS_EX_STATICEDGE
) TRACE(" WS_EX_STATICEDGE");
920 if(exstyle
& WS_EX_APPWINDOW
) TRACE(" WS_EX_APPWINDOW");
921 if(exstyle
& WS_EX_LAYERED
) TRACE(" WS_EX_LAYERED");
923 #define DUMPED_EX_STYLES \
924 (WS_EX_DLGMODALFRAME | \
926 WS_EX_NOPARENTNOTIFY | \
928 WS_EX_ACCEPTFILES | \
929 WS_EX_TRANSPARENT | \
934 WS_EX_CONTEXTHELP | \
937 WS_EX_LEFTSCROLLBAR | \
938 WS_EX_CONTROLPARENT | \
943 if(exstyle
& ~DUMPED_EX_STYLES
) TRACE(" %08lx", exstyle
& ~DUMPED_EX_STYLES
);
945 #undef DUMPED_EX_STYLES
949 /***********************************************************************
952 * Implementation of CreateWindowEx().
954 static HWND
WIN_CreateWindowEx( CREATESTRUCTA
*cs
, ATOM classAtom
,
955 WINDOWPROCTYPE type
)
959 HWND hwnd
, parent
, owner
, top_child
= 0;
960 BOOL unicode
= (type
== WIN_PROC_32W
);
962 TRACE("%s %s ex=%08lx style=%08lx %d,%d %dx%d parent=%p menu=%p inst=%p params=%p\n",
963 (type
== WIN_PROC_32W
) ? debugstr_w((LPWSTR
)cs
->lpszName
) : debugstr_a(cs
->lpszName
),
964 (type
== WIN_PROC_32W
) ? debugstr_w((LPWSTR
)cs
->lpszClass
) : debugstr_a(cs
->lpszClass
),
965 cs
->dwExStyle
, cs
->style
, cs
->x
, cs
->y
, cs
->cx
, cs
->cy
,
966 cs
->hwndParent
, cs
->hMenu
, cs
->hInstance
, cs
->lpCreateParams
);
968 if(TRACE_ON(win
)) dump_window_styles( cs
->style
, cs
->dwExStyle
);
970 TRACE("winproc type is %d (%s)\n", type
, (type
== WIN_PROC_16
) ? "WIN_PROC_16" :
971 ((type
== WIN_PROC_32A
) ? "WIN_PROC_32A" : "WIN_PROC_32W") );
973 /* Fix the styles for MDI children */
974 if (cs
->dwExStyle
& WS_EX_MDICHILD
)
976 MDICREATESTRUCTA mdi_cs
;
979 wndPtr
= WIN_GetPtr(cs
->hwndParent
);
980 if (wndPtr
&& wndPtr
!= WND_OTHER_PROCESS
)
982 flags
= wndPtr
->flags
;
983 WIN_ReleasePtr(wndPtr
);
986 if (!(flags
& WIN_ISMDICLIENT
))
988 WARN("WS_EX_MDICHILD, but parent %p is not MDIClient\n", cs
->hwndParent
);
992 /* cs->lpCreateParams of WM_[NC]CREATE is different for MDI children.
993 * MDICREATESTRUCT members have the originally passed values.
995 * Note: we rely on the fact that MDICREATESTRUCTA and MDICREATESTRUCTW
996 * have the same layout.
998 mdi_cs
.szClass
= cs
->lpszClass
;
999 mdi_cs
.szTitle
= cs
->lpszName
;
1000 mdi_cs
.hOwner
= cs
->hInstance
;
1005 mdi_cs
.style
= cs
->style
;
1006 mdi_cs
.lParam
= (LPARAM
)cs
->lpCreateParams
;
1008 cs
->lpCreateParams
= (LPVOID
)&mdi_cs
;
1010 if (GetWindowLongW(cs
->hwndParent
, GWL_STYLE
) & MDIS_ALLCHILDSTYLES
)
1012 if (cs
->style
& WS_POPUP
)
1014 TRACE("WS_POPUP with MDIS_ALLCHILDSTYLES is not allowed\n");
1017 cs
->style
|= WS_CHILD
| WS_CLIPSIBLINGS
;
1021 cs
->style
&= ~WS_POPUP
;
1022 cs
->style
|= WS_CHILD
| WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_CAPTION
|
1023 WS_SYSMENU
| WS_THICKFRAME
| WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
;
1026 top_child
= GetWindow(cs
->hwndParent
, GW_CHILD
);
1029 /* Find the parent window */
1031 parent
= GetDesktopWindow();
1034 if (cs
->hwndParent
== HWND_MESSAGE
)
1036 /* native ole32.OleInitialize uses HWND_MESSAGE to create the
1037 * message window (style: WS_POPUP|WS_DISABLED)
1039 FIXME("Parent is HWND_MESSAGE\n");
1041 else if (cs
->hwndParent
)
1043 /* Make sure parent is valid */
1044 if (!IsWindow( cs
->hwndParent
))
1046 WARN("Bad parent %p\n", cs
->hwndParent
);
1049 if ((cs
->style
& (WS_CHILD
|WS_POPUP
)) == WS_CHILD
)
1050 parent
= WIN_GetFullHandle(cs
->hwndParent
);
1052 owner
= GetAncestor( cs
->hwndParent
, GA_ROOT
);
1054 else if ((cs
->style
& (WS_CHILD
|WS_POPUP
)) == WS_CHILD
)
1056 WARN("No parent for child window\n" );
1057 return 0; /* WS_CHILD needs a parent, but WS_POPUP doesn't */
1060 WIN_FixCoordinates(cs
, &sw
); /* fix default coordinates */
1062 /* Correct the window styles.
1064 * It affects both the style loaded into the WIN structure and
1065 * passed in the CREATESTRUCT to the WM_[NC]CREATE.
1067 * WS_EX_WINDOWEDGE appears to be enforced based on the other styles, so
1068 * why does the user get to set it?
1071 /* This has been tested for WS_CHILD | WS_VISIBLE. It has not been
1072 * tested for WS_POPUP
1074 if ((cs
->dwExStyle
& WS_EX_DLGMODALFRAME
) ||
1075 ((!(cs
->dwExStyle
& WS_EX_STATICEDGE
)) &&
1076 (cs
->style
& (WS_DLGFRAME
| WS_THICKFRAME
))))
1077 cs
->dwExStyle
|= WS_EX_WINDOWEDGE
;
1079 cs
->dwExStyle
&= ~WS_EX_WINDOWEDGE
;
1081 if (!(cs
->style
& WS_CHILD
))
1083 cs
->style
|= WS_CLIPSIBLINGS
;
1084 if (!(cs
->style
& WS_POPUP
))
1085 cs
->style
|= WS_CAPTION
;
1088 /* Create the window structure */
1090 if (!(wndPtr
= create_window_handle( parent
, owner
, classAtom
, cs
->hInstance
, type
)))
1092 TRACE("out of memory\n" );
1095 hwnd
= wndPtr
->hwndSelf
;
1097 /* Fill the window structure */
1099 wndPtr
->tid
= GetCurrentThreadId();
1100 wndPtr
->owner
= owner
;
1101 wndPtr
->parent
= parent
;
1102 wndPtr
->hInstance
= cs
->hInstance
;
1103 wndPtr
->text
= NULL
;
1104 wndPtr
->hrgnUpdate
= 0;
1105 wndPtr
->dwStyle
= cs
->style
& ~WS_VISIBLE
;
1106 wndPtr
->dwExStyle
= cs
->dwExStyle
;
1107 wndPtr
->wIDmenu
= 0;
1108 wndPtr
->helpContext
= 0;
1109 wndPtr
->flags
= (type
== WIN_PROC_16
) ? 0 : WIN_ISWIN32
;
1110 wndPtr
->pVScroll
= NULL
;
1111 wndPtr
->pHScroll
= NULL
;
1112 wndPtr
->userdata
= 0;
1114 wndPtr
->hIconSmall
= 0;
1115 wndPtr
->hSysMenu
= (wndPtr
->dwStyle
& WS_SYSMENU
) ? MENU_GetSysMenu( hwnd
, 0 ) : 0;
1117 if (!(cs
->style
& (WS_CHILD
| WS_POPUP
)))
1118 wndPtr
->flags
|= WIN_NEED_SIZE
;
1120 SERVER_START_REQ( set_window_info
)
1123 req
->flags
= SET_WIN_STYLE
| SET_WIN_EXSTYLE
| SET_WIN_INSTANCE
;
1124 req
->style
= wndPtr
->dwStyle
;
1125 req
->ex_style
= wndPtr
->dwExStyle
;
1126 req
->instance
= (void *)wndPtr
->hInstance
;
1127 req
->extra_offset
= -1;
1128 wine_server_call( req
);
1132 /* Get class or window DC if needed */
1134 if (wndPtr
->clsStyle
& CS_OWNDC
) wndPtr
->dce
= DCE_AllocDCE(hwnd
,DCE_WINDOW_DC
);
1136 /* Set the window menu */
1138 if (((wndPtr
->dwStyle
& (WS_CAPTION
|WS_CHILD
)) == WS_CAPTION
) ||
1139 (wndPtr
->dwExStyle
& WS_EX_APPWINDOW
))
1141 if (cs
->hMenu
) MENU_SetMenu(hwnd
, cs
->hMenu
);
1144 LPCSTR menuName
= (LPCSTR
)GetClassLongA( hwnd
, GCL_MENUNAME
);
1147 if (HIWORD(cs
->hInstance
))
1148 cs
->hMenu
= LoadMenuA(cs
->hInstance
,menuName
);
1150 cs
->hMenu
= HMENU_32(LoadMenu16(HINSTANCE_16(cs
->hInstance
),menuName
));
1152 if (cs
->hMenu
) MENU_SetMenu( hwnd
, cs
->hMenu
);
1156 else SetWindowLongW( hwnd
, GWL_ID
, (UINT
)cs
->hMenu
);
1157 WIN_ReleaseWndPtr( wndPtr
);
1159 if (!USER_Driver
.pCreateWindow( hwnd
, cs
, unicode
))
1161 WIN_DestroyWindow( hwnd
);
1165 /* Notify the parent window only */
1167 send_parent_notify( hwnd
, WM_CREATE
);
1168 if (!IsWindow( hwnd
)) return 0;
1170 if (cs
->dwExStyle
& WS_EX_MDICHILD
)
1174 /* Restore current maximized child */
1175 if((cs
->style
& WS_VISIBLE
) && IsZoomed(top_child
))
1177 TRACE("Restoring current maximized child %p\n", top_child
);
1178 ShowWindow(top_child
, SW_SHOWNOACTIVATE
);
1182 SendMessageW(cs
->hwndParent
, WM_MDIREFRESHMENU
, 0, 0);
1185 if (cs
->style
& WS_VISIBLE
)
1186 ShowWindow( hwnd
, sw
);
1188 /* Call WH_SHELL hook */
1190 if (!(GetWindowLongW( hwnd
, GWL_STYLE
) & WS_CHILD
) && !GetWindow( hwnd
, GW_OWNER
))
1191 HOOK_CallHooks( WH_SHELL
, HSHELL_WINDOWCREATED
, (WPARAM
)hwnd
, 0, TRUE
);
1193 TRACE("created window %p\n", hwnd
);
1198 /***********************************************************************
1199 * CreateWindow (USER.41)
1201 HWND16 WINAPI
CreateWindow16( LPCSTR className
, LPCSTR windowName
,
1202 DWORD style
, INT16 x
, INT16 y
, INT16 width
,
1203 INT16 height
, HWND16 parent
, HMENU16 menu
,
1204 HINSTANCE16 instance
, LPVOID data
)
1206 return CreateWindowEx16( 0, className
, windowName
, style
,
1207 x
, y
, width
, height
, parent
, menu
, instance
, data
);
1211 /***********************************************************************
1212 * CreateWindowEx (USER.452)
1214 HWND16 WINAPI
CreateWindowEx16( DWORD exStyle
, LPCSTR className
,
1215 LPCSTR windowName
, DWORD style
, INT16 x
,
1216 INT16 y
, INT16 width
, INT16 height
,
1217 HWND16 parent
, HMENU16 menu
,
1218 HINSTANCE16 instance
, LPVOID data
)
1224 /* Find the class atom */
1226 if (HIWORD(className
))
1228 if (!(classAtom
= GlobalFindAtomA( className
)))
1230 ERR( "bad class name %s\n", debugstr_a(className
) );
1236 classAtom
= LOWORD(className
);
1237 if (!GlobalGetAtomNameA( classAtom
, buffer
, sizeof(buffer
) ))
1239 ERR( "bad atom %x\n", classAtom
);
1245 /* Fix the coordinates */
1247 cs
.x
= (x
== CW_USEDEFAULT16
) ? CW_USEDEFAULT
: (INT
)x
;
1248 cs
.y
= (y
== CW_USEDEFAULT16
) ? CW_USEDEFAULT
: (INT
)y
;
1249 cs
.cx
= (width
== CW_USEDEFAULT16
) ? CW_USEDEFAULT
: (INT
)width
;
1250 cs
.cy
= (height
== CW_USEDEFAULT16
) ? CW_USEDEFAULT
: (INT
)height
;
1252 /* Create the window */
1254 cs
.lpCreateParams
= data
;
1255 cs
.hInstance
= HINSTANCE_32(instance
);
1256 cs
.hMenu
= HMENU_32(menu
);
1257 cs
.hwndParent
= WIN_Handle32( parent
);
1259 cs
.lpszName
= windowName
;
1260 cs
.lpszClass
= className
;
1261 cs
.dwExStyle
= exStyle
;
1263 return HWND_16( WIN_CreateWindowEx( &cs
, classAtom
, WIN_PROC_16
));
1267 /***********************************************************************
1268 * CreateWindowExA (USER32.@)
1270 HWND WINAPI
CreateWindowExA( DWORD exStyle
, LPCSTR className
,
1271 LPCSTR windowName
, DWORD style
, INT x
,
1272 INT y
, INT width
, INT height
,
1273 HWND parent
, HMENU menu
,
1274 HINSTANCE instance
, LPVOID data
)
1280 /* Find the class atom */
1282 if (HIWORD(className
))
1284 if (!(classAtom
= GlobalFindAtomA( className
)))
1286 ERR( "bad class name %s\n", debugstr_a(className
) );
1292 classAtom
= LOWORD(className
);
1293 if (!GlobalGetAtomNameA( classAtom
, buffer
, sizeof(buffer
) ))
1295 ERR( "bad atom %x\n", classAtom
);
1301 /* Create the window */
1303 cs
.lpCreateParams
= data
;
1304 cs
.hInstance
= instance
;
1306 cs
.hwndParent
= parent
;
1312 cs
.lpszName
= windowName
;
1313 cs
.lpszClass
= className
;
1314 cs
.dwExStyle
= exStyle
;
1316 return WIN_CreateWindowEx( &cs
, classAtom
, WIN_PROC_32A
);
1320 /***********************************************************************
1321 * CreateWindowExW (USER32.@)
1323 HWND WINAPI
CreateWindowExW( DWORD exStyle
, LPCWSTR className
,
1324 LPCWSTR windowName
, DWORD style
, INT x
,
1325 INT y
, INT width
, INT height
,
1326 HWND parent
, HMENU menu
,
1327 HINSTANCE instance
, LPVOID data
)
1333 /* Find the class atom */
1335 if (HIWORD(className
))
1337 if (!(classAtom
= GlobalFindAtomW( className
)))
1339 ERR( "bad class name %s\n", debugstr_w(className
) );
1345 classAtom
= LOWORD(className
);
1346 if (!GlobalGetAtomNameW( classAtom
, buffer
, sizeof(buffer
)/sizeof(WCHAR
) ))
1348 ERR( "bad atom %x\n", classAtom
);
1354 /* Create the window */
1356 cs
.lpCreateParams
= data
;
1357 cs
.hInstance
= instance
;
1359 cs
.hwndParent
= parent
;
1365 cs
.lpszName
= windowName
;
1366 cs
.lpszClass
= className
;
1367 cs
.dwExStyle
= exStyle
;
1369 /* Note: we rely on the fact that CREATESTRUCTA and */
1370 /* CREATESTRUCTW have the same layout. */
1371 return WIN_CreateWindowEx( (CREATESTRUCTA
*)&cs
, classAtom
, WIN_PROC_32W
);
1375 /***********************************************************************
1376 * WIN_SendDestroyMsg
1378 static void WIN_SendDestroyMsg( HWND hwnd
)
1382 if (GetGUIThreadInfo( GetCurrentThreadId(), &info
))
1384 if (hwnd
== info
.hwndCaret
) DestroyCaret();
1385 if (hwnd
== info
.hwndActive
) WINPOS_ActivateOtherWindow( hwnd
);
1387 if (USER_Driver
.pResetSelectionOwner
)
1388 USER_Driver
.pResetSelectionOwner( hwnd
, TRUE
);
1391 * Send the WM_DESTROY to the window.
1393 SendMessageA( hwnd
, WM_DESTROY
, 0, 0);
1396 * This WM_DESTROY message can trigger re-entrant calls to DestroyWindow
1397 * make sure that the window still exists when we come back.
1404 if (!(pWndArray
= WIN_ListChildren( hwnd
))) return;
1406 /* start from the end (FIXME: is this needed?) */
1407 for (i
= 0; pWndArray
[i
]; i
++) ;
1411 if (IsWindow( pWndArray
[i
] )) WIN_SendDestroyMsg( pWndArray
[i
] );
1413 HeapFree( GetProcessHeap(), 0, pWndArray
);
1416 WARN("\tdestroyed itself while in WM_DESTROY!\n");
1420 /***********************************************************************
1421 * DestroyWindow (USER32.@)
1423 BOOL WINAPI
DestroyWindow( HWND hwnd
)
1427 if (!(hwnd
= WIN_IsCurrentThread( hwnd
)) || (hwnd
== GetDesktopWindow()))
1429 SetLastError( ERROR_ACCESS_DENIED
);
1433 TRACE("(%p)\n", hwnd
);
1435 if (GetWindowLongW(hwnd
, GWL_EXSTYLE
) & WS_EX_MDICHILD
)
1436 SendMessageW(GetAncestor(hwnd
, GA_PARENT
), WM_MDIREFRESHMENU
, 0, 0);
1440 if (HOOK_CallHooks( WH_CBT
, HCBT_DESTROYWND
, (WPARAM
)hwnd
, 0, TRUE
)) return FALSE
;
1442 is_child
= (GetWindowLongW( hwnd
, GWL_STYLE
) & WS_CHILD
) != 0;
1446 if (!USER_IsExitingThread( GetCurrentThreadId() ))
1447 send_parent_notify( hwnd
, WM_DESTROY
);
1449 else if (!GetWindow( hwnd
, GW_OWNER
))
1451 HOOK_CallHooks( WH_SHELL
, HSHELL_WINDOWDESTROYED
, (WPARAM
)hwnd
, 0L, TRUE
);
1452 /* FIXME: clean up palette - see "Internals" p.352 */
1455 if (!IsWindow(hwnd
)) return TRUE
;
1457 if (USER_Driver
.pResetSelectionOwner
)
1458 USER_Driver
.pResetSelectionOwner( hwnd
, FALSE
); /* before the window is unmapped */
1460 /* Hide the window */
1462 /* Only child windows receive WM_SHOWWINDOW in DestroyWindow() */
1464 ShowWindow( hwnd
, SW_HIDE
);
1466 SetWindowPos( hwnd
, 0, 0, 0, 0, 0, SWP_NOMOVE
| SWP_NOSIZE
|
1467 SWP_NOZORDER
| SWP_NOACTIVATE
| SWP_HIDEWINDOW
);
1469 if (!IsWindow(hwnd
)) return TRUE
;
1471 /* Recursively destroy owned windows */
1478 HWND
*list
= WIN_ListChildren( GetDesktopWindow() );
1481 for (i
= 0; list
[i
]; i
++)
1483 if (GetWindow( list
[i
], GW_OWNER
) != hwnd
) continue;
1484 if (WIN_IsCurrentThread( list
[i
] ))
1486 DestroyWindow( list
[i
] );
1490 WIN_SetOwner( list
[i
], 0 );
1492 HeapFree( GetProcessHeap(), 0, list
);
1494 if (!got_one
) break;
1498 /* Send destroy messages */
1500 WIN_SendDestroyMsg( hwnd
);
1501 if (!IsWindow( hwnd
)) return TRUE
;
1503 if (GetClipboardOwner() == hwnd
)
1504 CLIPBOARD_ReleaseOwner();
1506 /* Unlink now so we won't bother with the children later on */
1508 WIN_UnlinkWindow( hwnd
);
1510 /* Destroy the window storage */
1512 WIN_DestroyWindow( hwnd
);
1517 /***********************************************************************
1518 * CloseWindow (USER32.@)
1520 BOOL WINAPI
CloseWindow( HWND hwnd
)
1522 if (GetWindowLongW( hwnd
, GWL_STYLE
) & WS_CHILD
) return FALSE
;
1523 ShowWindow( hwnd
, SW_MINIMIZE
);
1528 /***********************************************************************
1529 * OpenIcon (USER32.@)
1531 BOOL WINAPI
OpenIcon( HWND hwnd
)
1533 if (!IsIconic( hwnd
)) return FALSE
;
1534 ShowWindow( hwnd
, SW_SHOWNORMAL
);
1539 /***********************************************************************
1542 * Implementation of FindWindow() and FindWindowEx().
1544 static HWND
WIN_FindWindow( HWND parent
, HWND child
, ATOM className
, LPCWSTR title
)
1549 WCHAR
*buffer
= NULL
;
1551 if (!parent
) parent
= GetDesktopWindow();
1554 len
= strlenW(title
) + 1; /* one extra char to check for chars beyond the end */
1555 if (!(buffer
= HeapAlloc( GetProcessHeap(), 0, (len
+ 1) * sizeof(WCHAR
) ))) return 0;
1558 if (!(list
= list_window_children( parent
, className
, 0 ))) goto done
;
1562 child
= WIN_GetFullHandle( child
);
1563 while (list
[i
] && list
[i
] != child
) i
++;
1564 if (!list
[i
]) goto done
;
1565 i
++; /* start from next window */
1572 if (GetWindowTextW( list
[i
], buffer
, len
+ 1 ) && !strcmpiW( buffer
, title
)) break;
1579 if (list
) HeapFree( GetProcessHeap(), 0, list
);
1580 if (buffer
) HeapFree( GetProcessHeap(), 0, buffer
);
1586 /***********************************************************************
1587 * FindWindowA (USER32.@)
1589 HWND WINAPI
FindWindowA( LPCSTR className
, LPCSTR title
)
1591 HWND ret
= FindWindowExA( 0, 0, className
, title
);
1592 if (!ret
) SetLastError (ERROR_CANNOT_FIND_WND_CLASS
);
1597 /***********************************************************************
1598 * FindWindowExA (USER32.@)
1600 HWND WINAPI
FindWindowExA( HWND parent
, HWND child
,
1601 LPCSTR className
, LPCSTR title
)
1610 /* If the atom doesn't exist, then no class */
1611 /* with this name exists either. */
1612 if (!(atom
= GlobalFindAtomA( className
)))
1614 SetLastError (ERROR_CANNOT_FIND_WND_CLASS
);
1618 if (!title
) return WIN_FindWindow( parent
, child
, atom
, NULL
);
1620 len
= MultiByteToWideChar( CP_ACP
, 0, title
, -1, NULL
, 0 );
1621 if (!(buffer
= HeapAlloc( GetProcessHeap(), 0, len
* sizeof(WCHAR
) ))) return 0;
1622 MultiByteToWideChar( CP_ACP
, 0, title
, -1, buffer
, len
);
1623 hwnd
= WIN_FindWindow( parent
, child
, atom
, buffer
);
1624 HeapFree( GetProcessHeap(), 0, buffer
);
1629 /***********************************************************************
1630 * FindWindowExW (USER32.@)
1632 HWND WINAPI
FindWindowExW( HWND parent
, HWND child
,
1633 LPCWSTR className
, LPCWSTR title
)
1639 /* If the atom doesn't exist, then no class */
1640 /* with this name exists either. */
1641 if (!(atom
= GlobalFindAtomW( className
)))
1643 SetLastError (ERROR_CANNOT_FIND_WND_CLASS
);
1647 return WIN_FindWindow( parent
, child
, atom
, title
);
1651 /***********************************************************************
1652 * FindWindowW (USER32.@)
1654 HWND WINAPI
FindWindowW( LPCWSTR className
, LPCWSTR title
)
1656 return FindWindowExW( 0, 0, className
, title
);
1660 /**********************************************************************
1661 * GetDesktopWindow (USER32.@)
1663 HWND WINAPI
GetDesktopWindow(void)
1665 if (pWndDesktop
) return pWndDesktop
->hwndSelf
;
1666 ERR( "Wine init error: either you're trying to use an invalid native USER.EXE config, or some graphics/GUI libraries or DLLs didn't initialize properly. Aborting.\n" );
1672 /*******************************************************************
1673 * EnableWindow (USER32.@)
1675 BOOL WINAPI
EnableWindow( HWND hwnd
, BOOL enable
)
1682 if (is_broadcast(hwnd
))
1684 SetLastError( ERROR_INVALID_PARAMETER
);
1688 if (!(full_handle
= WIN_IsCurrentThread( hwnd
)))
1689 return SendMessageW( hwnd
, WM_WINE_ENABLEWINDOW
, enable
, 0 );
1693 TRACE("( %p, %d )\n", hwnd
, enable
);
1695 if (!(wndPtr
= WIN_GetPtr( hwnd
))) return FALSE
;
1696 style
= wndPtr
->dwStyle
;
1697 retvalue
= ((style
& WS_DISABLED
) != 0);
1698 WIN_ReleasePtr( wndPtr
);
1700 if (enable
&& retvalue
)
1702 WIN_SetStyle( hwnd
, style
& ~WS_DISABLED
);
1703 SendMessageA( hwnd
, WM_ENABLE
, TRUE
, 0 );
1705 else if (!enable
&& !retvalue
)
1709 SendMessageA( hwnd
, WM_CANCELMODE
, 0, 0);
1711 WIN_SetStyle( hwnd
, style
| WS_DISABLED
);
1713 if (hwnd
== GetFocus())
1714 SetFocus( 0 ); /* A disabled window can't have the focus */
1716 capture_wnd
= GetCapture();
1717 if (hwnd
== capture_wnd
|| IsChild(hwnd
, capture_wnd
))
1718 ReleaseCapture(); /* A disabled window can't capture the mouse */
1720 SendMessageA( hwnd
, WM_ENABLE
, FALSE
, 0 );
1726 /***********************************************************************
1727 * IsWindowEnabled (USER32.@)
1729 BOOL WINAPI
IsWindowEnabled(HWND hWnd
)
1731 return !(GetWindowLongW( hWnd
, GWL_STYLE
) & WS_DISABLED
);
1735 /***********************************************************************
1736 * IsWindowUnicode (USER32.@)
1738 BOOL WINAPI
IsWindowUnicode( HWND hwnd
)
1743 if (!(wndPtr
= WIN_FindWndPtr(hwnd
))) return FALSE
;
1744 retvalue
= (WINPROC_GetProcType( wndPtr
->winproc
) == WIN_PROC_32W
);
1745 WIN_ReleaseWndPtr(wndPtr
);
1750 /**********************************************************************
1751 * GetWindowWord (USER32.@)
1753 WORD WINAPI
GetWindowWord( HWND hwnd
, INT offset
)
1758 WND
*wndPtr
= WIN_GetPtr( hwnd
);
1761 SetLastError( ERROR_INVALID_WINDOW_HANDLE
);
1764 if (wndPtr
== WND_OTHER_PROCESS
)
1766 SERVER_START_REQ( set_window_info
)
1769 req
->flags
= 0; /* don't set anything, just retrieve */
1770 req
->extra_offset
= offset
;
1771 req
->extra_size
= sizeof(retvalue
);
1772 if (!wine_server_call_err( req
))
1773 memcpy( &retvalue
, &reply
->old_extra_value
, sizeof(retvalue
) );
1778 if (offset
> (int)(wndPtr
->cbWndExtra
- sizeof(WORD
)))
1780 WARN("Invalid offset %d\n", offset
);
1781 SetLastError( ERROR_INVALID_INDEX
);
1783 else memcpy( &retvalue
, (char *)wndPtr
->wExtra
+ offset
, sizeof(retvalue
) );
1784 WIN_ReleasePtr( wndPtr
);
1790 case GWL_HWNDPARENT
:
1791 return GetWindowLongW( hwnd
, offset
);
1795 LONG ret
= GetWindowLongW( hwnd
, offset
);
1797 WARN("%d: discards high bits of 0x%08lx!\n", offset
, ret
);
1801 WARN("Invalid offset %d\n", offset
);
1807 /**********************************************************************
1808 * SetWindowWord (USER32.@)
1810 WORD WINAPI
SetWindowWord( HWND hwnd
, INT offset
, WORD newval
)
1819 case GWL_HWNDPARENT
:
1820 return SetWindowLongW( hwnd
, offset
, (UINT
)newval
);
1824 WARN("Invalid offset %d\n", offset
);
1825 SetLastError( ERROR_INVALID_INDEX
);
1830 wndPtr
= WIN_GetPtr( hwnd
);
1831 if (wndPtr
== WND_OTHER_PROCESS
)
1834 FIXME( "set %d <- %x not supported yet on other process window %p\n",
1835 offset
, newval
, hwnd
);
1840 SetLastError( ERROR_INVALID_WINDOW_HANDLE
);
1844 if (offset
> (int)(wndPtr
->cbWndExtra
- sizeof(WORD
)))
1846 WARN("Invalid offset %d\n", offset
);
1847 WIN_ReleasePtr(wndPtr
);
1848 SetLastError( ERROR_INVALID_INDEX
);
1852 SERVER_START_REQ( set_window_info
)
1855 req
->flags
= SET_WIN_EXTRA
;
1856 req
->extra_offset
= offset
;
1857 req
->extra_size
= sizeof(newval
);
1858 memcpy( &req
->extra_value
, &newval
, sizeof(newval
) );
1859 if (!wine_server_call_err( req
))
1861 void *ptr
= (char *)wndPtr
->wExtra
+ offset
;
1862 memcpy( &retval
, ptr
, sizeof(retval
) );
1863 memcpy( ptr
, &newval
, sizeof(newval
) );
1867 WIN_ReleasePtr( wndPtr
);
1872 /**********************************************************************
1875 * Helper function for GetWindowLong().
1877 static LONG
WIN_GetWindowLong( HWND hwnd
, INT offset
, WINDOWPROCTYPE type
)
1882 if (offset
== GWL_HWNDPARENT
)
1884 HWND parent
= GetAncestor( hwnd
, GA_PARENT
);
1885 if (parent
== GetDesktopWindow()) parent
= GetWindow( hwnd
, GW_OWNER
);
1886 return (LONG
)parent
;
1889 if (!(wndPtr
= WIN_GetPtr( hwnd
)))
1891 SetLastError( ERROR_INVALID_WINDOW_HANDLE
);
1895 if (wndPtr
== WND_OTHER_PROCESS
)
1897 if (offset
== GWL_WNDPROC
)
1899 SetLastError( ERROR_ACCESS_DENIED
);
1902 SERVER_START_REQ( set_window_info
)
1905 req
->flags
= 0; /* don't set anything, just retrieve */
1906 req
->extra_offset
= (offset
>= 0) ? offset
: -1;
1907 req
->extra_size
= (offset
>= 0) ? sizeof(retvalue
) : 0;
1908 if (!wine_server_call_err( req
))
1912 case GWL_STYLE
: retvalue
= reply
->old_style
; break;
1913 case GWL_EXSTYLE
: retvalue
= reply
->old_ex_style
; break;
1914 case GWL_ID
: retvalue
= reply
->old_id
; break;
1915 case GWL_HINSTANCE
: retvalue
= (ULONG_PTR
)reply
->old_instance
; break;
1916 case GWL_USERDATA
: retvalue
= (ULONG_PTR
)reply
->old_user_data
; break;
1918 if (offset
>= 0) retvalue
= reply
->old_extra_value
;
1919 else SetLastError( ERROR_INVALID_INDEX
);
1928 /* now we have a valid wndPtr */
1932 if (offset
> (int)(wndPtr
->cbWndExtra
- sizeof(LONG
)))
1935 * Some programs try to access last element from 16 bit
1936 * code using illegal offset value. Hopefully this is
1937 * what those programs really expect.
1939 if (type
== WIN_PROC_16
&&
1940 wndPtr
->cbWndExtra
>= 4 &&
1941 offset
== wndPtr
->cbWndExtra
- sizeof(WORD
))
1943 INT offset2
= wndPtr
->cbWndExtra
- sizeof(LONG
);
1945 ERR( "- replaced invalid offset %d with %d\n",
1948 retvalue
= *(LONG
*)(((char *)wndPtr
->wExtra
) + offset2
);
1949 WIN_ReleasePtr( wndPtr
);
1952 WARN("Invalid offset %d\n", offset
);
1953 WIN_ReleasePtr( wndPtr
);
1954 SetLastError( ERROR_INVALID_INDEX
);
1957 retvalue
= *(LONG
*)(((char *)wndPtr
->wExtra
) + offset
);
1958 /* Special case for dialog window procedure */
1959 if ((offset
== DWL_DLGPROC
) && (wndPtr
->flags
& WIN_ISDIALOG
))
1960 retvalue
= (LONG
)WINPROC_GetProc( (WNDPROC
)retvalue
, type
);
1961 WIN_ReleasePtr( wndPtr
);
1967 case GWL_USERDATA
: retvalue
= wndPtr
->userdata
; break;
1968 case GWL_STYLE
: retvalue
= wndPtr
->dwStyle
; break;
1969 case GWL_EXSTYLE
: retvalue
= wndPtr
->dwExStyle
; break;
1970 case GWL_ID
: retvalue
= (LONG
)wndPtr
->wIDmenu
; break;
1971 case GWL_WNDPROC
: retvalue
= (LONG
)WINPROC_GetProc( wndPtr
->winproc
, type
); break;
1972 case GWL_HINSTANCE
: retvalue
= (LONG
)wndPtr
->hInstance
; break;
1974 WARN("Unknown offset %d\n", offset
);
1975 SetLastError( ERROR_INVALID_INDEX
);
1978 WIN_ReleasePtr(wndPtr
);
1983 /**********************************************************************
1986 * Helper function for SetWindowLong().
1988 * 0 is the failure code. However, in the case of failure SetLastError
1989 * must be set to distinguish between a 0 return value and a failure.
1991 static LONG
WIN_SetWindowLong( HWND hwnd
, INT offset
, LONG newval
,
1992 WINDOWPROCTYPE type
)
1999 TRACE( "%p %d %lx %x\n", hwnd
, offset
, newval
, type
);
2001 if (is_broadcast(hwnd
))
2003 SetLastError( ERROR_INVALID_PARAMETER
);
2006 if (!WIN_IsCurrentProcess( hwnd
))
2008 if (offset
== GWL_WNDPROC
)
2010 SetLastError( ERROR_ACCESS_DENIED
);
2013 return SendMessageW( hwnd
, WM_WINE_SETWINDOWLONG
, offset
, newval
);
2016 wndPtr
= WIN_GetPtr( hwnd
);
2017 if (wndPtr
->hwndSelf
== GetDesktopWindow())
2019 /* can't change anything on the desktop window */
2020 WIN_ReleasePtr( wndPtr
);
2021 SetLastError( ERROR_ACCESS_DENIED
);
2025 /* first some special cases */
2031 offset
== GWL_STYLE
? wndPtr
->dwStyle
: wndPtr
->dwExStyle
;
2032 style
.styleNew
= newval
;
2033 WIN_ReleasePtr( wndPtr
);
2034 SendMessageW( hwnd
, WM_STYLECHANGING
, offset
, (LPARAM
)&style
);
2035 if (!(wndPtr
= WIN_GetPtr( hwnd
)) || wndPtr
== WND_OTHER_PROCESS
) return 0;
2036 newval
= style
.styleNew
;
2038 case GWL_HWNDPARENT
:
2039 if (wndPtr
->parent
== GetDesktopWindow())
2041 WIN_ReleasePtr( wndPtr
);
2042 return (LONG
)WIN_SetOwner( hwnd
, (HWND
)newval
);
2046 WIN_ReleasePtr( wndPtr
);
2047 return (LONG
)SetParent( hwnd
, (HWND
)newval
);
2050 retval
= (LONG
)WINPROC_GetProc( wndPtr
->winproc
, type
);
2051 WINPROC_SetProc( &wndPtr
->winproc
, (WNDPROC
)newval
, type
, WIN_PROC_WINDOW
);
2052 WIN_ReleasePtr( wndPtr
);
2059 if ((wndPtr
->cbWndExtra
+ sizeof(LONG
) >= DWL_DLGPROC
) && (wndPtr
->flags
& WIN_ISDIALOG
))
2061 WNDPROC
*ptr
= (WNDPROC
*)((char *)wndPtr
->wExtra
+ DWL_DLGPROC
);
2062 retval
= (LONG
)WINPROC_GetProc( *ptr
, type
);
2063 WINPROC_SetProc( ptr
, (WNDPROC
)newval
, type
, WIN_PROC_WINDOW
);
2064 WIN_ReleasePtr( wndPtr
);
2069 if (offset
< 0 || offset
> (int)(wndPtr
->cbWndExtra
- sizeof(LONG
)))
2071 WARN("Invalid offset %d\n", offset
);
2072 WIN_ReleasePtr( wndPtr
);
2073 SetLastError( ERROR_INVALID_INDEX
);
2078 LONG
*ptr
= (LONG
*)((char *)wndPtr
->wExtra
+ offset
);
2079 if (*ptr
== newval
) /* already set to the same value */
2081 WIN_ReleasePtr( wndPtr
);
2088 SERVER_START_REQ( set_window_info
)
2091 req
->extra_offset
= -1;
2095 req
->flags
= SET_WIN_STYLE
;
2096 req
->style
= newval
;
2099 req
->flags
= SET_WIN_EXSTYLE
;
2100 req
->ex_style
= newval
;
2103 req
->flags
= SET_WIN_ID
;
2107 req
->flags
= SET_WIN_INSTANCE
;
2108 req
->instance
= (void *)newval
;
2111 req
->flags
= SET_WIN_USERDATA
;
2112 req
->user_data
= (void *)newval
;
2115 req
->flags
= SET_WIN_EXTRA
;
2116 req
->extra_offset
= offset
;
2117 req
->extra_size
= sizeof(newval
);
2118 memcpy( &req
->extra_value
, &newval
, sizeof(newval
) );
2120 if ((ok
= !wine_server_call_err( req
)))
2125 wndPtr
->dwStyle
= newval
;
2126 retval
= reply
->old_style
;
2129 wndPtr
->dwExStyle
= newval
;
2130 retval
= reply
->old_ex_style
;
2133 wndPtr
->wIDmenu
= newval
;
2134 retval
= reply
->old_id
;
2137 wndPtr
->hInstance
= (HINSTANCE
)newval
;
2138 retval
= (ULONG_PTR
)reply
->old_instance
;
2141 wndPtr
->userdata
= newval
;
2142 retval
= (ULONG_PTR
)reply
->old_user_data
;
2146 void *ptr
= (char *)wndPtr
->wExtra
+ offset
;
2147 memcpy( &retval
, ptr
, sizeof(retval
) );
2148 memcpy( ptr
, &newval
, sizeof(newval
) );
2155 WIN_ReleasePtr( wndPtr
);
2159 if (offset
== GWL_STYLE
&& USER_Driver
.pSetWindowStyle
)
2160 USER_Driver
.pSetWindowStyle( hwnd
, retval
);
2162 if (offset
== GWL_STYLE
|| offset
== GWL_EXSTYLE
)
2163 SendMessageW( hwnd
, WM_STYLECHANGED
, offset
, (LPARAM
)&style
);
2169 /**********************************************************************
2170 * GetWindowLong (USER.135)
2172 LONG WINAPI
GetWindowLong16( HWND16 hwnd
, INT16 offset
)
2174 return WIN_GetWindowLong( WIN_Handle32(hwnd
), offset
, WIN_PROC_16
);
2178 /**********************************************************************
2179 * GetWindowLongA (USER32.@)
2181 LONG WINAPI
GetWindowLongA( HWND hwnd
, INT offset
)
2183 return WIN_GetWindowLong( hwnd
, offset
, WIN_PROC_32A
);
2187 /**********************************************************************
2188 * GetWindowLongW (USER32.@)
2190 LONG WINAPI
GetWindowLongW( HWND hwnd
, INT offset
)
2192 return WIN_GetWindowLong( hwnd
, offset
, WIN_PROC_32W
);
2196 /**********************************************************************
2197 * SetWindowLong (USER.136)
2199 LONG WINAPI
SetWindowLong16( HWND16 hwnd
, INT16 offset
, LONG newval
)
2201 return WIN_SetWindowLong( WIN_Handle32(hwnd
), offset
, newval
, WIN_PROC_16
);
2205 /**********************************************************************
2206 * SetWindowLongA (USER32.@)
2208 LONG WINAPI
SetWindowLongA( HWND hwnd
, INT offset
, LONG newval
)
2210 return WIN_SetWindowLong( hwnd
, offset
, newval
, WIN_PROC_32A
);
2214 /**********************************************************************
2215 * SetWindowLongW (USER32.@) Set window attribute
2217 * SetWindowLong() alters one of a window's attributes or sets a 32-bit (long)
2218 * value in a window's extra memory.
2220 * The _hwnd_ parameter specifies the window. is the handle to a
2221 * window that has extra memory. The _newval_ parameter contains the
2222 * new attribute or extra memory value. If positive, the _offset_
2223 * parameter is the byte-addressed location in the window's extra
2224 * memory to set. If negative, _offset_ specifies the window
2225 * attribute to set, and should be one of the following values:
2227 * GWL_EXSTYLE The window's extended window style
2229 * GWL_STYLE The window's window style.
2231 * GWL_WNDPROC Pointer to the window's window procedure.
2233 * GWL_HINSTANCE The window's pplication instance handle.
2235 * GWL_ID The window's identifier.
2237 * GWL_USERDATA The window's user-specified data.
2239 * If the window is a dialog box, the _offset_ parameter can be one of
2240 * the following values:
2242 * DWL_DLGPROC The address of the window's dialog box procedure.
2244 * DWL_MSGRESULT The return value of a message
2245 * that the dialog box procedure processed.
2247 * DWL_USER Application specific information.
2251 * If successful, returns the previous value located at _offset_. Otherwise,
2256 * Extra memory for a window class is specified by a nonzero cbWndExtra
2257 * parameter of the WNDCLASS structure passed to RegisterClass() at the
2258 * time of class creation.
2260 * Using GWL_WNDPROC to set a new window procedure effectively creates
2261 * a window subclass. Use CallWindowProc() in the new windows procedure
2262 * to pass messages to the superclass's window procedure.
2264 * The user data is reserved for use by the application which created
2267 * Do not use GWL_STYLE to change the window's WS_DISABLED style;
2268 * instead, call the EnableWindow() function to change the window's
2271 * Do not use GWL_HWNDPARENT to reset the window's parent, use
2272 * SetParent() instead.
2275 * When offset is GWL_STYLE and the calling app's ver is 4.0,
2276 * it sends WM_STYLECHANGING before changing the settings
2277 * and WM_STYLECHANGED afterwards.
2278 * App ver 4.0 can't use SetWindowLong to change WS_EX_TOPMOST.
2280 LONG WINAPI
SetWindowLongW(
2281 HWND hwnd
, /* [in] window to alter */
2282 INT offset
, /* [in] offset, in bytes, of location to alter */
2283 LONG newval
/* [in] new value of location */
2285 return WIN_SetWindowLong( hwnd
, offset
, newval
, WIN_PROC_32W
);
2289 /*******************************************************************
2290 * GetWindowTextA (USER32.@)
2292 INT WINAPI
GetWindowTextA( HWND hwnd
, LPSTR lpString
, INT nMaxCount
)
2296 if (WIN_IsCurrentProcess( hwnd
))
2297 return (INT
)SendMessageA( hwnd
, WM_GETTEXT
, nMaxCount
, (LPARAM
)lpString
);
2299 /* when window belongs to other process, don't send a message */
2300 if (nMaxCount
<= 0) return 0;
2301 if (!(buffer
= HeapAlloc( GetProcessHeap(), 0, nMaxCount
* sizeof(WCHAR
) ))) return 0;
2302 get_server_window_text( hwnd
, buffer
, nMaxCount
);
2303 if (!WideCharToMultiByte( CP_ACP
, 0, buffer
, -1, lpString
, nMaxCount
, NULL
, NULL
))
2304 lpString
[nMaxCount
-1] = 0;
2305 HeapFree( GetProcessHeap(), 0, buffer
);
2306 return strlen(lpString
);
2310 /*******************************************************************
2311 * InternalGetWindowText (USER32.@)
2313 INT WINAPI
InternalGetWindowText(HWND hwnd
,LPWSTR lpString
,INT nMaxCount
)
2317 if (nMaxCount
<= 0) return 0;
2318 if (!(win
= WIN_GetPtr( hwnd
))) return 0;
2319 if (win
!= WND_OTHER_PROCESS
)
2321 if (win
->text
) lstrcpynW( lpString
, win
->text
, nMaxCount
);
2322 else lpString
[0] = 0;
2323 WIN_ReleasePtr( win
);
2327 get_server_window_text( hwnd
, lpString
, nMaxCount
);
2329 return strlenW(lpString
);
2333 /*******************************************************************
2334 * GetWindowTextW (USER32.@)
2336 INT WINAPI
GetWindowTextW( HWND hwnd
, LPWSTR lpString
, INT nMaxCount
)
2338 if (WIN_IsCurrentProcess( hwnd
))
2339 return (INT
)SendMessageW( hwnd
, WM_GETTEXT
, nMaxCount
, (LPARAM
)lpString
);
2341 /* when window belongs to other process, don't send a message */
2342 if (nMaxCount
<= 0) return 0;
2343 get_server_window_text( hwnd
, lpString
, nMaxCount
);
2344 return strlenW(lpString
);
2348 /*******************************************************************
2349 * SetWindowText (USER32.@)
2350 * SetWindowTextA (USER32.@)
2352 BOOL WINAPI
SetWindowTextA( HWND hwnd
, LPCSTR lpString
)
2354 if (is_broadcast(hwnd
))
2356 SetLastError( ERROR_INVALID_PARAMETER
);
2359 if (!WIN_IsCurrentProcess( hwnd
))
2361 FIXME( "cannot set text %s of other process window %p\n", debugstr_a(lpString
), hwnd
);
2362 SetLastError( ERROR_ACCESS_DENIED
);
2365 return (BOOL
)SendMessageA( hwnd
, WM_SETTEXT
, 0, (LPARAM
)lpString
);
2369 /*******************************************************************
2370 * SetWindowTextW (USER32.@)
2372 BOOL WINAPI
SetWindowTextW( HWND hwnd
, LPCWSTR lpString
)
2374 if (is_broadcast(hwnd
))
2376 SetLastError( ERROR_INVALID_PARAMETER
);
2379 if (!WIN_IsCurrentProcess( hwnd
))
2381 FIXME( "cannot set text %s of other process window %p\n", debugstr_w(lpString
), hwnd
);
2382 SetLastError( ERROR_ACCESS_DENIED
);
2385 return (BOOL
)SendMessageW( hwnd
, WM_SETTEXT
, 0, (LPARAM
)lpString
);
2389 /*******************************************************************
2390 * GetWindowTextLengthA (USER32.@)
2392 INT WINAPI
GetWindowTextLengthA( HWND hwnd
)
2394 return SendMessageA( hwnd
, WM_GETTEXTLENGTH
, 0, 0 );
2397 /*******************************************************************
2398 * GetWindowTextLengthW (USER32.@)
2400 INT WINAPI
GetWindowTextLengthW( HWND hwnd
)
2402 return SendMessageW( hwnd
, WM_GETTEXTLENGTH
, 0, 0 );
2406 /*******************************************************************
2407 * IsWindow (USER32.@)
2409 BOOL WINAPI
IsWindow( HWND hwnd
)
2414 if (!(ptr
= WIN_GetPtr( hwnd
))) return FALSE
;
2416 if (ptr
!= WND_OTHER_PROCESS
)
2418 WIN_ReleasePtr( ptr
);
2422 /* check other processes */
2423 SERVER_START_REQ( get_window_info
)
2426 ret
= !wine_server_call_err( req
);
2433 /***********************************************************************
2434 * GetWindowThreadProcessId (USER32.@)
2436 DWORD WINAPI
GetWindowThreadProcessId( HWND hwnd
, LPDWORD process
)
2441 if (!(ptr
= WIN_GetPtr( hwnd
)))
2443 SetLastError( ERROR_INVALID_WINDOW_HANDLE
);
2447 if (ptr
!= WND_OTHER_PROCESS
)
2449 /* got a valid window */
2451 if (process
) *process
= GetCurrentProcessId();
2452 WIN_ReleasePtr( ptr
);
2456 /* check other processes */
2457 SERVER_START_REQ( get_window_info
)
2460 if (!wine_server_call_err( req
))
2462 tid
= (DWORD
)reply
->tid
;
2463 if (process
) *process
= (DWORD
)reply
->pid
;
2471 /*****************************************************************
2472 * GetParent (USER32.@)
2474 HWND WINAPI
GetParent( HWND hwnd
)
2479 if (!(wndPtr
= WIN_GetPtr( hwnd
)))
2481 SetLastError( ERROR_INVALID_WINDOW_HANDLE
);
2484 if (wndPtr
== WND_OTHER_PROCESS
)
2486 LONG style
= GetWindowLongW( hwnd
, GWL_STYLE
);
2487 if (style
& (WS_POPUP
| WS_CHILD
))
2489 SERVER_START_REQ( get_window_tree
)
2492 if (!wine_server_call_err( req
))
2494 if (style
& WS_POPUP
) retvalue
= reply
->owner
;
2495 else if (style
& WS_CHILD
) retvalue
= reply
->parent
;
2503 if (wndPtr
->dwStyle
& WS_POPUP
) retvalue
= wndPtr
->owner
;
2504 else if (wndPtr
->dwStyle
& WS_CHILD
) retvalue
= wndPtr
->parent
;
2505 WIN_ReleasePtr( wndPtr
);
2511 /*****************************************************************
2512 * GetAncestor (USER32.@)
2514 HWND WINAPI
GetAncestor( HWND hwnd
, UINT type
)
2517 HWND
*list
, ret
= 0;
2522 if (!(win
= WIN_GetPtr( hwnd
)))
2524 SetLastError( ERROR_INVALID_WINDOW_HANDLE
);
2527 if (win
!= WND_OTHER_PROCESS
)
2530 WIN_ReleasePtr( win
);
2532 else /* need to query the server */
2534 SERVER_START_REQ( get_window_tree
)
2537 if (!wine_server_call_err( req
)) ret
= reply
->parent
;
2544 if (!(list
= WIN_ListParents( hwnd
))) return 0;
2546 if (!list
[0] || !list
[1]) ret
= WIN_GetFullHandle( hwnd
); /* top-level window */
2550 while (list
[count
]) count
++;
2551 ret
= list
[count
- 2]; /* get the one before the desktop */
2553 HeapFree( GetProcessHeap(), 0, list
);
2557 if ((ret
= WIN_GetFullHandle( hwnd
)) == GetDesktopWindow()) return 0;
2560 HWND parent
= GetParent( ret
);
2570 /*****************************************************************
2571 * SetParent (USER32.@)
2573 HWND WINAPI
SetParent( HWND hwnd
, HWND parent
)
2576 HWND retvalue
, full_handle
;
2579 if (is_broadcast(hwnd
) || is_broadcast(parent
))
2581 SetLastError(ERROR_INVALID_PARAMETER
);
2585 if (!parent
) parent
= GetDesktopWindow();
2586 else parent
= WIN_GetFullHandle( parent
);
2588 if (!IsWindow( parent
))
2590 SetLastError( ERROR_INVALID_WINDOW_HANDLE
);
2594 if (!(full_handle
= WIN_IsCurrentThread( hwnd
)))
2595 return (HWND
)SendMessageW( hwnd
, WM_WINE_SETPARENT
, (WPARAM
)parent
, 0 );
2599 if (USER_Driver
.pSetParent
)
2600 return USER_Driver
.pSetParent( hwnd
, parent
);
2602 /* Windows hides the window first, then shows it again
2603 * including the WM_SHOWWINDOW messages and all */
2604 was_visible
= ShowWindow( hwnd
, SW_HIDE
);
2606 if (!IsWindow( parent
)) return 0;
2607 if (!(wndPtr
= WIN_GetPtr(hwnd
)) || wndPtr
== WND_OTHER_PROCESS
) return 0;
2609 retvalue
= wndPtr
->parent
; /* old parent */
2610 if (parent
!= retvalue
)
2612 WIN_LinkWindow( hwnd
, parent
, HWND_TOP
);
2614 if (parent
!= GetDesktopWindow()) /* a child window */
2616 if (!(wndPtr
->dwStyle
& WS_CHILD
))
2618 HMENU menu
= (HMENU
)SetWindowLongW( hwnd
, GWL_ID
, 0 );
2619 if (menu
) DestroyMenu( menu
);
2623 WIN_ReleasePtr( wndPtr
);
2625 /* SetParent additionally needs to make hwnd the topmost window
2626 in the x-order and send the expected WM_WINDOWPOSCHANGING and
2627 WM_WINDOWPOSCHANGED notification messages.
2629 SetWindowPos( hwnd
, HWND_TOPMOST
, 0, 0, 0, 0,
2630 SWP_NOACTIVATE
| SWP_NOMOVE
| SWP_NOSIZE
| (was_visible
? SWP_SHOWWINDOW
: 0) );
2631 /* FIXME: a WM_MOVE is also generated (in the DefWindowProc handler
2632 * for WM_WINDOWPOSCHANGED) in Windows, should probably remove SWP_NOMOVE */
2637 /*******************************************************************
2638 * IsChild (USER32.@)
2640 BOOL WINAPI
IsChild( HWND parent
, HWND child
)
2642 HWND
*list
= WIN_ListParents( child
);
2646 if (!list
) return FALSE
;
2647 parent
= WIN_GetFullHandle( parent
);
2648 for (i
= 0; list
[i
]; i
++) if (list
[i
] == parent
) break;
2649 ret
= (list
[i
] != 0);
2650 HeapFree( GetProcessHeap(), 0, list
);
2655 /***********************************************************************
2656 * IsWindowVisible (USER32.@)
2658 BOOL WINAPI
IsWindowVisible( HWND hwnd
)
2664 if (!(GetWindowLongW( hwnd
, GWL_STYLE
) & WS_VISIBLE
)) return FALSE
;
2665 if (!(list
= WIN_ListParents( hwnd
))) return TRUE
;
2666 for (i
= 0; list
[i
]; i
++)
2667 if (!(GetWindowLongW( list
[i
], GWL_STYLE
) & WS_VISIBLE
)) break;
2669 HeapFree( GetProcessHeap(), 0, list
);
2674 /***********************************************************************
2675 * WIN_IsWindowDrawable
2677 * hwnd is drawable when it is visible, all parents are not
2678 * minimized, and it is itself not minimized unless we are
2679 * trying to draw its default class icon.
2681 BOOL
WIN_IsWindowDrawable( HWND hwnd
, BOOL icon
)
2686 LONG style
= GetWindowLongW( hwnd
, GWL_STYLE
);
2688 if (!(style
& WS_VISIBLE
)) return FALSE
;
2689 if ((style
& WS_MINIMIZE
) && icon
&& GetClassLongA( hwnd
, GCL_HICON
)) return FALSE
;
2691 if (!(list
= WIN_ListParents( hwnd
))) return TRUE
;
2692 for (i
= 0; list
[i
]; i
++)
2693 if ((GetWindowLongW( list
[i
], GWL_STYLE
) & (WS_VISIBLE
|WS_MINIMIZE
)) != WS_VISIBLE
)
2696 HeapFree( GetProcessHeap(), 0, list
);
2701 /*******************************************************************
2702 * GetTopWindow (USER32.@)
2704 HWND WINAPI
GetTopWindow( HWND hwnd
)
2706 if (!hwnd
) hwnd
= GetDesktopWindow();
2707 return GetWindow( hwnd
, GW_CHILD
);
2711 /*******************************************************************
2712 * GetWindow (USER32.@)
2714 HWND WINAPI
GetWindow( HWND hwnd
, UINT rel
)
2718 if (rel
== GW_OWNER
) /* this one may be available locally */
2720 WND
*wndPtr
= WIN_GetPtr( hwnd
);
2723 SetLastError( ERROR_INVALID_HANDLE
);
2726 if (wndPtr
!= WND_OTHER_PROCESS
)
2728 retval
= wndPtr
->owner
;
2729 WIN_ReleasePtr( wndPtr
);
2732 /* else fall through to server call */
2735 SERVER_START_REQ( get_window_tree
)
2738 if (!wine_server_call_err( req
))
2743 retval
= reply
->first_sibling
;
2746 retval
= reply
->last_sibling
;
2749 retval
= reply
->next_sibling
;
2752 retval
= reply
->prev_sibling
;
2755 retval
= reply
->owner
;
2758 retval
= reply
->first_child
;
2768 /***********************************************************************
2769 * WIN_InternalShowOwnedPopups
2771 * Internal version of ShowOwnedPopups; Wine functions should use this
2772 * to avoid interfering with application calls to ShowOwnedPopups
2773 * and to make sure the application can't prevent showing/hiding.
2775 * Set unmanagedOnly to TRUE to show/hide unmanaged windows only.
2779 BOOL
WIN_InternalShowOwnedPopups( HWND owner
, BOOL fShow
, BOOL unmanagedOnly
)
2783 HWND
*win_array
= WIN_ListChildren( GetDesktopWindow() );
2785 if (!win_array
) return TRUE
;
2788 * Show windows Lowest first, Highest last to preserve Z-Order
2790 while (win_array
[count
]) count
++;
2791 while (--count
>= 0)
2793 if (GetWindow( win_array
[count
], GW_OWNER
) != owner
) continue;
2794 if (!(pWnd
= WIN_FindWndPtr( win_array
[count
] ))) continue;
2796 if (pWnd
->dwStyle
& WS_POPUP
)
2800 /* check in window was flagged for showing in previous WIN_InternalShowOwnedPopups call */
2801 if (pWnd
->flags
& WIN_NEEDS_INTERNALSOP
)
2804 * Call ShowWindow directly because an application can intercept WM_SHOWWINDOW messages
2806 ShowWindow(pWnd
->hwndSelf
,SW_SHOW
);
2807 pWnd
->flags
&= ~WIN_NEEDS_INTERNALSOP
; /* remove the flag */
2812 if ( IsWindowVisible(pWnd
->hwndSelf
) && /* hide only if window is visible */
2813 !( pWnd
->flags
& WIN_NEEDS_INTERNALSOP
) && /* don't hide if previous call already did it */
2814 !( unmanagedOnly
&& (pWnd
->dwExStyle
& WS_EX_MANAGED
) ) ) /* don't hide managed windows if unmanagedOnly is TRUE */
2817 * Call ShowWindow directly because an application can intercept WM_SHOWWINDOW messages
2819 ShowWindow(pWnd
->hwndSelf
,SW_HIDE
);
2820 /* flag the window for showing on next WIN_InternalShowOwnedPopups call */
2821 pWnd
->flags
|= WIN_NEEDS_INTERNALSOP
;
2825 WIN_ReleaseWndPtr( pWnd
);
2827 HeapFree( GetProcessHeap(), 0, win_array
);
2832 /*******************************************************************
2833 * ShowOwnedPopups (USER32.@)
2835 BOOL WINAPI
ShowOwnedPopups( HWND owner
, BOOL fShow
)
2839 HWND
*win_array
= WIN_ListChildren( GetDesktopWindow() );
2841 if (!win_array
) return TRUE
;
2843 while (win_array
[count
]) count
++;
2844 while (--count
>= 0)
2846 if (GetWindow( win_array
[count
], GW_OWNER
) != owner
) continue;
2847 if (!(pWnd
= WIN_FindWndPtr( win_array
[count
] ))) continue;
2849 if (pWnd
->dwStyle
& WS_POPUP
)
2853 if (pWnd
->flags
& WIN_NEEDS_SHOW_OWNEDPOPUP
)
2855 /* In Windows, ShowOwnedPopups(TRUE) generates
2856 * WM_SHOWWINDOW messages with SW_PARENTOPENING,
2857 * regardless of the state of the owner
2859 SendMessageA(pWnd
->hwndSelf
, WM_SHOWWINDOW
, SW_SHOW
, SW_PARENTOPENING
);
2860 pWnd
->flags
&= ~WIN_NEEDS_SHOW_OWNEDPOPUP
;
2865 if (IsWindowVisible(pWnd
->hwndSelf
))
2867 /* In Windows, ShowOwnedPopups(FALSE) generates
2868 * WM_SHOWWINDOW messages with SW_PARENTCLOSING,
2869 * regardless of the state of the owner
2871 SendMessageA(pWnd
->hwndSelf
, WM_SHOWWINDOW
, SW_HIDE
, SW_PARENTCLOSING
);
2872 pWnd
->flags
|= WIN_NEEDS_SHOW_OWNEDPOPUP
;
2876 WIN_ReleaseWndPtr( pWnd
);
2878 HeapFree( GetProcessHeap(), 0, win_array
);
2883 /*******************************************************************
2884 * GetLastActivePopup (USER32.@)
2886 HWND WINAPI
GetLastActivePopup( HWND hwnd
)
2890 SERVER_START_REQ( get_window_info
)
2893 if (!wine_server_call_err( req
)) retval
= reply
->last_active
;
2900 /*******************************************************************
2903 * Build an array of all parents of a given window, starting with
2904 * the immediate parent. The array must be freed with HeapFree.
2905 * Returns NULL if window is a top-level window.
2907 HWND
*WIN_ListParents( HWND hwnd
)
2910 HWND current
, *list
;
2911 int pos
= 0, size
= 16, count
= 0;
2913 if (!(list
= HeapAlloc( GetProcessHeap(), 0, size
* sizeof(HWND
) ))) return NULL
;
2918 if (!(win
= WIN_GetPtr( current
))) goto empty
;
2919 if (win
== WND_OTHER_PROCESS
) break; /* need to do it the hard way */
2920 list
[pos
] = win
->parent
;
2921 WIN_ReleasePtr( win
);
2922 if (!(current
= list
[pos
]))
2924 if (!pos
) goto empty
;
2927 if (++pos
== size
- 1)
2929 /* need to grow the list */
2930 HWND
*new_list
= HeapReAlloc( GetProcessHeap(), 0, list
, (size
+16) * sizeof(HWND
) );
2931 if (!new_list
) goto empty
;
2937 /* at least one parent belongs to another process, have to query the server */
2942 SERVER_START_REQ( get_window_parents
)
2945 wine_server_set_reply( req
, list
, (size
-1) * sizeof(HWND
) );
2946 if (!wine_server_call( req
)) count
= reply
->count
;
2949 if (!count
) goto empty
;
2955 HeapFree( GetProcessHeap(), 0, list
);
2957 if (!(list
= HeapAlloc( GetProcessHeap(), 0, size
* sizeof(HWND
) ))) return NULL
;
2961 HeapFree( GetProcessHeap(), 0, list
);
2966 /*******************************************************************
2969 * Build an array of the children of a given window. The array must be
2970 * freed with HeapFree. Returns NULL when no windows are found.
2972 HWND
*WIN_ListChildren( HWND hwnd
)
2974 return list_window_children( hwnd
, 0, 0 );
2978 /*******************************************************************
2979 * EnumWindows (USER32.@)
2981 BOOL WINAPI
EnumWindows( WNDENUMPROC lpEnumFunc
, LPARAM lParam
)
2987 /* We have to build a list of all windows first, to avoid */
2988 /* unpleasant side-effects, for instance if the callback */
2989 /* function changes the Z-order of the windows. */
2991 if (!(list
= WIN_ListChildren( GetDesktopWindow() ))) return TRUE
;
2993 /* Now call the callback function for every window */
2995 iWndsLocks
= WIN_SuspendWndsLock();
2996 for (i
= 0; list
[i
]; i
++)
2998 /* Make sure that the window still exists */
2999 if (!IsWindow( list
[i
] )) continue;
3000 if (!(ret
= lpEnumFunc( list
[i
], lParam
))) break;
3002 WIN_RestoreWndsLock(iWndsLocks
);
3003 HeapFree( GetProcessHeap(), 0, list
);
3008 /**********************************************************************
3009 * EnumThreadWindows (USER32.@)
3011 BOOL WINAPI
EnumThreadWindows( DWORD id
, WNDENUMPROC func
, LPARAM lParam
)
3016 if (!(list
= list_window_children( GetDesktopWindow(), 0, id
))) return TRUE
;
3018 /* Now call the callback function for every window */
3020 iWndsLocks
= WIN_SuspendWndsLock();
3021 for (i
= 0; list
[i
]; i
++)
3022 if (!func( list
[i
], lParam
)) break;
3023 WIN_RestoreWndsLock(iWndsLocks
);
3024 HeapFree( GetProcessHeap(), 0, list
);
3029 /**********************************************************************
3030 * WIN_EnumChildWindows
3032 * Helper function for EnumChildWindows().
3034 static BOOL
WIN_EnumChildWindows( HWND
*list
, WNDENUMPROC func
, LPARAM lParam
)
3039 for ( ; *list
; list
++)
3041 /* Make sure that the window still exists */
3042 if (!IsWindow( *list
)) continue;
3043 /* skip owned windows */
3044 if (GetWindow( *list
, GW_OWNER
)) continue;
3045 /* Build children list first */
3046 childList
= WIN_ListChildren( *list
);
3048 ret
= func( *list
, lParam
);
3052 if (ret
) ret
= WIN_EnumChildWindows( childList
, func
, lParam
);
3053 HeapFree( GetProcessHeap(), 0, childList
);
3055 if (!ret
) return FALSE
;
3061 /**********************************************************************
3062 * EnumChildWindows (USER32.@)
3064 BOOL WINAPI
EnumChildWindows( HWND parent
, WNDENUMPROC func
, LPARAM lParam
)
3069 if (!(list
= WIN_ListChildren( parent
))) return FALSE
;
3070 iWndsLocks
= WIN_SuspendWndsLock();
3071 WIN_EnumChildWindows( list
, func
, lParam
);
3072 WIN_RestoreWndsLock(iWndsLocks
);
3073 HeapFree( GetProcessHeap(), 0, list
);
3078 /*******************************************************************
3079 * AnyPopup (USER.52)
3081 BOOL16 WINAPI
AnyPopup16(void)
3087 /*******************************************************************
3088 * AnyPopup (USER32.@)
3090 BOOL WINAPI
AnyPopup(void)
3094 HWND
*list
= WIN_ListChildren( GetDesktopWindow() );
3096 if (!list
) return FALSE
;
3097 for (i
= 0; list
[i
]; i
++)
3099 if (IsWindowVisible( list
[i
] ) && GetWindow( list
[i
], GW_OWNER
)) break;
3101 retvalue
= (list
[i
] != 0);
3102 HeapFree( GetProcessHeap(), 0, list
);
3107 /*******************************************************************
3108 * FlashWindow (USER32.@)
3110 BOOL WINAPI
FlashWindow( HWND hWnd
, BOOL bInvert
)
3112 WND
*wndPtr
= WIN_FindWndPtr(hWnd
);
3114 TRACE("%p\n", hWnd
);
3116 if (!wndPtr
) return FALSE
;
3117 hWnd
= wndPtr
->hwndSelf
; /* make it a full handle */
3119 if (wndPtr
->dwStyle
& WS_MINIMIZE
)
3121 if (bInvert
&& !(wndPtr
->flags
& WIN_NCACTIVATED
))
3123 HDC hDC
= GetDC(hWnd
);
3125 if (!SendMessageW( hWnd
, WM_ERASEBKGND
, (WPARAM
)hDC
, 0 ))
3126 wndPtr
->flags
|= WIN_NEEDS_ERASEBKGND
;
3128 ReleaseDC( hWnd
, hDC
);
3129 wndPtr
->flags
|= WIN_NCACTIVATED
;
3133 RedrawWindow( hWnd
, 0, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_UPDATENOW
| RDW_FRAME
);
3134 wndPtr
->flags
&= ~WIN_NCACTIVATED
;
3136 WIN_ReleaseWndPtr(wndPtr
);
3142 if (bInvert
) wparam
= !(wndPtr
->flags
& WIN_NCACTIVATED
);
3143 else wparam
= (hWnd
== GetForegroundWindow());
3145 WIN_ReleaseWndPtr(wndPtr
);
3146 SendMessageW( hWnd
, WM_NCACTIVATE
, wparam
, (LPARAM
)0 );
3151 /*******************************************************************
3152 * FlashWindowEx (USER32.@)
3154 BOOL WINAPI
FlashWindowEx( PFLASHWINFO pfwi
)
3156 FIXME("%p\n", pfwi
);
3160 /*******************************************************************
3161 * GetWindowContextHelpId (USER32.@)
3163 DWORD WINAPI
GetWindowContextHelpId( HWND hwnd
)
3166 WND
*wnd
= WIN_FindWndPtr( hwnd
);
3168 retval
= wnd
->helpContext
;
3169 WIN_ReleaseWndPtr(wnd
);
3174 /*******************************************************************
3175 * SetWindowContextHelpId (USER32.@)
3177 BOOL WINAPI
SetWindowContextHelpId( HWND hwnd
, DWORD id
)
3179 WND
*wnd
= WIN_FindWndPtr( hwnd
);
3180 if (!wnd
) return FALSE
;
3181 wnd
->helpContext
= id
;
3182 WIN_ReleaseWndPtr(wnd
);
3187 /*******************************************************************
3188 * DragDetect (USER32.@)
3190 BOOL WINAPI
DragDetect( HWND hWnd
, POINT pt
)
3195 rect
.left
= pt
.x
- wDragWidth
;
3196 rect
.right
= pt
.x
+ wDragWidth
;
3198 rect
.top
= pt
.y
- wDragHeight
;
3199 rect
.bottom
= pt
.y
+ wDragHeight
;
3205 while(PeekMessageA(&msg
,0 ,WM_MOUSEFIRST
,WM_MOUSELAST
,PM_REMOVE
))
3207 if( msg
.message
== WM_LBUTTONUP
)
3212 if( msg
.message
== WM_MOUSEMOVE
)
3215 tmp
.x
= LOWORD(msg
.lParam
);
3216 tmp
.y
= HIWORD(msg
.lParam
);
3217 if( !PtInRect( &rect
, tmp
))
3229 /******************************************************************************
3230 * GetWindowModuleFileNameA (USER32.@)
3232 UINT WINAPI
GetWindowModuleFileNameA( HWND hwnd
, LPSTR lpszFileName
, UINT cchFileNameMax
)
3234 FIXME("GetWindowModuleFileNameA(hwnd %p, lpszFileName %p, cchFileNameMax %u) stub!\n",
3235 hwnd
, lpszFileName
, cchFileNameMax
);
3239 /******************************************************************************
3240 * GetWindowModuleFileNameW (USER32.@)
3242 UINT WINAPI
GetWindowModuleFileNameW( HWND hwnd
, LPWSTR lpszFileName
, UINT cchFileNameMax
)
3244 FIXME("GetWindowModuleFileNameW(hwnd %p, lpszFileName %p, cchFileNameMax %u) stub!\n",
3245 hwnd
, lpszFileName
, cchFileNameMax
);
3249 /******************************************************************************
3250 * GetWindowInfo (USER32.@)
3252 * Note: tests show that Windows doesn't check cbSize of the structure.
3254 BOOL WINAPI
GetWindowInfo( HWND hwnd
, PWINDOWINFO pwi
)
3256 if (!pwi
) return FALSE
;
3257 if (!IsWindow(hwnd
)) return FALSE
;
3259 GetWindowRect(hwnd
, &pwi
->rcWindow
);
3260 GetClientRect(hwnd
, &pwi
->rcClient
);
3261 /* translate to screen coordinates */
3262 MapWindowPoints(hwnd
, 0, (LPPOINT
)&pwi
->rcClient
, 2);
3264 pwi
->dwStyle
= GetWindowLongW(hwnd
, GWL_STYLE
);
3265 pwi
->dwExStyle
= GetWindowLongW(hwnd
, GWL_EXSTYLE
);
3266 pwi
->dwWindowStatus
= ((GetActiveWindow() == hwnd
) ? WS_ACTIVECAPTION
: 0);
3268 pwi
->cxWindowBorders
= pwi
->rcClient
.left
- pwi
->rcWindow
.left
;
3269 pwi
->cyWindowBorders
= pwi
->rcWindow
.bottom
- pwi
->rcClient
.bottom
;
3271 pwi
->atomWindowType
= GetClassLongW( hwnd
, GCW_ATOM
);
3272 pwi
->wCreatorVersion
= 0x0400;
3277 /******************************************************************************
3278 * SwitchDesktop (USER32.@)
3280 * NOTES: Sets the current input or interactive desktop.
3282 BOOL WINAPI
SwitchDesktop( HDESK hDesktop
)
3284 FIXME("SwitchDesktop(hwnd %p) stub!\n", hDesktop
);