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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "user_private.h"
24 #include "wine/server.h"
26 #include "wine/exception.h"
27 #include "wine/debug.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(win
);
32 /*******************************************************************
33 * list_window_children
35 * Build an array of the children of a given window. The array must be
36 * freed with HeapFree. Returns NULL when no windows are found.
38 static HWND
*list_window_children( HDESK desktop
, HWND hwnd
, UNICODE_STRING
*class, DWORD tid
)
42 ATOM atom
= class ? get_int_atom_value( class ) : 0;
44 /* empty class is not the same as NULL class */
45 if (!atom
&& class && !class->Length
) return NULL
;
51 if (!(list
= HeapAlloc( GetProcessHeap(), 0, size
* sizeof(HWND
) ))) break;
53 SERVER_START_REQ( get_window_children
)
55 req
->desktop
= wine_server_obj_handle( desktop
);
56 req
->parent
= wine_server_user_handle( hwnd
);
59 if (!atom
&& class) wine_server_add_data( req
, class->Buffer
, class->Length
);
60 wine_server_set_reply( req
, list
, (size
-1) * sizeof(user_handle_t
) );
61 if (!wine_server_call( req
)) count
= reply
->count
;
64 if (count
&& count
< size
)
66 /* start from the end since HWND is potentially larger than user_handle_t */
67 for (i
= count
- 1; i
>= 0; i
--)
68 list
[i
] = wine_server_ptr_handle( ((user_handle_t
*)list
)[i
] );
72 HeapFree( GetProcessHeap(), 0, list
);
74 size
= count
+ 1; /* restart with a large enough buffer */
80 /*******************************************************************
83 * Check if window is the desktop or the HWND_MESSAGE top parent.
85 BOOL
is_desktop_window( HWND hwnd
)
87 struct ntuser_thread_info
*thread_info
= NtUserGetThreadInfo();
89 if (!hwnd
) return FALSE
;
90 if (hwnd
== UlongToHandle( thread_info
->top_window
)) return TRUE
;
91 if (hwnd
== UlongToHandle( thread_info
->msg_window
)) return TRUE
;
93 if (!HIWORD(hwnd
) || HIWORD(hwnd
) == 0xffff)
95 if (LOWORD(thread_info
->top_window
) == LOWORD(hwnd
)) return TRUE
;
96 if (LOWORD(thread_info
->msg_window
) == LOWORD(hwnd
)) return TRUE
;
102 /* check if hwnd is a broadcast magic handle */
103 static inline BOOL
is_broadcast( HWND hwnd
)
105 return hwnd
== HWND_BROADCAST
|| hwnd
== HWND_TOPMOST
;
109 /***********************************************************************
110 * WIN_IsCurrentProcess
112 * Check whether a given window belongs to the current process (and return the full handle).
114 HWND
WIN_IsCurrentProcess( HWND hwnd
)
116 return UlongToHandle( NtUserCallHwnd( hwnd
, NtUserIsCurrentProcessWindow
));
120 /***********************************************************************
121 * WIN_IsCurrentThread
123 * Check whether a given window belongs to the current thread (and return the full handle).
125 HWND
WIN_IsCurrentThread( HWND hwnd
)
127 return UlongToHandle( NtUserCallHwnd( hwnd
, NtUserIsCurrentThreadWindow
));
131 /***********************************************************************
134 * Convert a possibly truncated window handle to a full 32-bit handle.
136 HWND
WIN_GetFullHandle( HWND hwnd
)
138 return UlongToHandle( NtUserCallHwnd( hwnd
, NtUserGetFullWindowHandle
));
142 /***********************************************************************
145 * Change the style of a window.
147 ULONG
WIN_SetStyle( HWND hwnd
, ULONG set_bits
, ULONG clear_bits
)
149 /* FIXME: Use SetWindowLong or move callers to win32u instead.
150 * We use STYLESTRUCT to pass params, but meaning of its field does not match our usage. */
151 STYLESTRUCT style
= { .styleNew
= set_bits
, .styleOld
= clear_bits
};
152 return NtUserCallHwndParam( hwnd
, (UINT_PTR
)&style
, NtUserSetWindowStyle
);
156 /***********************************************************************
159 static void dump_window_styles( DWORD style
, DWORD exstyle
)
162 if(style
& WS_POPUP
) TRACE(" WS_POPUP");
163 if(style
& WS_CHILD
) TRACE(" WS_CHILD");
164 if(style
& WS_MINIMIZE
) TRACE(" WS_MINIMIZE");
165 if(style
& WS_VISIBLE
) TRACE(" WS_VISIBLE");
166 if(style
& WS_DISABLED
) TRACE(" WS_DISABLED");
167 if(style
& WS_CLIPSIBLINGS
) TRACE(" WS_CLIPSIBLINGS");
168 if(style
& WS_CLIPCHILDREN
) TRACE(" WS_CLIPCHILDREN");
169 if(style
& WS_MAXIMIZE
) TRACE(" WS_MAXIMIZE");
170 if((style
& WS_CAPTION
) == WS_CAPTION
) TRACE(" WS_CAPTION");
173 if(style
& WS_BORDER
) TRACE(" WS_BORDER");
174 if(style
& WS_DLGFRAME
) TRACE(" WS_DLGFRAME");
176 if(style
& WS_VSCROLL
) TRACE(" WS_VSCROLL");
177 if(style
& WS_HSCROLL
) TRACE(" WS_HSCROLL");
178 if(style
& WS_SYSMENU
) TRACE(" WS_SYSMENU");
179 if(style
& WS_THICKFRAME
) TRACE(" WS_THICKFRAME");
180 if (style
& WS_CHILD
)
182 if(style
& WS_GROUP
) TRACE(" WS_GROUP");
183 if(style
& WS_TABSTOP
) TRACE(" WS_TABSTOP");
187 if(style
& WS_MINIMIZEBOX
) TRACE(" WS_MINIMIZEBOX");
188 if(style
& WS_MAXIMIZEBOX
) TRACE(" WS_MAXIMIZEBOX");
191 /* FIXME: Add dumping of BS_/ES_/SBS_/LBS_/CBS_/DS_/etc. styles */
192 #define DUMPED_STYLES \
193 ((DWORD)(WS_POPUP | \
212 if(style
& ~DUMPED_STYLES
) TRACE(" %08lx", style
& ~DUMPED_STYLES
);
217 if(exstyle
& WS_EX_DLGMODALFRAME
) TRACE(" WS_EX_DLGMODALFRAME");
218 if(exstyle
& WS_EX_DRAGDETECT
) TRACE(" WS_EX_DRAGDETECT");
219 if(exstyle
& WS_EX_NOPARENTNOTIFY
) TRACE(" WS_EX_NOPARENTNOTIFY");
220 if(exstyle
& WS_EX_TOPMOST
) TRACE(" WS_EX_TOPMOST");
221 if(exstyle
& WS_EX_ACCEPTFILES
) TRACE(" WS_EX_ACCEPTFILES");
222 if(exstyle
& WS_EX_TRANSPARENT
) TRACE(" WS_EX_TRANSPARENT");
223 if(exstyle
& WS_EX_MDICHILD
) TRACE(" WS_EX_MDICHILD");
224 if(exstyle
& WS_EX_TOOLWINDOW
) TRACE(" WS_EX_TOOLWINDOW");
225 if(exstyle
& WS_EX_WINDOWEDGE
) TRACE(" WS_EX_WINDOWEDGE");
226 if(exstyle
& WS_EX_CLIENTEDGE
) TRACE(" WS_EX_CLIENTEDGE");
227 if(exstyle
& WS_EX_CONTEXTHELP
) TRACE(" WS_EX_CONTEXTHELP");
228 if(exstyle
& WS_EX_RIGHT
) TRACE(" WS_EX_RIGHT");
229 if(exstyle
& WS_EX_RTLREADING
) TRACE(" WS_EX_RTLREADING");
230 if(exstyle
& WS_EX_LEFTSCROLLBAR
) TRACE(" WS_EX_LEFTSCROLLBAR");
231 if(exstyle
& WS_EX_CONTROLPARENT
) TRACE(" WS_EX_CONTROLPARENT");
232 if(exstyle
& WS_EX_STATICEDGE
) TRACE(" WS_EX_STATICEDGE");
233 if(exstyle
& WS_EX_APPWINDOW
) TRACE(" WS_EX_APPWINDOW");
234 if(exstyle
& WS_EX_LAYERED
) TRACE(" WS_EX_LAYERED");
235 if(exstyle
& WS_EX_NOINHERITLAYOUT
) TRACE(" WS_EX_NOINHERITLAYOUT");
236 if(exstyle
& WS_EX_LAYOUTRTL
) TRACE(" WS_EX_LAYOUTRTL");
237 if(exstyle
& WS_EX_COMPOSITED
) TRACE(" WS_EX_COMPOSITED");
238 if(exstyle
& WS_EX_NOACTIVATE
) TRACE(" WS_EX_NOACTIVATE");
240 #define DUMPED_EX_STYLES \
241 ((DWORD)(WS_EX_DLGMODALFRAME | \
243 WS_EX_NOPARENTNOTIFY | \
245 WS_EX_ACCEPTFILES | \
246 WS_EX_TRANSPARENT | \
251 WS_EX_CONTEXTHELP | \
254 WS_EX_LEFTSCROLLBAR | \
255 WS_EX_CONTROLPARENT | \
259 WS_EX_NOINHERITLAYOUT | \
264 if(exstyle
& ~DUMPED_EX_STYLES
) TRACE(" %08lx", exstyle
& ~DUMPED_EX_STYLES
);
266 #undef DUMPED_EX_STYLES
269 static BOOL
is_default_coord( int x
)
271 return x
== CW_USEDEFAULT
|| x
== 0x8000;
274 /***********************************************************************
277 * Implementation of CreateWindowEx().
279 HWND
WIN_CreateWindowEx( CREATESTRUCTW
*cs
, LPCWSTR className
, HINSTANCE module
, BOOL unicode
)
281 UNICODE_STRING
class, window_name
= {0};
282 HWND hwnd
, top_child
= 0;
283 MDICREATESTRUCTW mdi_cs
;
288 if (!get_class_info( module
, className
, &info
, &class, FALSE
)) return FALSE
;
290 TRACE("%s %s%s%s ex=%08lx style=%08lx %d,%d %dx%d parent=%p menu=%p inst=%p params=%p\n",
291 unicode
? debugstr_w(cs
->lpszName
) : debugstr_a((LPCSTR
)cs
->lpszName
),
292 debugstr_w(className
), class.Buffer
!= className
? "->" : "",
293 class.Buffer
!= className
? debugstr_wn(class.Buffer
, class.Length
/ sizeof(WCHAR
)) : "",
294 cs
->dwExStyle
, cs
->style
, cs
->x
, cs
->y
, cs
->cx
, cs
->cy
,
295 cs
->hwndParent
, cs
->hMenu
, cs
->hInstance
, cs
->lpCreateParams
);
296 if(TRACE_ON(win
)) dump_window_styles( cs
->style
, cs
->dwExStyle
);
298 /* Fix the styles for MDI children */
299 if (cs
->dwExStyle
& WS_EX_MDICHILD
)
304 if (!NtUserGetMDIClientInfo( cs
->hwndParent
))
306 WARN("WS_EX_MDICHILD, but parent %p is not MDIClient\n", cs
->hwndParent
);
310 /* cs->lpCreateParams of WM_[NC]CREATE is different for MDI children.
311 * MDICREATESTRUCT members have the originally passed values.
313 * Note: we rely on the fact that MDICREATESTRUCTA and MDICREATESTRUCTW
314 * have the same layout.
316 mdi_cs
.szClass
= cs
->lpszClass
;
317 mdi_cs
.szTitle
= cs
->lpszName
;
318 mdi_cs
.hOwner
= cs
->hInstance
;
323 mdi_cs
.style
= cs
->style
;
324 mdi_cs
.lParam
= (LPARAM
)cs
->lpCreateParams
;
326 cs
->lpCreateParams
= &mdi_cs
;
328 if (GetWindowLongW(cs
->hwndParent
, GWL_STYLE
) & MDIS_ALLCHILDSTYLES
)
330 if (cs
->style
& WS_POPUP
)
332 TRACE("WS_POPUP with MDIS_ALLCHILDSTYLES is not allowed\n");
335 cs
->style
|= WS_CHILD
| WS_CLIPSIBLINGS
;
339 cs
->style
&= ~WS_POPUP
;
340 cs
->style
|= WS_CHILD
| WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_CAPTION
|
341 WS_SYSMENU
| WS_THICKFRAME
| WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
;
344 top_child
= GetWindow(cs
->hwndParent
, GW_CHILD
);
348 /* Restore current maximized child */
349 if((cs
->style
& WS_VISIBLE
) && IsZoomed(top_child
))
351 TRACE("Restoring current maximized child %p\n", top_child
);
352 if (cs
->style
& WS_MAXIMIZE
)
354 /* if the new window is maximized don't bother repainting */
355 SendMessageW( top_child
, WM_SETREDRAW
, FALSE
, 0 );
356 NtUserShowWindow( top_child
, SW_SHOWNORMAL
);
357 SendMessageW( top_child
, WM_SETREDRAW
, TRUE
, 0 );
359 else NtUserShowWindow( top_child
, SW_SHOWNORMAL
);
363 MDI_CalcDefaultChildPos( cs
->hwndParent
, -1, pos
, 0, &id
);
364 if (!(cs
->style
& WS_POPUP
)) cs
->hMenu
= ULongToHandle(id
);
366 TRACE( "MDI child id %04x\n", id
);
368 if (cs
->style
& (WS_CHILD
| WS_POPUP
))
370 if (is_default_coord( cs
->x
))
375 if (is_default_coord( cs
->cx
) || !cs
->cx
) cs
->cx
= pos
[1].x
;
376 if (is_default_coord( cs
->cy
) || !cs
->cy
) cs
->cy
= pos
[1].y
;
380 if (!unicode
&& cs
->lpszName
)
382 const char *nameA
= (const char *)cs
->lpszName
;
383 /* resource ID string is a special case */
384 if (nameA
[0] == '\xff')
386 name_buf
[0] = 0xffff;
387 name_buf
[1] = MAKEWORD( nameA
[1], nameA
[2] );
389 RtlInitUnicodeString( &window_name
, name_buf
);
391 else if (!RtlCreateUnicodeStringFromAsciiz( &window_name
, (const char *)cs
->lpszName
))
394 else RtlInitUnicodeString( &window_name
, cs
->lpszName
);
397 if (!menu
&& info
.lpszMenuName
&& (cs
->style
& (WS_CHILD
| WS_POPUP
)) != WS_CHILD
)
398 menu
= LoadMenuW( cs
->hInstance
, info
.lpszMenuName
);
400 hwnd
= NtUserCreateWindowEx( cs
->dwExStyle
, &class, NULL
, &window_name
, cs
->style
,
401 cs
->x
, cs
->y
, cs
->cx
, cs
->cy
, cs
->hwndParent
, menu
, module
,
402 cs
->lpCreateParams
, 0, cs
->hInstance
, 0, !unicode
);
403 if (!hwnd
&& menu
&& menu
!= cs
->hMenu
) NtUserDestroyMenu( menu
);
404 if (!unicode
&& window_name
.Buffer
!= name_buf
) RtlFreeUnicodeString( &window_name
);
409 /***********************************************************************
410 * CreateWindowExA (USER32.@)
412 HWND WINAPI DECLSPEC_HOTPATCH
CreateWindowExA( DWORD exStyle
, LPCSTR className
,
413 LPCSTR windowName
, DWORD style
, INT x
,
414 INT y
, INT width
, INT height
,
415 HWND parent
, HMENU menu
,
416 HINSTANCE instance
, LPVOID data
)
420 cs
.lpCreateParams
= data
;
421 cs
.hInstance
= instance
;
423 cs
.hwndParent
= parent
;
429 cs
.lpszName
= windowName
;
430 cs
.lpszClass
= className
;
431 cs
.dwExStyle
= exStyle
;
433 if (!IS_INTRESOURCE(className
))
436 if (!MultiByteToWideChar( CP_ACP
, 0, className
, -1, bufferW
, ARRAY_SIZE( bufferW
)))
438 return wow_handlers
.create_window( (CREATESTRUCTW
*)&cs
, bufferW
, instance
, FALSE
);
440 /* Note: we rely on the fact that CREATESTRUCTA and */
441 /* CREATESTRUCTW have the same layout. */
442 return wow_handlers
.create_window( (CREATESTRUCTW
*)&cs
, (LPCWSTR
)className
, instance
, FALSE
);
446 /***********************************************************************
447 * CreateWindowExW (USER32.@)
449 HWND WINAPI DECLSPEC_HOTPATCH
CreateWindowExW( DWORD exStyle
, LPCWSTR className
,
450 LPCWSTR windowName
, DWORD style
, INT x
,
451 INT y
, INT width
, INT height
,
452 HWND parent
, HMENU menu
,
453 HINSTANCE instance
, LPVOID data
)
457 cs
.lpCreateParams
= data
;
458 cs
.hInstance
= instance
;
460 cs
.hwndParent
= parent
;
466 cs
.lpszName
= windowName
;
467 cs
.lpszClass
= className
;
468 cs
.dwExStyle
= exStyle
;
470 return wow_handlers
.create_window( &cs
, className
, instance
, TRUE
);
474 /***********************************************************************
475 * CloseWindow (USER32.@)
477 BOOL WINAPI
CloseWindow( HWND hwnd
)
479 if (GetWindowLongW( hwnd
, GWL_STYLE
) & WS_CHILD
) return FALSE
;
480 NtUserShowWindow( hwnd
, SW_MINIMIZE
);
485 /***********************************************************************
486 * OpenIcon (USER32.@)
488 BOOL WINAPI
OpenIcon( HWND hwnd
)
490 if (!IsIconic( hwnd
)) return FALSE
;
491 NtUserShowWindow( hwnd
, SW_SHOWNORMAL
);
496 /***********************************************************************
497 * FindWindowExW (USER32.@)
499 HWND WINAPI
FindWindowExW( HWND parent
, HWND child
, const WCHAR
*class, const WCHAR
*title
)
501 UNICODE_STRING class_str
, title_str
;
503 if (title
) RtlInitUnicodeString( &title_str
, title
);
507 if (IS_INTRESOURCE(class))
509 class_str
.Buffer
= (WCHAR
*)class;
510 class_str
.Length
= class_str
.MaximumLength
= 0;
512 else RtlInitUnicodeString( &class_str
, class );
515 return NtUserFindWindowEx( parent
, child
, class ? &class_str
: NULL
,
516 title
? &title_str
: NULL
, 0 );
521 /***********************************************************************
522 * FindWindowA (USER32.@)
524 HWND WINAPI
FindWindowA( LPCSTR className
, LPCSTR title
)
526 HWND ret
= FindWindowExA( 0, 0, className
, title
);
527 if (!ret
) SetLastError (ERROR_CANNOT_FIND_WND_CLASS
);
532 /***********************************************************************
533 * FindWindowExA (USER32.@)
535 HWND WINAPI
FindWindowExA( HWND parent
, HWND child
, LPCSTR className
, LPCSTR title
)
537 LPWSTR titleW
= NULL
;
542 DWORD len
= MultiByteToWideChar( CP_ACP
, 0, title
, -1, NULL
, 0 );
543 if (!(titleW
= HeapAlloc( GetProcessHeap(), 0, len
* sizeof(WCHAR
) ))) return 0;
544 MultiByteToWideChar( CP_ACP
, 0, title
, -1, titleW
, len
);
547 if (!IS_INTRESOURCE(className
))
550 if (MultiByteToWideChar( CP_ACP
, 0, className
, -1, classW
, ARRAY_SIZE( classW
)))
551 hwnd
= FindWindowExW( parent
, child
, classW
, titleW
);
555 hwnd
= FindWindowExW( parent
, child
, (LPCWSTR
)className
, titleW
);
558 HeapFree( GetProcessHeap(), 0, titleW
);
563 /***********************************************************************
564 * FindWindowW (USER32.@)
566 HWND WINAPI
FindWindowW( LPCWSTR className
, LPCWSTR title
)
568 return FindWindowExW( 0, 0, className
, title
);
572 /**********************************************************************
573 * GetDesktopWindow (USER32.@)
575 HWND WINAPI
GetDesktopWindow(void)
577 struct ntuser_thread_info
*thread_info
= NtUserGetThreadInfo();
579 if (thread_info
->top_window
) return UlongToHandle( thread_info
->top_window
);
580 return NtUserGetDesktopWindow();
584 /*******************************************************************
585 * EnableWindow (USER32.@)
587 BOOL WINAPI
EnableWindow( HWND hwnd
, BOOL enable
)
589 return NtUserEnableWindow( hwnd
, enable
);
593 /***********************************************************************
594 * IsWindowEnabled (USER32.@)
596 BOOL WINAPI
IsWindowEnabled( HWND hwnd
)
598 return NtUserIsWindowEnabled( hwnd
);
601 /***********************************************************************
602 * IsWindowUnicode (USER32.@)
604 BOOL WINAPI
IsWindowUnicode( HWND hwnd
)
606 return NtUserIsWindowUnicode( hwnd
);
610 /***********************************************************************
611 * GetWindowDpiAwarenessContext (USER32.@)
613 DPI_AWARENESS_CONTEXT WINAPI
GetWindowDpiAwarenessContext( HWND hwnd
)
615 return NtUserGetWindowDpiAwarenessContext( hwnd
);
619 static LONG_PTR
get_window_long_ptr( HWND hwnd
, int offset
, LONG_PTR ret
, BOOL ansi
)
621 if (offset
== DWLP_DLGPROC
&& NtUserGetDialogInfo( hwnd
))
623 DLGPROC proc
= NtUserGetDialogProc( (DLGPROC
)ret
, ansi
);
624 if (proc
&& proc
!= WINPROC_PROC16
) return (LONG_PTR
)proc
;
630 static LONG_PTR
set_dialog_proc( HWND hwnd
, LONG_PTR newval
, BOOL ansi
)
634 newval
= NtUserCallTwoParam( newval
, ansi
, NtUserAllocWinProc
);
635 ret
= NtUserSetWindowLongPtr( hwnd
, DWLP_DLGPROC
, newval
, ansi
);
636 proc
= NtUserGetDialogProc( (DLGPROC
)ret
, ansi
);
637 if (proc
) ret
= (UINT_PTR
)proc
;
642 /***********************************************************************
643 * GetDpiForWindow (USER32.@)
645 UINT WINAPI
GetDpiForWindow( HWND hwnd
)
647 return NtUserGetDpiForWindow( hwnd
);
651 /***********************************************************************
652 * SwitchToThisWindow (USER32.@)
654 void WINAPI
SwitchToThisWindow( HWND hwnd
, BOOL alt_tab
)
656 if (IsIconic( hwnd
)) NtUserShowWindow( hwnd
, SW_RESTORE
);
657 else BringWindowToTop( hwnd
);
661 /***********************************************************************
662 * GetWindowRect (USER32.@)
664 BOOL WINAPI
GetWindowRect( HWND hwnd
, RECT
*rect
)
666 BOOL ret
= NtUserGetWindowRect( hwnd
, rect
);
667 if (ret
) TRACE( "hwnd %p %s\n", hwnd
, wine_dbgstr_rect(rect
) );
672 /***********************************************************************
673 * GetWindowRgn (USER32.@)
675 int WINAPI
GetWindowRgn( HWND hwnd
, HRGN hrgn
)
677 return NtUserGetWindowRgnEx( hwnd
, hrgn
, 0 );
681 /***********************************************************************
682 * GetWindowRgnBox (USER32.@)
684 int WINAPI
GetWindowRgnBox( HWND hwnd
, RECT
*rect
)
692 if ((hrgn
= CreateRectRgn( 0, 0, 0, 0 )))
694 if ((ret
= GetWindowRgn( hwnd
, hrgn
)) != ERROR
)
695 ret
= GetRgnBox( hrgn
, rect
);
696 DeleteObject( hrgn
);
703 /***********************************************************************
704 * GetClientRect (USER32.@)
706 BOOL WINAPI
GetClientRect( HWND hwnd
, RECT
*rect
)
708 return NtUserGetClientRect( hwnd
, rect
);
712 /*******************************************************************
713 * WindowFromPoint (USER32.@)
715 HWND WINAPI
WindowFromPoint( POINT pt
)
717 return NtUserWindowFromPoint( pt
.x
, pt
.y
);
721 /*******************************************************************
722 * ChildWindowFromPoint (USER32.@)
724 HWND WINAPI
ChildWindowFromPoint( HWND parent
, POINT pt
)
726 return NtUserChildWindowFromPointEx( parent
, pt
.x
, pt
.y
, CWP_ALL
);
729 /*******************************************************************
730 * RealChildWindowFromPoint (USER32.@)
732 HWND WINAPI
RealChildWindowFromPoint( HWND parent
, POINT pt
)
734 return NtUserRealChildWindowFromPoint( parent
, pt
.x
, pt
.y
);
737 /*******************************************************************
738 * ChildWindowFromPointEx (USER32.@)
740 HWND WINAPI
ChildWindowFromPointEx( HWND parent
, POINT pt
, UINT flags
)
742 return NtUserChildWindowFromPointEx( parent
, pt
.x
, pt
.y
, flags
);
746 /*******************************************************************
747 * MapWindowPoints (USER32.@)
749 INT WINAPI
MapWindowPoints( HWND hwnd_from
, HWND hwnd_to
, POINT
*points
, UINT count
)
751 return NtUserMapWindowPoints( hwnd_from
, hwnd_to
, points
, count
);
755 /*******************************************************************
756 * ClientToScreen (USER32.@)
758 BOOL WINAPI
ClientToScreen( HWND hwnd
, POINT
*pt
)
760 return NtUserClientToScreen( hwnd
, pt
);
764 /*******************************************************************
765 * ScreenToClient (USER32.@)
767 BOOL WINAPI
ScreenToClient( HWND hwnd
, POINT
*pt
)
769 return NtUserScreenToClient( hwnd
, pt
);
773 /***********************************************************************
774 * IsIconic (USER32.@)
776 BOOL WINAPI
IsIconic( HWND hwnd
)
778 return (GetWindowLongW( hwnd
, GWL_STYLE
) & WS_MINIMIZE
) != 0;
782 /***********************************************************************
783 * IsZoomed (USER32.@)
785 BOOL WINAPI
IsZoomed( HWND hwnd
)
787 return (GetWindowLongW( hwnd
, GWL_STYLE
) & WS_MAXIMIZE
) != 0;
791 /*******************************************************************
792 * AllowSetForegroundWindow (USER32.@)
794 BOOL WINAPI
AllowSetForegroundWindow( DWORD procid
)
796 /* FIXME: If Win98/2000 style SetForegroundWindow behavior is
797 * implemented, then fix this function. */
802 /*******************************************************************
803 * LockSetForegroundWindow (USER32.@)
805 BOOL WINAPI
LockSetForegroundWindow( UINT lockcode
)
807 /* FIXME: If Win98/2000 style SetForegroundWindow behavior is
808 * implemented, then fix this function. */
813 /***********************************************************************
814 * BringWindowToTop (USER32.@)
816 BOOL WINAPI
BringWindowToTop( HWND hwnd
)
818 return NtUserSetWindowPos( hwnd
, HWND_TOP
, 0, 0, 0, 0, SWP_NOMOVE
| SWP_NOSIZE
);
822 /***********************************************************************
823 * AnimateWindow (USER32.@)
825 BOOL WINAPI
AnimateWindow( HWND hwnd
, DWORD time
, DWORD flags
)
827 FIXME( "partial stub\n" );
829 /* If trying to show/hide and it's already shown/hidden or invalid window,
830 * fail with invalid parameter. */
831 if (!IsWindow( hwnd
) || (!(flags
& AW_HIDE
)) == IsWindowVisible( hwnd
))
833 SetLastError(ERROR_INVALID_PARAMETER
);
837 NtUserShowWindow( hwnd
, (flags
& AW_HIDE
) ? SW_HIDE
: ((flags
& AW_ACTIVATE
) ? SW_SHOW
: SW_SHOWNA
) );
842 /***********************************************************************
843 * BeginDeferWindowPos (USER32.@)
845 HDWP WINAPI
BeginDeferWindowPos( INT count
)
847 return NtUserBeginDeferWindowPos( count
);
851 /***********************************************************************
852 * DeferWindowPos (USER32.@)
854 HDWP WINAPI
DeferWindowPos( HDWP hdwp
, HWND hwnd
, HWND after
, INT x
, INT y
,
855 INT cx
, INT cy
, UINT flags
)
857 return NtUserDeferWindowPosAndBand( hdwp
, hwnd
, after
, x
, y
, cx
, cy
, flags
, 0, 0 );
861 /***********************************************************************
862 * EndDeferWindowPos (USER32.@)
864 BOOL WINAPI
EndDeferWindowPos( HDWP hdwp
)
866 return NtUserEndDeferWindowPosEx( hdwp
, FALSE
);
870 /***********************************************************************
871 * ArrangeIconicWindows (USER32.@)
873 UINT WINAPI
ArrangeIconicWindows( HWND parent
)
875 return NtUserArrangeIconicWindows( parent
);
879 /**********************************************************************
880 * GetWindowWord (USER32.@)
882 WORD WINAPI
GetWindowWord( HWND hwnd
, INT offset
)
884 return NtUserGetWindowWord( hwnd
, offset
);
888 /**********************************************************************
889 * GetWindowLongA (USER32.@)
894 /* This wrapper is here to workaround a ntlea quirk. First of all, ntlea
895 * checks whether GetWindowLongA starts with the Win32 hotpatchable prologue,
896 * if it can find that, it will use a hooking strategy more difficult for us
897 * to deal with. Secondly, it assumes what follows the prologue is a `pushl $-2`,
898 * and will try to skip over this instruction when calling `GetWindowLongA`,
899 * (i.e. it tries to jump to `GetWindowLongA + 7`, 5 bytes for the prologue, 2
900 * bytes for the `pushl`.). We have to anticipate that and make sure the result
901 * of doing this won't be a messed up stack, or a desynced PC.
903 __ASM_STDCALL_FUNC( GetWindowLongA
, 8,
904 ".byte 0x8b, 0xff, 0x55, 0x8b, 0xec\n" /* Win32 hotpatchable prologue. */
908 "jmp " __ASM_STDCALL("get_window_longA", 8) )
909 LONG WINAPI
get_window_longA( HWND hwnd
, INT offset
)
911 LONG WINAPI DECLSPEC_HOTPATCH
GetWindowLongA( HWND hwnd
, INT offset
)
919 case GWLP_HWNDPARENT
:
920 WARN( "Invalid offset %d\n", offset
);
921 SetLastError( ERROR_INVALID_INDEX
);
925 if (sizeof(void *) == sizeof(LONG
))
927 LONG_PTR ret
= NtUserGetWindowLongA( hwnd
, offset
);
928 return get_window_long_ptr( hwnd
, offset
, ret
, TRUE
);
930 return NtUserGetWindowLongA( hwnd
, offset
);
935 /**********************************************************************
936 * GetWindowLongW (USER32.@)
938 LONG WINAPI
GetWindowLongW( HWND hwnd
, INT offset
)
945 case GWLP_HWNDPARENT
:
946 WARN( "Invalid offset %d\n", offset
);
947 SetLastError( ERROR_INVALID_INDEX
);
951 if (sizeof(void *) == sizeof(LONG
))
953 LONG_PTR ret
= NtUserGetWindowLongW( hwnd
, offset
);
954 return get_window_long_ptr( hwnd
, offset
, ret
, FALSE
);
956 return NtUserGetWindowLongW( hwnd
, offset
);
961 /**********************************************************************
962 * SetWindowLongA (USER32.@)
964 * See SetWindowLongW.
966 LONG WINAPI DECLSPEC_HOTPATCH
SetWindowLongA( HWND hwnd
, INT offset
, LONG newval
)
973 case GWLP_HWNDPARENT
:
974 WARN( "Invalid offset %d\n", offset
);
975 SetLastError( ERROR_INVALID_INDEX
);
979 if (NtUserGetDialogInfo( hwnd
)) return set_dialog_proc( hwnd
, newval
, TRUE
);
983 return NtUserSetWindowLong( hwnd
, offset
, newval
, TRUE
);
988 /**********************************************************************
989 * SetWindowLongW (USER32.@) Set window attribute
991 * SetWindowLong() alters one of a window's attributes or sets a 32-bit (long)
992 * value in a window's extra memory.
994 * The _hwnd_ parameter specifies the handle to a window that
995 * has extra memory. The _newval_ parameter contains the new
996 * attribute or extra memory value. If positive, the _offset_
997 * parameter is the byte-addressed location in the window's extra
998 * memory to set. If negative, _offset_ specifies the window
999 * attribute to set, and should be one of the following values:
1001 * GWL_EXSTYLE The window's extended window style
1003 * GWL_STYLE The window's window style.
1005 * GWLP_WNDPROC Pointer to the window's window procedure.
1007 * GWLP_HINSTANCE The window's application instance handle.
1009 * GWLP_ID The window's identifier.
1011 * GWLP_USERDATA The window's user-specified data.
1013 * If the window is a dialog box, the _offset_ parameter can be one of
1014 * the following values:
1016 * DWLP_DLGPROC The address of the window's dialog box procedure.
1018 * DWLP_MSGRESULT The return value of a message
1019 * that the dialog box procedure processed.
1021 * DWLP_USER Application specific information.
1025 * If successful, returns the previous value located at _offset_. Otherwise,
1030 * Extra memory for a window class is specified by a nonzero cbWndExtra
1031 * parameter of the WNDCLASS structure passed to RegisterClass() at the
1032 * time of class creation.
1034 * Using GWL_WNDPROC to set a new window procedure effectively creates
1035 * a window subclass. Use CallWindowProc() in the new windows procedure
1036 * to pass messages to the superclass's window procedure.
1038 * The user data is reserved for use by the application which created
1041 * Do not use GWL_STYLE to change the window's WS_DISABLED style;
1042 * instead, call the EnableWindow() function to change the window's
1045 * Do not use GWL_HWNDPARENT to reset the window's parent, use
1046 * SetParent() instead.
1049 * When offset is GWL_STYLE and the calling app's ver is 4.0,
1050 * it sends WM_STYLECHANGING before changing the settings
1051 * and WM_STYLECHANGED afterwards.
1052 * App ver 4.0 can't use SetWindowLong to change WS_EX_TOPMOST.
1054 LONG WINAPI DECLSPEC_HOTPATCH
SetWindowLongW(
1055 HWND hwnd
, /* [in] window to alter */
1056 INT offset
, /* [in] offset, in bytes, of location to alter */
1057 LONG newval
/* [in] new value of location */
1064 case GWLP_HINSTANCE
:
1065 case GWLP_HWNDPARENT
:
1066 WARN("Invalid offset %d\n", offset
);
1067 SetLastError( ERROR_INVALID_INDEX
);
1071 if (NtUserGetDialogInfo( hwnd
)) return set_dialog_proc( hwnd
, newval
, FALSE
);
1075 return NtUserSetWindowLong( hwnd
, offset
, newval
, FALSE
);
1080 /*******************************************************************
1081 * GetWindowTextA (USER32.@)
1083 INT WINAPI
GetWindowTextA( HWND hwnd
, LPSTR lpString
, INT nMaxCount
)
1088 if (!lpString
|| nMaxCount
<= 0) return 0;
1094 if (WIN_IsCurrentProcess( hwnd
))
1096 ret
= (INT
)SendMessageA( hwnd
, WM_GETTEXT
, nMaxCount
, (LPARAM
)lpString
);
1098 else if ((buffer
= HeapAlloc( GetProcessHeap(), 0, nMaxCount
* sizeof(WCHAR
) )))
1100 /* when window belongs to other process, don't send a message */
1101 NtUserInternalGetWindowText( hwnd
, buffer
, nMaxCount
);
1102 if (!WideCharToMultiByte( CP_ACP
, 0, buffer
, -1, lpString
, nMaxCount
, NULL
, NULL
))
1103 lpString
[nMaxCount
-1] = 0;
1104 HeapFree( GetProcessHeap(), 0, buffer
);
1105 ret
= strlen(lpString
);
1118 /*******************************************************************
1119 * GetWindowTextW (USER32.@)
1121 INT WINAPI
GetWindowTextW( HWND hwnd
, LPWSTR lpString
, INT nMaxCount
)
1125 if (!lpString
|| nMaxCount
<= 0) return 0;
1131 if (WIN_IsCurrentProcess( hwnd
))
1133 ret
= (INT
)SendMessageW( hwnd
, WM_GETTEXT
, nMaxCount
, (LPARAM
)lpString
);
1137 /* when window belongs to other process, don't send a message */
1138 ret
= NtUserInternalGetWindowText( hwnd
, lpString
, nMaxCount
);
1151 /*******************************************************************
1152 * SetWindowTextA (USER32.@)
1153 * SetWindowText (USER32.@)
1155 BOOL WINAPI DECLSPEC_HOTPATCH
SetWindowTextA( HWND hwnd
, LPCSTR lpString
)
1157 if (is_broadcast(hwnd
))
1159 SetLastError( ERROR_INVALID_PARAMETER
);
1162 if (!WIN_IsCurrentProcess( hwnd
))
1163 WARN( "setting text %s of other process window %p should not use SendMessage\n",
1164 debugstr_a(lpString
), hwnd
);
1165 return (BOOL
)SendMessageA( hwnd
, WM_SETTEXT
, 0, (LPARAM
)lpString
);
1169 /*******************************************************************
1170 * SetWindowTextW (USER32.@)
1172 BOOL WINAPI DECLSPEC_HOTPATCH
SetWindowTextW( HWND hwnd
, LPCWSTR lpString
)
1174 if (is_broadcast(hwnd
))
1176 SetLastError( ERROR_INVALID_PARAMETER
);
1179 if (!WIN_IsCurrentProcess( hwnd
))
1180 WARN( "setting text %s of other process window %p should not use SendMessage\n",
1181 debugstr_w(lpString
), hwnd
);
1182 return (BOOL
)SendMessageW( hwnd
, WM_SETTEXT
, 0, (LPARAM
)lpString
);
1186 /*******************************************************************
1187 * GetWindowTextLengthA (USER32.@)
1189 INT WINAPI
GetWindowTextLengthA( HWND hwnd
)
1193 if (WIN_IsCurrentProcess( hwnd
)) return SendMessageA( hwnd
, WM_GETTEXTLENGTH
, 0, 0 );
1195 /* when window belongs to other process, don't send a message */
1196 GetCPInfo( CP_ACP
, &info
);
1197 return NtUserGetWindowTextLength( hwnd
) * info
.MaxCharSize
;
1200 /*******************************************************************
1201 * GetWindowTextLengthW (USER32.@)
1203 INT WINAPI
GetWindowTextLengthW( HWND hwnd
)
1205 if (WIN_IsCurrentProcess( hwnd
)) return SendMessageW( hwnd
, WM_GETTEXTLENGTH
, 0, 0 );
1207 /* when window belongs to other process, don't send a message */
1208 return NtUserGetWindowTextLength( hwnd
);
1212 /*******************************************************************
1213 * IsWindow (USER32.@)
1215 BOOL WINAPI
IsWindow( HWND hwnd
)
1217 return NtUserIsWindow( hwnd
);
1221 /***********************************************************************
1222 * GetWindowThreadProcessId (USER32.@)
1224 DWORD WINAPI
GetWindowThreadProcessId( HWND hwnd
, LPDWORD process
)
1226 return NtUserGetWindowThread( hwnd
, process
);
1230 /*****************************************************************
1231 * GetParent (USER32.@)
1233 HWND WINAPI
GetParent( HWND hwnd
)
1235 return NtUserGetParent( hwnd
);
1239 /*******************************************************************
1240 * IsChild (USER32.@)
1242 BOOL WINAPI
IsChild( HWND parent
, HWND child
)
1244 return NtUserIsChild( parent
, child
);
1248 /***********************************************************************
1249 * IsWindowVisible (USER32.@)
1251 BOOL WINAPI
IsWindowVisible( HWND hwnd
)
1253 return NtUserIsWindowVisible( hwnd
);
1257 /*******************************************************************
1258 * GetTopWindow (USER32.@)
1260 HWND WINAPI
GetTopWindow( HWND hwnd
)
1262 if (!hwnd
) hwnd
= GetDesktopWindow();
1263 return GetWindow( hwnd
, GW_CHILD
);
1267 /*******************************************************************
1268 * GetWindow (USER32.@)
1270 HWND WINAPI
GetWindow( HWND hwnd
, UINT rel
)
1272 return NtUserGetWindowRelative( hwnd
, rel
);
1276 /*******************************************************************
1277 * ShowOwnedPopups (USER32.@)
1279 BOOL WINAPI
ShowOwnedPopups( HWND owner
, BOOL show
)
1281 return NtUserShowOwnedPopups( owner
, show
);
1285 /*******************************************************************
1286 * GetLastActivePopup (USER32.@)
1288 HWND WINAPI
GetLastActivePopup( HWND hwnd
)
1292 SERVER_START_REQ( get_window_info
)
1294 req
->handle
= wine_server_user_handle( hwnd
);
1295 if (!wine_server_call_err( req
)) retval
= wine_server_ptr_handle( reply
->last_active
);
1302 /*******************************************************************
1305 * Build an array of the children of a given window. The array must be
1306 * freed with HeapFree. Returns NULL when no windows are found.
1308 HWND
*WIN_ListChildren( HWND hwnd
)
1312 SetLastError( ERROR_INVALID_WINDOW_HANDLE
);
1315 return list_window_children( 0, hwnd
, NULL
, 0 );
1319 /*******************************************************************
1320 * EnumWindows (USER32.@)
1322 BOOL WINAPI
EnumWindows( WNDENUMPROC lpEnumFunc
, LPARAM lParam
)
1328 /* We have to build a list of all windows first, to avoid */
1329 /* unpleasant side-effects, for instance if the callback */
1330 /* function changes the Z-order of the windows. */
1332 if (!(list
= WIN_ListChildren( GetDesktopWindow() ))) return TRUE
;
1334 /* Now call the callback function for every window */
1336 for (i
= 0; list
[i
]; i
++)
1338 /* Make sure that the window still exists */
1339 if (!IsWindow( list
[i
] )) continue;
1340 if (!(ret
= lpEnumFunc( list
[i
], lParam
))) break;
1342 HeapFree( GetProcessHeap(), 0, list
);
1347 /**********************************************************************
1348 * EnumThreadWindows (USER32.@)
1350 BOOL WINAPI
EnumThreadWindows( DWORD id
, WNDENUMPROC func
, LPARAM lParam
)
1356 if (!(list
= list_window_children( 0, GetDesktopWindow(), NULL
, id
))) return TRUE
;
1358 /* Now call the callback function for every window */
1360 for (i
= 0; list
[i
]; i
++)
1361 if (!(ret
= func( list
[i
], lParam
))) break;
1362 HeapFree( GetProcessHeap(), 0, list
);
1367 /***********************************************************************
1368 * EnumDesktopWindows (USER32.@)
1370 BOOL WINAPI
EnumDesktopWindows( HDESK desktop
, WNDENUMPROC func
, LPARAM lparam
)
1375 if (!(list
= list_window_children( desktop
, 0, NULL
, 0 ))) return TRUE
;
1377 for (i
= 0; list
[i
]; i
++)
1378 if (!func( list
[i
], lparam
)) break;
1379 HeapFree( GetProcessHeap(), 0, list
);
1385 /* Some apps pass a non-stdcall proc to EnumChildWindows,
1386 * so we need a small assembly wrapper to call the proc.
1388 extern LRESULT
enum_callback_wrapper( WNDENUMPROC proc
, HWND hwnd
, LPARAM lparam
);
1389 __ASM_GLOBAL_FUNC( enum_callback_wrapper
,
1391 __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
1392 __ASM_CFI(".cfi_rel_offset %ebp,0\n\t")
1393 "movl %esp,%ebp\n\t"
1394 __ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
1395 "pushl 16(%ebp)\n\t"
1396 "pushl 12(%ebp)\n\t"
1399 __ASM_CFI(".cfi_def_cfa %esp,4\n\t")
1400 __ASM_CFI(".cfi_same_value %ebp\n\t")
1403 static inline LRESULT
enum_callback_wrapper( WNDENUMPROC proc
, HWND hwnd
, LPARAM lparam
)
1405 return proc( hwnd
, lparam
);
1407 #endif /* __i386__ */
1409 /**********************************************************************
1410 * WIN_EnumChildWindows
1412 * Helper function for EnumChildWindows().
1414 static BOOL
WIN_EnumChildWindows( HWND
*list
, WNDENUMPROC func
, LPARAM lParam
)
1419 for ( ; *list
; list
++)
1421 /* Make sure that the window still exists */
1422 if (!IsWindow( *list
)) continue;
1423 /* Build children list first */
1424 childList
= WIN_ListChildren( *list
);
1426 ret
= enum_callback_wrapper( func
, *list
, lParam
);
1430 if (ret
) ret
= WIN_EnumChildWindows( childList
, func
, lParam
);
1431 HeapFree( GetProcessHeap(), 0, childList
);
1433 if (!ret
) return FALSE
;
1439 /**********************************************************************
1440 * EnumChildWindows (USER32.@)
1442 BOOL WINAPI
EnumChildWindows( HWND parent
, WNDENUMPROC func
, LPARAM lParam
)
1447 if (!(list
= WIN_ListChildren( parent
))) return FALSE
;
1448 ret
= WIN_EnumChildWindows( list
, func
, lParam
);
1449 HeapFree( GetProcessHeap(), 0, list
);
1454 /*******************************************************************
1455 * AnyPopup (USER32.@)
1457 BOOL WINAPI
AnyPopup(void)
1461 HWND
*list
= WIN_ListChildren( GetDesktopWindow() );
1463 if (!list
) return FALSE
;
1464 for (i
= 0; list
[i
]; i
++)
1466 if (IsWindowVisible( list
[i
] ) && GetWindow( list
[i
], GW_OWNER
)) break;
1468 retvalue
= (list
[i
] != 0);
1469 HeapFree( GetProcessHeap(), 0, list
);
1474 /*******************************************************************
1475 * FlashWindow (USER32.@)
1477 BOOL WINAPI
FlashWindow( HWND hWnd
, BOOL bInvert
)
1481 finfo
.cbSize
= sizeof(FLASHWINFO
);
1482 finfo
.dwFlags
= bInvert
? FLASHW_ALL
: FLASHW_STOP
;
1484 finfo
.dwTimeout
= 0;
1486 return NtUserFlashWindowEx( &finfo
);
1490 /*******************************************************************
1491 * GetWindowContextHelpId (USER32.@)
1493 DWORD WINAPI
GetWindowContextHelpId( HWND hwnd
)
1495 return NtUserGetWindowContextHelpId( hwnd
);
1499 /*******************************************************************
1500 * SetWindowContextHelpId (USER32.@)
1502 BOOL WINAPI
SetWindowContextHelpId( HWND hwnd
, DWORD id
)
1504 return NtUserSetWindowContextHelpId( hwnd
, id
);
1508 /*******************************************************************
1509 * DragDetect (USER32.@)
1511 BOOL WINAPI
DragDetect( HWND hwnd
, POINT pt
)
1513 return NtUserDragDetect( hwnd
, pt
.x
, pt
.y
);
1516 /******************************************************************************
1517 * GetWindowModuleFileNameA (USER32.@)
1519 UINT WINAPI
GetWindowModuleFileNameA( HWND hwnd
, LPSTR module
, UINT size
)
1523 TRACE( "%p, %p, %u\n", hwnd
, module
, size
);
1525 if (!WIN_IsCurrentProcess( hwnd
))
1527 SetLastError( ERROR_INVALID_WINDOW_HANDLE
);
1531 hinst
= (HINSTANCE
)GetWindowLongPtrA( hwnd
, GWLP_HINSTANCE
);
1532 return GetModuleFileNameA( hinst
, module
, size
);
1535 /******************************************************************************
1536 * GetWindowModuleFileNameW (USER32.@)
1538 UINT WINAPI
GetWindowModuleFileNameW( HWND hwnd
, LPWSTR module
, UINT size
)
1542 TRACE( "%p, %p, %u\n", hwnd
, module
, size
);
1544 if (!WIN_IsCurrentProcess( hwnd
))
1546 SetLastError( ERROR_INVALID_WINDOW_HANDLE
);
1550 hinst
= (HINSTANCE
)GetWindowLongPtrW( hwnd
, GWLP_HINSTANCE
);
1551 return GetModuleFileNameW( hinst
, module
, size
);
1554 /******************************************************************************
1555 * GetWindowInfo (USER32.@)
1557 * Note: tests show that Windows doesn't check cbSize of the structure.
1559 BOOL WINAPI DECLSPEC_HOTPATCH
GetWindowInfo( HWND hwnd
, WINDOWINFO
*info
)
1561 return NtUserGetWindowInfo( hwnd
, info
);
1564 /******************************************************************************
1565 * SwitchDesktop (USER32.@)
1567 * NOTES: Sets the current input or interactive desktop.
1569 BOOL WINAPI
SwitchDesktop( HDESK hDesktop
)
1571 FIXME("(hwnd %p) stub!\n", hDesktop
);
1576 /*****************************************************************************
1577 * UpdateLayeredWindowIndirect (USER32.@)
1579 BOOL WINAPI
UpdateLayeredWindowIndirect( HWND hwnd
, const UPDATELAYEREDWINDOWINFO
*info
)
1581 if (!info
|| info
->cbSize
!= sizeof(*info
))
1583 SetLastError( ERROR_INVALID_PARAMETER
);
1587 return NtUserUpdateLayeredWindow( hwnd
, info
->hdcDst
, info
->pptDst
, info
->psize
,
1588 info
->hdcSrc
, info
->pptSrc
, info
->crKey
,
1589 info
->pblend
, info
->dwFlags
, info
->prcDirty
);
1593 /*****************************************************************************
1594 * UpdateLayeredWindow (USER32.@)
1596 BOOL WINAPI
UpdateLayeredWindow( HWND hwnd
, HDC hdcDst
, POINT
*pptDst
, SIZE
*psize
,
1597 HDC hdcSrc
, POINT
*pptSrc
, COLORREF crKey
, BLENDFUNCTION
*pblend
,
1600 UPDATELAYEREDWINDOWINFO info
;
1602 if (flags
& ULW_EX_NORESIZE
) /* only valid for UpdateLayeredWindowIndirect */
1604 SetLastError( ERROR_INVALID_PARAMETER
);
1607 info
.cbSize
= sizeof(info
);
1608 info
.hdcDst
= hdcDst
;
1609 info
.pptDst
= pptDst
;
1611 info
.hdcSrc
= hdcSrc
;
1612 info
.pptSrc
= pptSrc
;
1614 info
.pblend
= pblend
;
1615 info
.dwFlags
= flags
;
1616 info
.prcDirty
= NULL
;
1617 return UpdateLayeredWindowIndirect( hwnd
, &info
);
1621 /******************************************************************************
1622 * GetProcessDefaultLayout [USER32.@]
1624 * Gets the default layout for parentless windows.
1626 BOOL WINAPI
GetProcessDefaultLayout( DWORD
*layout
)
1630 SetLastError( ERROR_NOACCESS
);
1633 *layout
= NtUserGetProcessDefaultLayout();
1636 WCHAR
*str
, buffer
[MAX_PATH
];
1637 DWORD i
, version_layout
= 0;
1639 DWORD user_lang
= GetUserDefaultLangID();
1643 GetModuleFileNameW( 0, buffer
, MAX_PATH
);
1644 if (!(len
= GetFileVersionInfoSizeW( buffer
, NULL
))) goto done
;
1645 if (!(data
= HeapAlloc( GetProcessHeap(), 0, len
))) goto done
;
1646 if (!GetFileVersionInfoW( buffer
, 0, len
, data
)) goto done
;
1647 if (!VerQueryValueW( data
, L
"\\VarFileInfo\\Translation", (void **)&languages
, &len
) || !len
) goto done
;
1649 len
/= sizeof(DWORD
);
1650 for (i
= 0; i
< len
; i
++) if (LOWORD(languages
[i
]) == user_lang
) break;
1651 if (i
== len
) /* try neutral language */
1652 for (i
= 0; i
< len
; i
++)
1653 if (LOWORD(languages
[i
]) == MAKELANGID( PRIMARYLANGID(user_lang
), SUBLANG_NEUTRAL
)) break;
1654 if (i
== len
) i
= 0; /* default to the first one */
1656 swprintf( buffer
, ARRAY_SIZE(buffer
), L
"\\StringFileInfo\\%04x%04x\\FileDescription",
1657 LOWORD(languages
[i
]), HIWORD(languages
[i
]) );
1658 if (!VerQueryValueW( data
, buffer
, (void **)&str
, &len
)) goto done
;
1659 TRACE( "found description %s\n", debugstr_w( str
));
1660 if (str
[0] == 0x200e && str
[1] == 0x200e) version_layout
= LAYOUT_RTL
;
1663 HeapFree( GetProcessHeap(), 0, data
);
1664 NtUserSetProcessDefaultLayout( *layout
= version_layout
);
1670 /******************************************************************************
1671 * SetProcessDefaultLayout [USER32.@]
1673 * Sets the default layout for parentless windows.
1675 BOOL WINAPI
SetProcessDefaultLayout( DWORD layout
)
1677 return NtUserSetProcessDefaultLayout( layout
);
1681 /***********************************************************************
1682 * UpdateWindow (USER32.@)
1684 BOOL WINAPI
UpdateWindow( HWND hwnd
)
1688 SetLastError( ERROR_INVALID_WINDOW_HANDLE
);
1692 return NtUserRedrawWindow( hwnd
, NULL
, 0, RDW_UPDATENOW
| RDW_ALLCHILDREN
);
1696 /***********************************************************************
1697 * ValidateRgn (USER32.@)
1699 BOOL WINAPI
ValidateRgn( HWND hwnd
, HRGN hrgn
)
1703 SetLastError( ERROR_INVALID_WINDOW_HANDLE
);
1707 return NtUserRedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
);
1711 /*************************************************************************
1712 * ScrollWindow (USER32.@)
1714 BOOL WINAPI
ScrollWindow( HWND hwnd
, INT dx
, INT dy
, const RECT
*rect
, const RECT
*clip_rect
)
1716 UINT flags
= SW_INVALIDATE
| SW_ERASE
| (rect
? 0 : SW_SCROLLCHILDREN
) | SW_NODCCACHE
;
1717 return NtUserScrollWindowEx( hwnd
, dx
, dy
, rect
, clip_rect
, 0, NULL
, flags
);
1722 /* 64bit versions */
1724 #undef GetWindowLongPtrW
1725 #undef GetWindowLongPtrA
1726 #undef SetWindowLongPtrW
1727 #undef SetWindowLongPtrA
1729 /*****************************************************************************
1730 * GetWindowLongPtrW (USER32.@)
1732 LONG_PTR WINAPI
GetWindowLongPtrW( HWND hwnd
, INT offset
)
1734 LONG_PTR ret
= NtUserGetWindowLongPtrW( hwnd
, offset
);
1735 return get_window_long_ptr( hwnd
, offset
, ret
, FALSE
);
1738 /*****************************************************************************
1739 * GetWindowLongPtrA (USER32.@)
1741 LONG_PTR WINAPI
GetWindowLongPtrA( HWND hwnd
, INT offset
)
1743 LONG_PTR ret
= NtUserGetWindowLongPtrA( hwnd
, offset
);
1744 return get_window_long_ptr( hwnd
, offset
, ret
, TRUE
);
1747 /*****************************************************************************
1748 * SetWindowLongPtrW (USER32.@)
1750 LONG_PTR WINAPI
SetWindowLongPtrW( HWND hwnd
, INT offset
, LONG_PTR newval
)
1752 if (offset
== DWLP_DLGPROC
&& NtUserGetDialogInfo( hwnd
))
1753 return set_dialog_proc( hwnd
, newval
, FALSE
);
1755 return NtUserSetWindowLongPtr( hwnd
, offset
, newval
, FALSE
);
1758 /*****************************************************************************
1759 * SetWindowLongPtrA (USER32.@)
1761 LONG_PTR WINAPI
SetWindowLongPtrA( HWND hwnd
, INT offset
, LONG_PTR newval
)
1763 if (offset
== DWLP_DLGPROC
&& NtUserGetDialogInfo( hwnd
))
1764 return set_dialog_proc( hwnd
, newval
, TRUE
);
1766 return NtUserSetWindowLongPtr( hwnd
, offset
, newval
, TRUE
);
1771 /*****************************************************************************
1772 * GetWindowDisplayAffinity (USER32.@)
1774 BOOL WINAPI
GetWindowDisplayAffinity(HWND hwnd
, DWORD
*affinity
)
1776 FIXME("(%p, %p): stub\n", hwnd
, affinity
);
1778 if (!hwnd
|| !affinity
)
1780 SetLastError(hwnd
? ERROR_NOACCESS
: ERROR_INVALID_WINDOW_HANDLE
);
1784 *affinity
= WDA_NONE
;
1788 /*****************************************************************************
1789 * SetWindowDisplayAffinity (USER32.@)
1791 BOOL WINAPI
SetWindowDisplayAffinity(HWND hwnd
, DWORD affinity
)
1793 FIXME("(%p, %lu): stub\n", hwnd
, affinity
);
1797 SetLastError(ERROR_INVALID_WINDOW_HANDLE
);
1801 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1805 /**********************************************************************
1806 * SetWindowCompositionAttribute (USER32.@)
1808 BOOL WINAPI
SetWindowCompositionAttribute(HWND hwnd
, void *data
)
1810 FIXME("(%p, %p): stub\n", hwnd
, data
);
1811 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);