ntdll: Add ARM64 cpu info.
[wine] / dlls / user.exe16 / window.c
1 /*
2  * 16-bit windowing functions
3  *
4  * Copyright 2001 Alexandre Julliard
5  *
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.
10  *
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.
15  *
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
19  */
20
21 #include "wine/winuser16.h"
22 #include "wownt32.h"
23 #include "user_private.h"
24 #include "wine/list.h"
25 #include "wine/server.h"
26 #include "wine/debug.h"
27
28 WINE_DEFAULT_DEBUG_CHANNEL(win);
29
30 /* size of buffer needed to store an atom string */
31 #define ATOM_BUFFER_SIZE 256
32
33 /* handle <--> handle16 conversions */
34 #define HANDLE_16(h32)          (LOWORD(h32))
35 #define HANDLE_32(h16)          ((HANDLE)(ULONG_PTR)(h16))
36
37 static HWND16 hwndSysModal;
38
39 struct class_entry
40 {
41     struct list entry;
42     ATOM        atom;
43     HINSTANCE16 inst;
44 };
45
46 static struct list class_list = LIST_INIT( class_list );
47
48 struct wnd_enum_info
49 {
50     WNDENUMPROC16 proc;
51     LPARAM        param;
52 };
53
54 /* callback for 16-bit window enumeration functions */
55 static BOOL CALLBACK wnd_enum_callback( HWND hwnd, LPARAM param )
56 {
57     const struct wnd_enum_info *info = (struct wnd_enum_info *)param;
58     WORD args[3];
59     DWORD ret;
60
61     args[2] = HWND_16(hwnd);
62     args[1] = HIWORD(info->param);
63     args[0] = LOWORD(info->param);
64     WOWCallback16Ex( (DWORD)info->proc, WCB16_PASCAL, sizeof(args), args, &ret );
65     return LOWORD(ret);
66 }
67
68 /* convert insert after window handle to 32-bit */
69 static inline HWND full_insert_after_hwnd( HWND16 hwnd )
70 {
71     HWND ret = WIN_Handle32( hwnd );
72     if (ret == (HWND)0xffff) ret = HWND_TOPMOST;
73     return ret;
74 }
75
76 void free_module_classes( HINSTANCE16 inst )
77 {
78     struct class_entry *class, *next;
79
80     LIST_FOR_EACH_ENTRY_SAFE( class, next, &class_list, struct class_entry, entry )
81     {
82         if (class->inst != inst) continue;
83         list_remove( &class->entry );
84         UnregisterClassA( (LPCSTR)MAKEINTATOM(class->atom), HINSTANCE_32(class->inst) );
85         HeapFree( GetProcessHeap(), 0, class );
86     }
87 }
88
89 /**************************************************************************
90  *              MessageBox   (USER.1)
91  */
92 INT16 WINAPI MessageBox16( HWND16 hwnd, LPCSTR text, LPCSTR title, UINT16 type )
93 {
94     return MessageBoxA( WIN_Handle32(hwnd), text, title, type );
95 }
96
97
98 /***********************************************************************
99  *              SetTimer (USER.10)
100  */
101 UINT16 WINAPI SetTimer16( HWND16 hwnd, UINT16 id, UINT16 timeout, TIMERPROC16 proc )
102 {
103     TIMERPROC proc32 = (TIMERPROC)WINPROC_AllocProc16( (WNDPROC16)proc );
104     return SetTimer( WIN_Handle32(hwnd), id, timeout, proc32 );
105 }
106
107
108 /***********************************************************************
109  *              SetSystemTimer (USER.11)
110  */
111 UINT16 WINAPI SetSystemTimer16( HWND16 hwnd, UINT16 id, UINT16 timeout, TIMERPROC16 proc )
112 {
113     TIMERPROC proc32 = (TIMERPROC)WINPROC_AllocProc16( (WNDPROC16)proc );
114     return SetSystemTimer( WIN_Handle32(hwnd), id, timeout, proc32 );
115 }
116
117
118 /**************************************************************************
119  *              KillTimer   (USER.12)
120  */
121 BOOL16 WINAPI KillTimer16( HWND16 hwnd, UINT16 id )
122 {
123     return KillTimer( WIN_Handle32(hwnd), id );
124 }
125
126
127 /**************************************************************************
128  *              SetCapture   (USER.18)
129  */
130 HWND16 WINAPI SetCapture16( HWND16 hwnd )
131 {
132     return HWND_16( SetCapture( WIN_Handle32(hwnd) ));
133 }
134
135
136 /**************************************************************************
137  *              ReleaseCapture   (USER.19)
138  */
139 BOOL16 WINAPI ReleaseCapture16(void)
140 {
141     return ReleaseCapture();
142 }
143
144
145 /**************************************************************************
146  *              SetFocus   (USER.22)
147  */
148 HWND16 WINAPI SetFocus16( HWND16 hwnd )
149 {
150     return HWND_16( SetFocus( WIN_Handle32(hwnd) ));
151 }
152
153
154 /**************************************************************************
155  *              GetFocus   (USER.23)
156  */
157 HWND16 WINAPI GetFocus16(void)
158 {
159     return HWND_16( GetFocus() );
160 }
161
162
163 /**************************************************************************
164  *              RemoveProp   (USER.24)
165  */
166 HANDLE16 WINAPI RemoveProp16( HWND16 hwnd, LPCSTR str )
167 {
168     return HANDLE_16(RemovePropA( WIN_Handle32(hwnd), str ));
169 }
170
171
172 /**************************************************************************
173  *              GetProp   (USER.25)
174  */
175 HANDLE16 WINAPI GetProp16( HWND16 hwnd, LPCSTR str )
176 {
177     return HANDLE_16(GetPropA( WIN_Handle32(hwnd), str ));
178 }
179
180
181 /**************************************************************************
182  *              SetProp   (USER.26)
183  */
184 BOOL16 WINAPI SetProp16( HWND16 hwnd, LPCSTR str, HANDLE16 handle )
185 {
186     return SetPropA( WIN_Handle32(hwnd), str, HANDLE_32(handle) );
187 }
188
189
190 /***********************************************************************
191  *              EnumProps   (USER.27)
192  */
193 INT16 WINAPI EnumProps16( HWND16 hwnd, PROPENUMPROC16 func )
194 {
195     int ret = -1, i, count, total = 32;
196     property_data_t *list;
197
198     while (total)
199     {
200         if (!(list = HeapAlloc( GetProcessHeap(), 0, total * sizeof(*list) ))) break;
201         count = 0;
202         SERVER_START_REQ( get_window_properties )
203         {
204             req->window = wine_server_user_handle( HWND_32(hwnd) );
205             wine_server_set_reply( req, list, total * sizeof(*list) );
206             if (!wine_server_call( req )) count = reply->total;
207         }
208         SERVER_END_REQ;
209
210         if (count && count <= total)
211         {
212             char string[ATOM_BUFFER_SIZE];
213             SEGPTR segptr = MapLS( string );
214             WORD args[4];
215             DWORD result;
216
217             for (i = 0; i < count; i++)
218             {
219                 if (list[i].string)  /* it was a string originally */
220                 {
221                     if (!GlobalGetAtomNameA( list[i].atom, string, ATOM_BUFFER_SIZE )) continue;
222                     args[3] = hwnd;
223                     args[2] = SELECTOROF(segptr);
224                     args[1] = OFFSETOF(segptr);
225                     args[0] = LOWORD(list[i].data);
226                 }
227                 else
228                 {
229                     args[3] = hwnd;
230                     args[2] = 0;
231                     args[1] = list[i].atom;
232                     args[0] = LOWORD(list[i].data);
233                 }
234                 WOWCallback16Ex( (DWORD)func, WCB16_PASCAL, sizeof(args), args, &result );
235                 if (!(ret = LOWORD(result))) break;
236             }
237             UnMapLS( segptr );
238             HeapFree( GetProcessHeap(), 0, list );
239             break;
240         }
241         HeapFree( GetProcessHeap(), 0, list );
242         total = count;  /* restart with larger buffer */
243     }
244     return ret;
245 }
246
247
248 /**************************************************************************
249  *              ClientToScreen   (USER.28)
250  */
251 void WINAPI ClientToScreen16( HWND16 hwnd, LPPOINT16 lppnt )
252 {
253     MapWindowPoints16( hwnd, 0, lppnt, 1 );
254 }
255
256
257 /**************************************************************************
258  *              ScreenToClient   (USER.29)
259  */
260 void WINAPI ScreenToClient16( HWND16 hwnd, LPPOINT16 lppnt )
261 {
262     MapWindowPoints16( 0, hwnd, lppnt, 1 );
263 }
264
265
266 /**************************************************************************
267  *              WindowFromPoint   (USER.30)
268  */
269 HWND16 WINAPI WindowFromPoint16( POINT16 pt )
270 {
271     POINT pt32;
272
273     pt32.x = pt.x;
274     pt32.y = pt.y;
275     return HWND_16( WindowFromPoint( pt32 ) );
276 }
277
278
279 /**************************************************************************
280  *              IsIconic   (USER.31)
281  */
282 BOOL16 WINAPI IsIconic16(HWND16 hwnd)
283 {
284     return IsIconic( WIN_Handle32(hwnd) );
285 }
286
287
288 /**************************************************************************
289  *              GetWindowRect   (USER.32)
290  */
291 void WINAPI GetWindowRect16( HWND16 hwnd, LPRECT16 rect )
292 {
293     RECT rect32;
294
295     GetWindowRect( WIN_Handle32(hwnd), &rect32 );
296     rect->left   = rect32.left;
297     rect->top    = rect32.top;
298     rect->right  = rect32.right;
299     rect->bottom = rect32.bottom;
300 }
301
302
303 /**************************************************************************
304  *              GetClientRect   (USER.33)
305  */
306 void WINAPI GetClientRect16( HWND16 hwnd, LPRECT16 rect )
307 {
308     RECT rect32;
309
310     GetClientRect( WIN_Handle32(hwnd), &rect32 );
311     rect->left   = rect32.left;
312     rect->top    = rect32.top;
313     rect->right  = rect32.right;
314     rect->bottom = rect32.bottom;
315 }
316
317
318 /**************************************************************************
319  *              EnableWindow   (USER.34)
320  */
321 BOOL16 WINAPI EnableWindow16( HWND16 hwnd, BOOL16 enable )
322 {
323     return EnableWindow( WIN_Handle32(hwnd), enable );
324 }
325
326
327 /**************************************************************************
328  *              IsWindowEnabled   (USER.35)
329  */
330 BOOL16 WINAPI IsWindowEnabled16(HWND16 hwnd)
331 {
332     return IsWindowEnabled( WIN_Handle32(hwnd) );
333 }
334
335
336 /**************************************************************************
337  *              GetWindowText   (USER.36)
338  */
339 INT16 WINAPI GetWindowText16( HWND16 hwnd, SEGPTR lpString, INT16 nMaxCount )
340 {
341     return SendMessage16( hwnd, WM_GETTEXT, nMaxCount, lpString );
342 }
343
344
345 /**************************************************************************
346  *              SetWindowText   (USER.37)
347  */
348 BOOL16 WINAPI SetWindowText16( HWND16 hwnd, SEGPTR lpString )
349 {
350     return SendMessage16( hwnd, WM_SETTEXT, 0, lpString );
351 }
352
353
354 /**************************************************************************
355  *              GetWindowTextLength   (USER.38)
356  */
357 INT16 WINAPI GetWindowTextLength16( HWND16 hwnd )
358 {
359     return SendMessage16( hwnd, WM_GETTEXTLENGTH, 0, 0 );
360 }
361
362
363 /***********************************************************************
364  *              BeginPaint (USER.39)
365  */
366 HDC16 WINAPI BeginPaint16( HWND16 hwnd, LPPAINTSTRUCT16 lps )
367 {
368     PAINTSTRUCT ps;
369
370     BeginPaint( WIN_Handle32(hwnd), &ps );
371     lps->hdc            = HDC_16(ps.hdc);
372     lps->fErase         = ps.fErase;
373     lps->rcPaint.top    = ps.rcPaint.top;
374     lps->rcPaint.left   = ps.rcPaint.left;
375     lps->rcPaint.right  = ps.rcPaint.right;
376     lps->rcPaint.bottom = ps.rcPaint.bottom;
377     lps->fRestore       = ps.fRestore;
378     lps->fIncUpdate     = ps.fIncUpdate;
379     return lps->hdc;
380 }
381
382
383 /***********************************************************************
384  *              EndPaint (USER.40)
385  */
386 BOOL16 WINAPI EndPaint16( HWND16 hwnd, const PAINTSTRUCT16* lps )
387 {
388     PAINTSTRUCT ps;
389
390     ps.hdc = HDC_32(lps->hdc);
391     return EndPaint( WIN_Handle32(hwnd), &ps );
392 }
393
394
395 /***********************************************************************
396  *              CreateWindow (USER.41)
397  */
398 HWND16 WINAPI CreateWindow16( LPCSTR className, LPCSTR windowName,
399                               DWORD style, INT16 x, INT16 y, INT16 width,
400                               INT16 height, HWND16 parent, HMENU16 menu,
401                               HINSTANCE16 instance, LPVOID data )
402 {
403     return CreateWindowEx16( 0, className, windowName, style,
404                              x, y, width, height, parent, menu, instance, data );
405 }
406
407
408 /**************************************************************************
409  *              ShowWindow   (USER.42)
410  */
411 BOOL16 WINAPI ShowWindow16( HWND16 hwnd, INT16 cmd )
412 {
413     return ShowWindow( WIN_Handle32(hwnd), cmd );
414 }
415
416
417 /**************************************************************************
418  *              CloseWindow   (USER.43)
419  */
420 BOOL16 WINAPI CloseWindow16( HWND16 hwnd )
421 {
422     return CloseWindow( WIN_Handle32(hwnd) );
423 }
424
425
426 /**************************************************************************
427  *              OpenIcon   (USER.44)
428  */
429 BOOL16 WINAPI OpenIcon16( HWND16 hwnd )
430 {
431     return OpenIcon( WIN_Handle32(hwnd) );
432 }
433
434
435 /**************************************************************************
436  *              BringWindowToTop   (USER.45)
437  */
438 BOOL16 WINAPI BringWindowToTop16( HWND16 hwnd )
439 {
440     return BringWindowToTop( WIN_Handle32(hwnd) );
441 }
442
443
444 /**************************************************************************
445  *              GetParent   (USER.46)
446  */
447 HWND16 WINAPI GetParent16( HWND16 hwnd )
448 {
449     return HWND_16( GetParent( WIN_Handle32(hwnd) ));
450 }
451
452
453 /**************************************************************************
454  *              IsWindow   (USER.47)
455  */
456 BOOL16 WINAPI IsWindow16( HWND16 hwnd )
457 {
458     STACK16FRAME *frame = MapSL( (SEGPTR)NtCurrentTeb()->WOW32Reserved );
459     frame->es = USER_HeapSel;
460     /* don't use WIN_Handle32 here, we don't care about the full handle */
461     return IsWindow( HWND_32(hwnd) );
462 }
463
464
465 /**************************************************************************
466  *              IsChild   (USER.48)
467  */
468 BOOL16 WINAPI IsChild16( HWND16 parent, HWND16 child )
469 {
470     return IsChild( WIN_Handle32(parent), WIN_Handle32(child) );
471 }
472
473
474 /**************************************************************************
475  *              IsWindowVisible   (USER.49)
476  */
477 BOOL16 WINAPI IsWindowVisible16( HWND16 hwnd )
478 {
479     return IsWindowVisible( WIN_Handle32(hwnd) );
480 }
481
482
483 /**************************************************************************
484  *              FindWindow   (USER.50)
485  */
486 HWND16 WINAPI FindWindow16( LPCSTR className, LPCSTR title )
487 {
488     return HWND_16( FindWindowA( className, title ));
489 }
490
491
492 /**************************************************************************
493  *              DestroyWindow   (USER.53)
494  */
495 BOOL16 WINAPI DestroyWindow16( HWND16 hwnd )
496 {
497     return DestroyWindow( WIN_Handle32(hwnd) );
498 }
499
500
501 /*******************************************************************
502  *           EnumWindows   (USER.54)
503  */
504 BOOL16 WINAPI EnumWindows16( WNDENUMPROC16 func, LPARAM lParam )
505 {
506     struct wnd_enum_info info;
507
508     info.proc  = func;
509     info.param = lParam;
510     return EnumWindows( wnd_enum_callback, (LPARAM)&info );
511 }
512
513
514 /**********************************************************************
515  *           EnumChildWindows   (USER.55)
516  */
517 BOOL16 WINAPI EnumChildWindows16( HWND16 parent, WNDENUMPROC16 func, LPARAM lParam )
518 {
519     struct wnd_enum_info info;
520
521     info.proc  = func;
522     info.param = lParam;
523     return EnumChildWindows( WIN_Handle32(parent), wnd_enum_callback, (LPARAM)&info );
524 }
525
526
527 /**************************************************************************
528  *              MoveWindow   (USER.56)
529  */
530 BOOL16 WINAPI MoveWindow16( HWND16 hwnd, INT16 x, INT16 y, INT16 cx, INT16 cy, BOOL16 repaint )
531 {
532     return MoveWindow( WIN_Handle32(hwnd), x, y, cx, cy, repaint );
533 }
534
535
536 /***********************************************************************
537  *              RegisterClass (USER.57)
538  */
539 ATOM WINAPI RegisterClass16( const WNDCLASS16 *wc )
540 {
541     WNDCLASSEX16 wcex;
542
543     wcex.cbSize        = sizeof(wcex);
544     wcex.style         = wc->style;
545     wcex.lpfnWndProc   = wc->lpfnWndProc;
546     wcex.cbClsExtra    = wc->cbClsExtra;
547     wcex.cbWndExtra    = wc->cbWndExtra;
548     wcex.hInstance     = wc->hInstance;
549     wcex.hIcon         = wc->hIcon;
550     wcex.hCursor       = wc->hCursor;
551     wcex.hbrBackground = wc->hbrBackground;
552     wcex.lpszMenuName  = wc->lpszMenuName;
553     wcex.lpszClassName = wc->lpszClassName;
554     wcex.hIconSm       = 0;
555     return RegisterClassEx16( &wcex );
556 }
557
558
559 /**************************************************************************
560  *              GetClassName   (USER.58)
561  */
562 INT16 WINAPI GetClassName16( HWND16 hwnd, LPSTR buffer, INT16 count )
563 {
564     return GetClassNameA( WIN_Handle32(hwnd), buffer, count );
565 }
566
567
568 /**************************************************************************
569  *              SetActiveWindow   (USER.59)
570  */
571 HWND16 WINAPI SetActiveWindow16( HWND16 hwnd )
572 {
573     return HWND_16( SetActiveWindow( WIN_Handle32(hwnd) ));
574 }
575
576
577 /**************************************************************************
578  *              GetActiveWindow   (USER.60)
579  */
580 HWND16 WINAPI GetActiveWindow16(void)
581 {
582     return HWND_16( GetActiveWindow() );
583 }
584
585
586 /**************************************************************************
587  *              ScrollWindow   (USER.61)
588  */
589 void WINAPI ScrollWindow16( HWND16 hwnd, INT16 dx, INT16 dy, const RECT16 *rect,
590                             const RECT16 *clipRect )
591 {
592     RECT rect32, clipRect32;
593
594     if (rect)
595     {
596         rect32.left   = rect->left;
597         rect32.top    = rect->top;
598         rect32.right  = rect->right;
599         rect32.bottom = rect->bottom;
600     }
601     if (clipRect)
602     {
603         clipRect32.left   = clipRect->left;
604         clipRect32.top    = clipRect->top;
605         clipRect32.right  = clipRect->right;
606         clipRect32.bottom = clipRect->bottom;
607     }
608     ScrollWindow( WIN_Handle32(hwnd), dx, dy, rect ? &rect32 : NULL,
609                   clipRect ? &clipRect32 : NULL );
610 }
611
612
613 /**************************************************************************
614  *              SetScrollPos   (USER.62)
615  */
616 INT16 WINAPI SetScrollPos16( HWND16 hwnd, INT16 nBar, INT16 nPos, BOOL16 redraw )
617 {
618     return SetScrollPos( WIN_Handle32(hwnd), nBar, nPos, redraw );
619 }
620
621
622 /**************************************************************************
623  *              GetScrollPos   (USER.63)
624  */
625 INT16 WINAPI GetScrollPos16( HWND16 hwnd, INT16 nBar )
626 {
627     return GetScrollPos( WIN_Handle32(hwnd), nBar );
628 }
629
630
631 /**************************************************************************
632  *              SetScrollRange   (USER.64)
633  */
634 void WINAPI SetScrollRange16( HWND16 hwnd, INT16 nBar, INT16 MinVal, INT16 MaxVal, BOOL16 redraw )
635 {
636     /* Invalid range -> range is set to (0,0) */
637     if ((INT)MaxVal - (INT)MinVal > 0x7fff) MinVal = MaxVal = 0;
638     SetScrollRange( WIN_Handle32(hwnd), nBar, MinVal, MaxVal, redraw );
639 }
640
641
642 /**************************************************************************
643  *              GetScrollRange   (USER.65)
644  */
645 BOOL16 WINAPI GetScrollRange16( HWND16 hwnd, INT16 nBar, LPINT16 lpMin, LPINT16 lpMax)
646 {
647     INT min, max;
648     BOOL ret = GetScrollRange( WIN_Handle32(hwnd), nBar, &min, &max );
649     if (lpMin) *lpMin = min;
650     if (lpMax) *lpMax = max;
651     return ret;
652 }
653
654
655 /**************************************************************************
656  *              GetDC   (USER.66)
657  */
658 HDC16 WINAPI GetDC16( HWND16 hwnd )
659 {
660     return HDC_16(GetDC( WIN_Handle32(hwnd) ));
661 }
662
663
664 /**************************************************************************
665  *              GetWindowDC   (USER.67)
666  */
667 HDC16 WINAPI GetWindowDC16( HWND16 hwnd )
668 {
669     return GetDCEx16( hwnd, 0, DCX_USESTYLE | DCX_WINDOW );
670 }
671
672
673 /**************************************************************************
674  *              ReleaseDC   (USER.68)
675  */
676 INT16 WINAPI ReleaseDC16( HWND16 hwnd, HDC16 hdc )
677 {
678     return (INT16)ReleaseDC( WIN_Handle32(hwnd), HDC_32(hdc) );
679 }
680
681
682 /**************************************************************************
683  *              FlashWindow   (USER.105)
684  */
685 BOOL16 WINAPI FlashWindow16( HWND16 hwnd, BOOL16 bInvert )
686 {
687     return FlashWindow( WIN_Handle32(hwnd), bInvert );
688 }
689
690
691 /**************************************************************************
692  *              WindowFromDC   (USER.117)
693  */
694 HWND16 WINAPI WindowFromDC16( HDC16 hDC )
695 {
696     return HWND_16( WindowFromDC( HDC_32(hDC) ) );
697 }
698
699
700 /**************************************************************************
701  *              UpdateWindow   (USER.124)
702  */
703 void WINAPI UpdateWindow16( HWND16 hwnd )
704 {
705     RedrawWindow16( hwnd, NULL, 0, RDW_UPDATENOW | RDW_ALLCHILDREN );
706 }
707
708
709 /**************************************************************************
710  *              InvalidateRect   (USER.125)
711  */
712 void WINAPI InvalidateRect16( HWND16 hwnd, const RECT16 *rect, BOOL16 erase )
713 {
714     RedrawWindow16( hwnd, rect, 0, RDW_INVALIDATE | (erase ? RDW_ERASE : 0) );
715 }
716
717
718 /**************************************************************************
719  *              InvalidateRgn   (USER.126)
720  */
721 void WINAPI InvalidateRgn16( HWND16 hwnd, HRGN16 hrgn, BOOL16 erase )
722 {
723     RedrawWindow16( hwnd, NULL, hrgn, RDW_INVALIDATE | (erase ? RDW_ERASE : 0) );
724 }
725
726
727 /**************************************************************************
728  *              ValidateRect   (USER.127)
729  */
730 void WINAPI ValidateRect16( HWND16 hwnd, const RECT16 *rect )
731 {
732     RedrawWindow16( hwnd, rect, 0, RDW_VALIDATE | RDW_NOCHILDREN );
733 }
734
735
736 /**************************************************************************
737  *              ValidateRgn   (USER.128)
738  */
739 void WINAPI ValidateRgn16( HWND16 hwnd, HRGN16 hrgn )
740 {
741     RedrawWindow16( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOCHILDREN );
742 }
743
744
745 /**************************************************************************
746  *              GetClassWord   (USER.129)
747  */
748 WORD WINAPI GetClassWord16( HWND16 hwnd, INT16 offset )
749 {
750     HICON icon;
751
752     switch (offset)
753     {
754     case GCLP_HCURSOR:
755     case GCLP_HICON:
756     case GCLP_HICONSM:
757         icon = (HICON)GetClassLongPtrW( WIN_Handle32(hwnd), offset );
758         return get_icon_16( icon );
759     }
760     return GetClassWord( WIN_Handle32(hwnd), offset );
761 }
762
763
764 /**************************************************************************
765  *              SetClassWord   (USER.130)
766  */
767 WORD WINAPI SetClassWord16( HWND16 hwnd, INT16 offset, WORD newval )
768 {
769     HICON icon;
770
771     switch (offset)
772     {
773     case GCLP_HCURSOR:
774     case GCLP_HICON:
775     case GCLP_HICONSM:
776         icon = (HICON)SetClassLongPtrW( WIN_Handle32(hwnd), offset, (ULONG_PTR)get_icon_32(newval) );
777         return get_icon_16( icon );
778     }
779     return SetClassWord( WIN_Handle32(hwnd), offset, newval );
780 }
781
782
783 /***********************************************************************
784  *              GetClassLong (USER.131)
785  */
786 LONG WINAPI GetClassLong16( HWND16 hwnd16, INT16 offset )
787 {
788     LONG_PTR ret = GetClassLongA( WIN_Handle32(hwnd16), offset );
789
790     switch( offset )
791     {
792     case GCLP_WNDPROC:
793         return (LONG_PTR)WINPROC_GetProc16( (WNDPROC)ret, FALSE );
794     case GCLP_MENUNAME:
795         return MapLS( (void *)ret );  /* leak */
796     case GCLP_HCURSOR:
797     case GCLP_HICON:
798     case GCLP_HICONSM:
799         return get_icon_16( (HICON)ret );
800     default:
801         return ret;
802     }
803 }
804
805
806 /***********************************************************************
807  *              SetClassLong (USER.132)
808  */
809 LONG WINAPI SetClassLong16( HWND16 hwnd16, INT16 offset, LONG newval )
810 {
811     HICON icon;
812
813     switch( offset )
814     {
815     case GCLP_HCURSOR:
816     case GCLP_HICON:
817     case GCLP_HICONSM:
818         icon = (HICON)SetClassLongPtrW( WIN_Handle32(hwnd16), offset, (ULONG_PTR)get_icon_32(newval) );
819         return get_icon_16( icon );
820     case GCLP_WNDPROC:
821         {
822             WNDPROC new_proc = WINPROC_AllocProc16( (WNDPROC16)newval );
823             WNDPROC old_proc = (WNDPROC)SetClassLongA( WIN_Handle32(hwnd16), offset, (LONG_PTR)new_proc );
824             return (LONG)WINPROC_GetProc16( old_proc, FALSE );
825         }
826     case GCLP_MENUNAME:
827         newval = (LONG)MapSL( newval );
828         /* fall through */
829     default:
830         return SetClassLongA( WIN_Handle32(hwnd16), offset, newval );
831     }
832 }
833
834
835 /**************************************************************************
836  *              GetWindowWord   (USER.133)
837  */
838 WORD WINAPI GetWindowWord16( HWND16 hwnd, INT16 offset )
839 {
840     return GetWindowWord( WIN_Handle32(hwnd), offset );
841 }
842
843
844 /**************************************************************************
845  *              SetWindowWord   (USER.134)
846  */
847 WORD WINAPI SetWindowWord16( HWND16 hwnd, INT16 offset, WORD newval )
848 {
849     return SetWindowWord( WIN_Handle32(hwnd), offset, newval );
850 }
851
852
853 /**********************************************************************
854  *              GetWindowLong (USER.135)
855  */
856 LONG WINAPI GetWindowLong16( HWND16 hwnd16, INT16 offset )
857 {
858     HWND hwnd = WIN_Handle32( hwnd16 );
859     LONG_PTR retvalue;
860     BOOL is_winproc = (offset == GWLP_WNDPROC);
861
862     if (offset >= 0)
863     {
864         int cbWndExtra = GetClassLongA( hwnd, GCL_CBWNDEXTRA );
865
866         if (offset > (int)(cbWndExtra - sizeof(LONG)))
867         {
868             /*
869              * Some programs try to access last element from 16 bit
870              * code using illegal offset value. Hopefully this is
871              * what those programs really expect.
872              */
873             if (cbWndExtra >= 4 && offset == cbWndExtra - sizeof(WORD))
874             {
875                 offset = cbWndExtra - sizeof(LONG);
876             }
877             else
878             {
879                 SetLastError( ERROR_INVALID_INDEX );
880                 return 0;
881             }
882         }
883         else if (offset == DWLP_DLGPROC)
884             is_winproc = (wow_handlers32.get_dialog_info( hwnd, FALSE ) != NULL);
885     }
886     retvalue = GetWindowLongA( hwnd, offset );
887     if (is_winproc) retvalue = (LONG_PTR)WINPROC_GetProc16( (WNDPROC)retvalue, FALSE );
888     return retvalue;
889 }
890
891
892 /**********************************************************************
893  *              SetWindowLong (USER.136)
894  */
895 LONG WINAPI SetWindowLong16( HWND16 hwnd16, INT16 offset, LONG newval )
896 {
897     HWND hwnd = WIN_Handle32( hwnd16 );
898     BOOL is_winproc = (offset == GWLP_WNDPROC);
899
900     if (offset == DWLP_DLGPROC)
901         is_winproc = (wow_handlers32.get_dialog_info( hwnd, FALSE ) != NULL);
902
903     if (is_winproc)
904     {
905         WNDPROC new_proc = WINPROC_AllocProc16( (WNDPROC16)newval );
906         WNDPROC old_proc = (WNDPROC)SetWindowLongPtrA( hwnd, offset, (LONG_PTR)new_proc );
907         return (LONG)WINPROC_GetProc16( old_proc, FALSE );
908     }
909     else return SetWindowLongA( hwnd, offset, newval );
910 }
911
912
913 /**************************************************************************
914  *              OpenClipboard   (USER.137)
915  */
916 BOOL16 WINAPI OpenClipboard16( HWND16 hwnd )
917 {
918     return OpenClipboard( WIN_Handle32(hwnd) );
919 }
920
921
922 /**************************************************************************
923  *              GetClipboardOwner   (USER.140)
924  */
925 HWND16 WINAPI GetClipboardOwner16(void)
926 {
927     return HWND_16( GetClipboardOwner() );
928 }
929
930
931 /**************************************************************************
932  *              SetClipboardViewer   (USER.147)
933  */
934 HWND16 WINAPI SetClipboardViewer16( HWND16 hwnd )
935 {
936     return HWND_16( SetClipboardViewer( WIN_Handle32(hwnd) ));
937 }
938
939
940 /**************************************************************************
941  *              GetClipboardViewer   (USER.148)
942  */
943 HWND16 WINAPI GetClipboardViewer16(void)
944 {
945     return HWND_16( GetClipboardViewer() );
946 }
947
948
949 /**************************************************************************
950  *              ChangeClipboardChain   (USER.149)
951  */
952 BOOL16 WINAPI ChangeClipboardChain16(HWND16 hwnd, HWND16 hwndNext)
953 {
954     return ChangeClipboardChain( WIN_Handle32(hwnd), WIN_Handle32(hwndNext) );
955 }
956
957
958 /**************************************************************************
959  *              GetSystemMenu   (USER.156)
960  */
961 HMENU16 WINAPI GetSystemMenu16( HWND16 hwnd, BOOL16 revert )
962 {
963     return HMENU_16(GetSystemMenu( WIN_Handle32(hwnd), revert ));
964 }
965
966
967 /**************************************************************************
968  *              GetMenu   (USER.157)
969  */
970 HMENU16 WINAPI GetMenu16( HWND16 hwnd )
971 {
972     return HMENU_16(GetMenu( WIN_Handle32(hwnd) ));
973 }
974
975
976 /**************************************************************************
977  *              SetMenu   (USER.158)
978  */
979 BOOL16 WINAPI SetMenu16( HWND16 hwnd, HMENU16 hMenu )
980 {
981     return SetMenu( WIN_Handle32(hwnd), HMENU_32(hMenu) );
982 }
983
984
985 /**************************************************************************
986  *              DrawMenuBar   (USER.160)
987  */
988 void WINAPI DrawMenuBar16( HWND16 hwnd )
989 {
990     DrawMenuBar( WIN_Handle32(hwnd) );
991 }
992
993
994 /**************************************************************************
995  *              HiliteMenuItem   (USER.162)
996  */
997 BOOL16 WINAPI HiliteMenuItem16( HWND16 hwnd, HMENU16 hMenu, UINT16 id, UINT16 wHilite )
998 {
999     return HiliteMenuItem( WIN_Handle32(hwnd), HMENU_32(hMenu), id, wHilite );
1000 }
1001
1002
1003 /**************************************************************************
1004  *              CreateCaret   (USER.163)
1005  */
1006 void WINAPI CreateCaret16( HWND16 hwnd, HBITMAP16 bitmap, INT16 width, INT16 height )
1007 {
1008     CreateCaret( WIN_Handle32(hwnd), HBITMAP_32(bitmap), width, height );
1009 }
1010
1011
1012 /*****************************************************************
1013  *              DestroyCaret (USER.164)
1014  */
1015 void WINAPI DestroyCaret16(void)
1016 {
1017     DestroyCaret();
1018 }
1019
1020
1021 /*****************************************************************
1022  *              SetCaretPos (USER.165)
1023  */
1024 void WINAPI SetCaretPos16( INT16 x, INT16 y )
1025 {
1026     SetCaretPos( x, y );
1027 }
1028
1029
1030 /**************************************************************************
1031  *              HideCaret   (USER.166)
1032  */
1033 void WINAPI HideCaret16( HWND16 hwnd )
1034 {
1035     HideCaret( WIN_Handle32(hwnd) );
1036 }
1037
1038
1039 /**************************************************************************
1040  *              ShowCaret   (USER.167)
1041  */
1042 void WINAPI ShowCaret16( HWND16 hwnd )
1043 {
1044     ShowCaret( WIN_Handle32(hwnd) );
1045 }
1046
1047
1048 /*****************************************************************
1049  *              SetCaretBlinkTime (USER.168)
1050  */
1051 void WINAPI SetCaretBlinkTime16( UINT16 msecs )
1052 {
1053     SetCaretBlinkTime( msecs );
1054 }
1055
1056
1057 /*****************************************************************
1058  *              GetCaretBlinkTime (USER.169)
1059  */
1060 UINT16 WINAPI GetCaretBlinkTime16(void)
1061 {
1062     return GetCaretBlinkTime();
1063 }
1064
1065
1066 /**************************************************************************
1067  *              ArrangeIconicWindows   (USER.170)
1068  */
1069 UINT16 WINAPI ArrangeIconicWindows16( HWND16 parent)
1070 {
1071     return ArrangeIconicWindows( WIN_Handle32(parent) );
1072 }
1073
1074
1075 /**************************************************************************
1076  *              SwitchToThisWindow   (USER.172)
1077  */
1078 void WINAPI SwitchToThisWindow16( HWND16 hwnd, BOOL16 restore )
1079 {
1080     SwitchToThisWindow( WIN_Handle32(hwnd), restore );
1081 }
1082
1083
1084 /**************************************************************************
1085  *              KillSystemTimer   (USER.182)
1086  */
1087 BOOL16 WINAPI KillSystemTimer16( HWND16 hwnd, UINT16 id )
1088 {
1089     return KillSystemTimer( WIN_Handle32(hwnd), id );
1090 }
1091
1092
1093 /*****************************************************************
1094  *              GetCaretPos (USER.183)
1095  */
1096 void WINAPI GetCaretPos16( LPPOINT16 pt16 )
1097 {
1098     POINT pt;
1099     if (GetCaretPos( &pt ))
1100     {
1101         pt16->x = pt.x;
1102         pt16->y = pt.y;
1103     }
1104 }
1105
1106
1107 /**************************************************************************
1108  *              SetSysModalWindow   (USER.188)
1109  */
1110 HWND16 WINAPI SetSysModalWindow16( HWND16 hwnd )
1111 {
1112     HWND16 old = hwndSysModal;
1113     hwndSysModal = hwnd;
1114     return old;
1115 }
1116
1117
1118 /**************************************************************************
1119  *              GetSysModalWindow   (USER.189)
1120  */
1121 HWND16 WINAPI GetSysModalWindow16(void)
1122 {
1123     return hwndSysModal;
1124 }
1125
1126
1127 /**************************************************************************
1128  *              GetUpdateRect   (USER.190)
1129  */
1130 BOOL16 WINAPI GetUpdateRect16( HWND16 hwnd, LPRECT16 rect, BOOL16 erase )
1131 {
1132     RECT r;
1133     BOOL16 ret;
1134
1135     if (!rect) return GetUpdateRect( WIN_Handle32(hwnd), NULL, erase );
1136     ret = GetUpdateRect( WIN_Handle32(hwnd), &r, erase );
1137     rect->left   = r.left;
1138     rect->top    = r.top;
1139     rect->right  = r.right;
1140     rect->bottom = r.bottom;
1141     return ret;
1142 }
1143
1144
1145 /**************************************************************************
1146  *              ChildWindowFromPoint   (USER.191)
1147  */
1148 HWND16 WINAPI ChildWindowFromPoint16( HWND16 hwndParent, POINT16 pt )
1149 {
1150     POINT pt32;
1151
1152     pt32.x = pt.x;
1153     pt32.y = pt.y;
1154     return HWND_16( ChildWindowFromPoint( WIN_Handle32(hwndParent), pt32 ));
1155 }
1156
1157
1158 /***********************************************************************
1159  *              CascadeChildWindows (USER.198)
1160  */
1161 void WINAPI CascadeChildWindows16( HWND16 parent, WORD action )
1162 {
1163     CascadeWindows( WIN_Handle32(parent), action, NULL, 0, NULL );
1164 }
1165
1166
1167 /***********************************************************************
1168  *              TileChildWindows (USER.199)
1169  */
1170 void WINAPI TileChildWindows16( HWND16 parent, WORD action )
1171 {
1172     TileWindows( WIN_Handle32(parent), action, NULL, 0, NULL );
1173 }
1174
1175
1176 /***********************************************************************
1177  *              GetWindowTask   (USER.224)
1178  */
1179 HTASK16 WINAPI GetWindowTask16( HWND16 hwnd )
1180 {
1181     DWORD tid = GetWindowThreadProcessId( HWND_32(hwnd), NULL );
1182     if (!tid) return 0;
1183     return HTASK_16(tid);
1184 }
1185
1186 /**********************************************************************
1187  *              EnumTaskWindows   (USER.225)
1188  */
1189 BOOL16 WINAPI EnumTaskWindows16( HTASK16 hTask, WNDENUMPROC16 func, LPARAM lParam )
1190 {
1191     struct wnd_enum_info info;
1192     DWORD tid = HTASK_32( hTask );
1193
1194     if (!tid) return FALSE;
1195     info.proc  = func;
1196     info.param = lParam;
1197     return EnumThreadWindows( tid, wnd_enum_callback, (LPARAM)&info );
1198 }
1199
1200
1201 /**************************************************************************
1202  *              GetTopWindow   (USER.229)
1203  */
1204 HWND16 WINAPI GetTopWindow16( HWND16 hwnd )
1205 {
1206     return HWND_16( GetTopWindow( WIN_Handle32(hwnd) ));
1207 }
1208
1209
1210 /**************************************************************************
1211  *              GetNextWindow   (USER.230)
1212  */
1213 HWND16 WINAPI GetNextWindow16( HWND16 hwnd, WORD flag )
1214 {
1215     if ((flag != GW_HWNDNEXT) && (flag != GW_HWNDPREV)) return 0;
1216     return GetWindow16( hwnd, flag );
1217 }
1218
1219
1220 /**************************************************************************
1221  *              SetWindowPos   (USER.232)
1222  */
1223 BOOL16 WINAPI SetWindowPos16( HWND16 hwnd, HWND16 hwndInsertAfter,
1224                               INT16 x, INT16 y, INT16 cx, INT16 cy, WORD flags)
1225 {
1226     return SetWindowPos( WIN_Handle32(hwnd), full_insert_after_hwnd(hwndInsertAfter),
1227                          x, y, cx, cy, flags );
1228 }
1229
1230
1231 /**************************************************************************
1232  *              SetParent   (USER.233)
1233  */
1234 HWND16 WINAPI SetParent16( HWND16 hwndChild, HWND16 hwndNewParent )
1235 {
1236     return HWND_16( SetParent( WIN_Handle32(hwndChild), WIN_Handle32(hwndNewParent) ));
1237 }
1238
1239
1240 /**************************************************************************
1241  *              GetCapture   (USER.236)
1242  */
1243 HWND16 WINAPI GetCapture16(void)
1244 {
1245     return HWND_16( GetCapture() );
1246 }
1247
1248
1249 /**************************************************************************
1250  *              GetUpdateRgn   (USER.237)
1251  */
1252 INT16 WINAPI GetUpdateRgn16( HWND16 hwnd, HRGN16 hrgn, BOOL16 erase )
1253 {
1254     return GetUpdateRgn( WIN_Handle32(hwnd), HRGN_32(hrgn), erase );
1255 }
1256
1257
1258 /**************************************************************************
1259  *              ExcludeUpdateRgn   (USER.238)
1260  */
1261 INT16 WINAPI ExcludeUpdateRgn16( HDC16 hdc, HWND16 hwnd )
1262 {
1263     return ExcludeUpdateRgn( HDC_32(hdc), WIN_Handle32(hwnd) );
1264 }
1265
1266
1267 /**************************************************************************
1268  *              GetOpenClipboardWindow   (USER.248)
1269  */
1270 HWND16 WINAPI GetOpenClipboardWindow16(void)
1271 {
1272     return HWND_16( GetOpenClipboardWindow() );
1273 }
1274
1275
1276 /*******************************************************************
1277  *              MapWindowPoints (USER.258)
1278  */
1279 void WINAPI MapWindowPoints16( HWND16 hwndFrom, HWND16 hwndTo, LPPOINT16 lppt, UINT16 count )
1280 {
1281     POINT buffer[8], *ppt = buffer;
1282     UINT i;
1283
1284     if (count > 8) ppt = HeapAlloc( GetProcessHeap(), 0, count * sizeof(*ppt) );
1285     for (i = 0; i < count; i++)
1286     {
1287         ppt[i].x = lppt[i].x;
1288         ppt[i].y = lppt[i].y;
1289     }
1290     MapWindowPoints( WIN_Handle32(hwndFrom), WIN_Handle32(hwndTo), ppt, count );
1291     for (i = 0; i < count; i++)
1292     {
1293         lppt[i].x = ppt[i].x;
1294         lppt[i].y = ppt[i].y;
1295     }
1296     if (ppt != buffer) HeapFree( GetProcessHeap(), 0, ppt );
1297 }
1298
1299
1300 /**************************************************************************
1301  *              BeginDeferWindowPos   (USER.259)
1302  */
1303 HDWP16 WINAPI BeginDeferWindowPos16( INT16 count )
1304 {
1305     return HDWP_16(BeginDeferWindowPos( count ));
1306 }
1307
1308
1309 /**************************************************************************
1310  *              DeferWindowPos   (USER.260)
1311  */
1312 HDWP16 WINAPI DeferWindowPos16( HDWP16 hdwp, HWND16 hwnd, HWND16 hwndAfter,
1313                                 INT16 x, INT16 y, INT16 cx, INT16 cy,
1314                                 UINT16 flags )
1315 {
1316     return HDWP_16(DeferWindowPos( HDWP_32(hdwp), WIN_Handle32(hwnd),
1317                    full_insert_after_hwnd(hwndAfter), x, y, cx, cy, flags ));
1318 }
1319
1320
1321 /**************************************************************************
1322  *              EndDeferWindowPos   (USER.261)
1323  */
1324 BOOL16 WINAPI EndDeferWindowPos16( HDWP16 hdwp )
1325 {
1326     return EndDeferWindowPos(HDWP_32(hdwp));
1327 }
1328
1329
1330 /**************************************************************************
1331  *              GetWindow   (USER.262)
1332  */
1333 HWND16 WINAPI GetWindow16( HWND16 hwnd, WORD rel )
1334 {
1335     return HWND_16( GetWindow( WIN_Handle32(hwnd), rel ) );
1336 }
1337
1338
1339 /**************************************************************************
1340  *              ShowOwnedPopups   (USER.265)
1341  */
1342 void WINAPI ShowOwnedPopups16( HWND16 owner, BOOL16 fShow )
1343 {
1344     ShowOwnedPopups( WIN_Handle32(owner), fShow );
1345 }
1346
1347
1348 /**************************************************************************
1349  *              ShowScrollBar   (USER.267)
1350  */
1351 void WINAPI ShowScrollBar16( HWND16 hwnd, INT16 nBar, BOOL16 fShow )
1352 {
1353     ShowScrollBar( WIN_Handle32(hwnd), nBar, fShow );
1354 }
1355
1356
1357 /**************************************************************************
1358  *              IsZoomed   (USER.272)
1359  */
1360 BOOL16 WINAPI IsZoomed16(HWND16 hwnd)
1361 {
1362     return IsZoomed( WIN_Handle32(hwnd) );
1363 }
1364
1365
1366 /**************************************************************************
1367  *              GetDlgCtrlID   (USER.277)
1368  */
1369 INT16 WINAPI GetDlgCtrlID16( HWND16 hwnd )
1370 {
1371     return GetDlgCtrlID( WIN_Handle32(hwnd) );
1372 }
1373
1374
1375 /**************************************************************************
1376  *              GetDesktopHwnd   (USER.278)
1377  *
1378  * Exactly the same thing as GetDesktopWindow(), but not documented.
1379  * Don't ask me why...
1380  */
1381 HWND16 WINAPI GetDesktopHwnd16(void)
1382 {
1383     return GetDesktopWindow16();
1384 }
1385
1386
1387 /**************************************************************************
1388  *              SetSystemMenu   (USER.280)
1389  */
1390 BOOL16 WINAPI SetSystemMenu16( HWND16 hwnd, HMENU16 hMenu )
1391 {
1392     return SetSystemMenu( WIN_Handle32(hwnd), HMENU_32(hMenu) );
1393 }
1394
1395
1396 /**************************************************************************
1397  *              GetDesktopWindow   (USER.286)
1398  */
1399 HWND16 WINAPI GetDesktopWindow16(void)
1400 {
1401     return HWND_16( GetDesktopWindow() );
1402 }
1403
1404
1405 /**************************************************************************
1406  *              GetLastActivePopup   (USER.287)
1407  */
1408 HWND16 WINAPI GetLastActivePopup16( HWND16 hwnd )
1409 {
1410     return HWND_16( GetLastActivePopup( WIN_Handle32(hwnd) ));
1411 }
1412
1413
1414 /**************************************************************************
1415  *              RedrawWindow   (USER.290)
1416  */
1417 BOOL16 WINAPI RedrawWindow16( HWND16 hwnd, const RECT16 *rectUpdate,
1418                               HRGN16 hrgnUpdate, UINT16 flags )
1419 {
1420     if (rectUpdate)
1421     {
1422         RECT r;
1423         r.left   = rectUpdate->left;
1424         r.top    = rectUpdate->top;
1425         r.right  = rectUpdate->right;
1426         r.bottom = rectUpdate->bottom;
1427         return RedrawWindow(WIN_Handle32(hwnd), &r, HRGN_32(hrgnUpdate), flags);
1428     }
1429     return RedrawWindow(WIN_Handle32(hwnd), NULL, HRGN_32(hrgnUpdate), flags);
1430 }
1431
1432
1433 /**************************************************************************
1434  *              LockWindowUpdate   (USER.294)
1435  */
1436 BOOL16 WINAPI LockWindowUpdate16( HWND16 hwnd )
1437 {
1438     return LockWindowUpdate( WIN_Handle32(hwnd) );
1439 }
1440
1441
1442 /**************************************************************************
1443  *              ScrollWindowEx   (USER.319)
1444  */
1445 INT16 WINAPI ScrollWindowEx16( HWND16 hwnd, INT16 dx, INT16 dy,
1446                                const RECT16 *rect, const RECT16 *clipRect,
1447                                HRGN16 hrgnUpdate, LPRECT16 rcUpdate,
1448                                UINT16 flags )
1449 {
1450     RECT rect32, clipRect32, rcUpdate32;
1451     BOOL16 ret;
1452
1453     if (rect)
1454     {
1455         rect32.left   = rect->left;
1456         rect32.top    = rect->top;
1457         rect32.right  = rect->right;
1458         rect32.bottom = rect->bottom;
1459     }
1460     if (clipRect)
1461     {
1462         clipRect32.left   = clipRect->left;
1463         clipRect32.top    = clipRect->top;
1464         clipRect32.right  = clipRect->right;
1465         clipRect32.bottom = clipRect->bottom;
1466     }
1467     ret = ScrollWindowEx( WIN_Handle32(hwnd), dx, dy, rect ? &rect32 : NULL,
1468                           clipRect ? &clipRect32 : NULL, HRGN_32(hrgnUpdate),
1469                           (rcUpdate) ? &rcUpdate32 : NULL, flags );
1470     if (rcUpdate)
1471     {
1472         rcUpdate->left   = rcUpdate32.left;
1473         rcUpdate->top    = rcUpdate32.top;
1474         rcUpdate->right  = rcUpdate32.right;
1475         rcUpdate->bottom = rcUpdate32.bottom;
1476     }
1477     return ret;
1478 }
1479
1480
1481 /**************************************************************************
1482  *              FillWindow   (USER.324)
1483  */
1484 void WINAPI FillWindow16( HWND16 hwndParent, HWND16 hwnd, HDC16 hdc, HBRUSH16 hbrush )
1485 {
1486     RECT rect;
1487     RECT16 rc16;
1488     GetClientRect( WIN_Handle32(hwnd), &rect );
1489     DPtoLP( HDC_32(hdc), (LPPOINT)&rect, 2 );
1490     rc16.left   = rect.left;
1491     rc16.top    = rect.top;
1492     rc16.right  = rect.right;
1493     rc16.bottom = rect.bottom;
1494     PaintRect16( hwndParent, hwnd, hdc, hbrush, &rc16 );
1495 }
1496
1497
1498 /**************************************************************************
1499  *              PaintRect   (USER.325)
1500  */
1501 void WINAPI PaintRect16( HWND16 hwndParent, HWND16 hwnd, HDC16 hdc,
1502                          HBRUSH16 hbrush, const RECT16 *rect)
1503 {
1504     if (hbrush <= CTLCOLOR_STATIC)
1505     {
1506         HWND parent = WIN_Handle32(hwndParent), hwnd32 = WIN_Handle32(hwnd);
1507
1508         if (!parent) return;
1509         hbrush = SendMessageW( parent, WM_CTLCOLORMSGBOX + hbrush, hdc, (LPARAM)hwnd32 );
1510         if (!hbrush) hbrush = DefWindowProcW( parent, WM_CTLCOLORMSGBOX + hbrush,
1511                                               hdc, (LPARAM)hwnd32 );
1512     }
1513     if (hbrush) FillRect16( hdc, rect, hbrush );
1514 }
1515
1516
1517 /**************************************************************************
1518  *              GetControlBrush   (USER.326)
1519  */
1520 HBRUSH16 WINAPI GetControlBrush16( HWND16 hwnd, HDC16 hdc, UINT16 ctlType )
1521 {
1522     HBRUSH16 ret;
1523     HWND hwnd32 = WIN_Handle32(hwnd);
1524     HWND parent = GetParent( hwnd32 );
1525
1526     if (!parent) parent = hwnd32;
1527     ret = SendMessageW( parent, WM_CTLCOLORMSGBOX + ctlType, hdc, (LPARAM)hwnd32 );
1528     if (!ret) ret = DefWindowProcW( parent, WM_CTLCOLORMSGBOX + ctlType,
1529                                     hdc, (LPARAM)hwnd32 );
1530     return ret;
1531 }
1532
1533
1534 /**************************************************************************
1535  *              GetDCEx   (USER.359)
1536  */
1537 HDC16 WINAPI GetDCEx16( HWND16 hwnd, HRGN16 hrgnClip, DWORD flags )
1538 {
1539     return HDC_16(GetDCEx(WIN_Handle32(hwnd), HRGN_32(hrgnClip), flags));
1540 }
1541
1542
1543 /**************************************************************************
1544  *              GetWindowPlacement   (USER.370)
1545  */
1546 BOOL16 WINAPI GetWindowPlacement16( HWND16 hwnd, WINDOWPLACEMENT16 *wp16 )
1547 {
1548     WINDOWPLACEMENT wpl;
1549
1550     wpl.length = sizeof(wpl);
1551     if (!GetWindowPlacement( WIN_Handle32(hwnd), &wpl )) return FALSE;
1552     wp16->length  = sizeof(*wp16);
1553     wp16->flags   = wpl.flags;
1554     wp16->showCmd = wpl.showCmd;
1555     wp16->ptMinPosition.x = wpl.ptMinPosition.x;
1556     wp16->ptMinPosition.y = wpl.ptMinPosition.y;
1557     wp16->ptMaxPosition.x = wpl.ptMaxPosition.x;
1558     wp16->ptMaxPosition.y = wpl.ptMaxPosition.y;
1559     wp16->rcNormalPosition.left   = wpl.rcNormalPosition.left;
1560     wp16->rcNormalPosition.top    = wpl.rcNormalPosition.top;
1561     wp16->rcNormalPosition.right  = wpl.rcNormalPosition.right;
1562     wp16->rcNormalPosition.bottom = wpl.rcNormalPosition.bottom;
1563     return TRUE;
1564 }
1565
1566
1567 /**************************************************************************
1568  *              SetWindowPlacement   (USER.371)
1569  */
1570 BOOL16 WINAPI SetWindowPlacement16( HWND16 hwnd, const WINDOWPLACEMENT16 *wp16 )
1571 {
1572     WINDOWPLACEMENT wpl;
1573
1574     if (!wp16) return FALSE;
1575     wpl.length  = sizeof(wpl);
1576     wpl.flags   = wp16->flags;
1577     wpl.showCmd = wp16->showCmd;
1578     wpl.ptMinPosition.x = wp16->ptMinPosition.x;
1579     wpl.ptMinPosition.y = wp16->ptMinPosition.y;
1580     wpl.ptMaxPosition.x = wp16->ptMaxPosition.x;
1581     wpl.ptMaxPosition.y = wp16->ptMaxPosition.y;
1582     wpl.rcNormalPosition.left   = wp16->rcNormalPosition.left;
1583     wpl.rcNormalPosition.top    = wp16->rcNormalPosition.top;
1584     wpl.rcNormalPosition.right  = wp16->rcNormalPosition.right;
1585     wpl.rcNormalPosition.bottom = wp16->rcNormalPosition.bottom;
1586     return SetWindowPlacement( WIN_Handle32(hwnd), &wpl );
1587 }
1588
1589
1590 /***********************************************************************
1591  *              RegisterClassEx (USER.397)
1592  */
1593 ATOM WINAPI RegisterClassEx16( const WNDCLASSEX16 *wc )
1594 {
1595     struct class_entry *class;
1596     WNDCLASSEXA wc32;
1597     HINSTANCE16 inst;
1598     ATOM atom;
1599
1600     inst = GetExePtr( wc->hInstance );
1601     if (!inst) inst = GetModuleHandle16( NULL );
1602
1603     wc32.cbSize        = sizeof(wc32);
1604     wc32.style         = wc->style;
1605     wc32.lpfnWndProc   = WINPROC_AllocProc16( wc->lpfnWndProc );
1606     wc32.cbClsExtra    = wc->cbClsExtra;
1607     wc32.cbWndExtra    = wc->cbWndExtra;
1608     wc32.hInstance     = HINSTANCE_32(inst);
1609     wc32.hIcon         = get_icon_32(wc->hIcon);
1610     wc32.hCursor       = get_icon_32( wc->hCursor );
1611     wc32.hbrBackground = HBRUSH_32(wc->hbrBackground);
1612     wc32.lpszMenuName  = MapSL(wc->lpszMenuName);
1613     wc32.lpszClassName = MapSL(wc->lpszClassName);
1614     wc32.hIconSm       = get_icon_32(wc->hIconSm);
1615     atom = RegisterClassExA( &wc32 );
1616     if ((class = HeapAlloc( GetProcessHeap(), 0, sizeof(*class) )))
1617     {
1618         class->atom = atom;
1619         class->inst = inst;
1620         list_add_tail( &class_list, &class->entry );
1621     }
1622     return atom;
1623 }
1624
1625
1626 /***********************************************************************
1627  *              GetClassInfoEx (USER.398)
1628  *
1629  * FIXME: this is just a guess, I have no idea if GetClassInfoEx() is the
1630  * same in Win16 as in Win32. --AJ
1631  */
1632 BOOL16 WINAPI GetClassInfoEx16( HINSTANCE16 hInst16, SEGPTR name, WNDCLASSEX16 *wc )
1633 {
1634     static HMODULE user32_module;
1635     WNDCLASSEXA wc32;
1636     HINSTANCE hInstance;
1637     BOOL ret;
1638
1639     if (!user32_module) user32_module = GetModuleHandleA( "user32.dll" );
1640     if (hInst16 == GetModuleHandle16("user")) hInstance = user32_module;
1641     else hInstance = HINSTANCE_32(GetExePtr( hInst16 ));
1642
1643     ret = GetClassInfoExA( hInstance, MapSL(name), &wc32 );
1644
1645     if (ret)
1646     {
1647         wc->lpfnWndProc   = WINPROC_GetProc16( wc32.lpfnWndProc, FALSE );
1648         wc->style         = wc32.style;
1649         wc->cbClsExtra    = wc32.cbClsExtra;
1650         wc->cbWndExtra    = wc32.cbWndExtra;
1651         wc->hInstance     = (wc32.hInstance == user32_module) ? GetModuleHandle16("user") : HINSTANCE_16(wc32.hInstance);
1652         wc->hIcon         = get_icon_16( wc32.hIcon );
1653         wc->hIconSm       = get_icon_16( wc32.hIconSm );
1654         wc->hCursor       = get_icon_16( wc32.hCursor );
1655         wc->hbrBackground = HBRUSH_16(wc32.hbrBackground);
1656         wc->lpszClassName = 0;
1657         wc->lpszMenuName  = MapLS(wc32.lpszMenuName);  /* FIXME: leak */
1658     }
1659     return ret;
1660 }
1661
1662
1663 /**************************************************************************
1664  *              ChildWindowFromPointEx   (USER.399)
1665  */
1666 HWND16 WINAPI ChildWindowFromPointEx16( HWND16 hwndParent, POINT16 pt, UINT16 uFlags)
1667 {
1668     POINT pt32;
1669
1670     pt32.x = pt.x;
1671     pt32.y = pt.y;
1672     return HWND_16( ChildWindowFromPointEx( WIN_Handle32(hwndParent), pt32, uFlags ));
1673 }
1674
1675
1676 /**************************************************************************
1677  *              GetPriorityClipboardFormat   (USER.402)
1678  */
1679 INT16 WINAPI GetPriorityClipboardFormat16( UINT16 *list, INT16 count )
1680 {
1681     int i;
1682
1683     for (i = 0; i < count; i++)
1684         if (IsClipboardFormatAvailable( list[i] )) return list[i];
1685     return -1;
1686 }
1687
1688
1689 /***********************************************************************
1690  *              UnregisterClass (USER.403)
1691  */
1692 BOOL16 WINAPI UnregisterClass16( LPCSTR className, HINSTANCE16 hInstance )
1693 {
1694     ATOM atom;
1695
1696     if (hInstance == GetModuleHandle16("user")) hInstance = 0;
1697     else hInstance = GetExePtr( hInstance );
1698
1699     if ((atom = GlobalFindAtomA( className )))
1700     {
1701         struct class_entry *class;
1702         LIST_FOR_EACH_ENTRY( class, &class_list, struct class_entry, entry )
1703         {
1704             if (class->inst != hInstance) continue;
1705             if (class->atom != atom) continue;
1706             list_remove( &class->entry );
1707             HeapFree( GetProcessHeap(), 0, class );
1708             break;
1709         }
1710     }
1711     return UnregisterClassA( className, HINSTANCE_32(hInstance) );
1712 }
1713
1714
1715 /***********************************************************************
1716  *              GetClassInfo (USER.404)
1717  */
1718 BOOL16 WINAPI GetClassInfo16( HINSTANCE16 hInst16, SEGPTR name, WNDCLASS16 *wc )
1719 {
1720     WNDCLASSEX16 wcex;
1721     UINT16 ret = GetClassInfoEx16( hInst16, name, &wcex );
1722
1723     if (ret)
1724     {
1725         wc->style         = wcex.style;
1726         wc->lpfnWndProc   = wcex.lpfnWndProc;
1727         wc->cbClsExtra    = wcex.cbClsExtra;
1728         wc->cbWndExtra    = wcex.cbWndExtra;
1729         wc->hInstance     = wcex.hInstance;
1730         wc->hIcon         = wcex.hIcon;
1731         wc->hCursor       = wcex.hCursor;
1732         wc->hbrBackground = wcex.hbrBackground;
1733         wc->lpszMenuName  = wcex.lpszMenuName;
1734         wc->lpszClassName = wcex.lpszClassName;
1735     }
1736     return ret;
1737 }
1738
1739
1740 /**************************************************************************
1741  *              TrackPopupMenu   (USER.416)
1742  */
1743 BOOL16 WINAPI TrackPopupMenu16( HMENU16 hMenu, UINT16 wFlags, INT16 x, INT16 y,
1744                                 INT16 nReserved, HWND16 hwnd, const RECT16 *lpRect )
1745 {
1746     RECT r;
1747     if (lpRect)
1748     {
1749         r.left   = lpRect->left;
1750         r.top    = lpRect->top;
1751         r.right  = lpRect->right;
1752         r.bottom = lpRect->bottom;
1753     }
1754     return TrackPopupMenu( HMENU_32(hMenu), wFlags, x, y, nReserved,
1755                            WIN_Handle32(hwnd), lpRect ? &r : NULL );
1756 }
1757
1758
1759 /**************************************************************************
1760  *              FindWindowEx   (USER.427)
1761  */
1762 HWND16 WINAPI FindWindowEx16( HWND16 parent, HWND16 child, LPCSTR className, LPCSTR title )
1763 {
1764     return HWND_16( FindWindowExA( WIN_Handle32(parent), WIN_Handle32(child),
1765                                         className, title ));
1766 }
1767
1768
1769 /***********************************************************************
1770  *              DefFrameProc (USER.445)
1771  */
1772 LRESULT WINAPI DefFrameProc16( HWND16 hwnd, HWND16 hwndMDIClient,
1773                                UINT16 message, WPARAM16 wParam, LPARAM lParam )
1774 {
1775     switch (message)
1776     {
1777     case WM_SETTEXT:
1778         lParam = (LPARAM)MapSL(lParam);
1779         /* fall through */
1780     case WM_COMMAND:
1781     case WM_NCACTIVATE:
1782     case WM_SETFOCUS:
1783     case WM_SIZE:
1784         return DefFrameProcA( WIN_Handle32(hwnd), WIN_Handle32(hwndMDIClient),
1785                               message, wParam, lParam );
1786
1787     case WM_NEXTMENU:
1788         {
1789             MDINEXTMENU next_menu;
1790             DefFrameProcW( WIN_Handle32(hwnd), WIN_Handle32(hwndMDIClient),
1791                            message, wParam, (LPARAM)&next_menu );
1792             return MAKELONG( HMENU_16(next_menu.hmenuNext), HWND_16(next_menu.hwndNext) );
1793         }
1794     default:
1795         return DefWindowProc16(hwnd, message, wParam, lParam);
1796     }
1797 }
1798
1799
1800 /***********************************************************************
1801  *              DefMDIChildProc (USER.447)
1802  */
1803 LRESULT WINAPI DefMDIChildProc16( HWND16 hwnd, UINT16 message,
1804                                   WPARAM16 wParam, LPARAM lParam )
1805 {
1806     switch (message)
1807     {
1808     case WM_SETTEXT:
1809         return DefMDIChildProcA( WIN_Handle32(hwnd), message, wParam, (LPARAM)MapSL(lParam) );
1810
1811     case WM_MENUCHAR:
1812     case WM_CLOSE:
1813     case WM_SETFOCUS:
1814     case WM_CHILDACTIVATE:
1815     case WM_SYSCOMMAND:
1816     case WM_SETVISIBLE:
1817     case WM_SIZE:
1818     case WM_SYSCHAR:
1819         return DefMDIChildProcW( WIN_Handle32(hwnd), message, wParam, lParam );
1820
1821     case WM_GETMINMAXINFO:
1822         {
1823             MINMAXINFO16 *mmi16 = MapSL(lParam);
1824             MINMAXINFO mmi;
1825
1826             mmi.ptReserved.x     = mmi16->ptReserved.x;
1827             mmi.ptReserved.y     = mmi16->ptReserved.y;
1828             mmi.ptMaxSize.x      = mmi16->ptMaxSize.x;
1829             mmi.ptMaxSize.y      = mmi16->ptMaxSize.y;
1830             mmi.ptMaxPosition.x  = mmi16->ptMaxPosition.x;
1831             mmi.ptMaxPosition.y  = mmi16->ptMaxPosition.y;
1832             mmi.ptMinTrackSize.x = mmi16->ptMinTrackSize.x;
1833             mmi.ptMinTrackSize.y = mmi16->ptMinTrackSize.y;
1834             mmi.ptMaxTrackSize.x = mmi16->ptMaxTrackSize.x;
1835             mmi.ptMaxTrackSize.y = mmi16->ptMaxTrackSize.y;
1836
1837             DefMDIChildProcW( WIN_Handle32(hwnd), message, wParam, (LPARAM)&mmi );
1838
1839             mmi16->ptReserved.x     = mmi.ptReserved.x;
1840             mmi16->ptReserved.y     = mmi.ptReserved.y;
1841             mmi16->ptMaxSize.x      = mmi.ptMaxSize.x;
1842             mmi16->ptMaxSize.y      = mmi.ptMaxSize.y;
1843             mmi16->ptMaxPosition.x  = mmi.ptMaxPosition.x;
1844             mmi16->ptMaxPosition.y  = mmi.ptMaxPosition.y;
1845             mmi16->ptMinTrackSize.x = mmi.ptMinTrackSize.x;
1846             mmi16->ptMinTrackSize.y = mmi.ptMinTrackSize.y;
1847             mmi16->ptMaxTrackSize.x = mmi.ptMaxTrackSize.x;
1848             mmi16->ptMaxTrackSize.y = mmi.ptMaxTrackSize.y;
1849             return 0;
1850         }
1851     case WM_NEXTMENU:
1852         {
1853             MDINEXTMENU next_menu;
1854             DefMDIChildProcW( WIN_Handle32(hwnd), message, wParam, (LPARAM)&next_menu );
1855             return MAKELONG( HMENU_16(next_menu.hmenuNext), HWND_16(next_menu.hwndNext) );
1856         }
1857     default:
1858         return DefWindowProc16(hwnd, message, wParam, lParam);
1859     }
1860 }
1861
1862
1863 /**************************************************************************
1864  *              DrawAnimatedRects   (USER.448)
1865  */
1866 BOOL16 WINAPI DrawAnimatedRects16( HWND16 hwnd, INT16 idAni,
1867                                    const RECT16* lprcFrom, const RECT16* lprcTo )
1868 {
1869     RECT rcFrom32, rcTo32;
1870     rcFrom32.left   = lprcFrom->left;
1871     rcFrom32.top    = lprcFrom->top;
1872     rcFrom32.right  = lprcFrom->right;
1873     rcFrom32.bottom = lprcFrom->bottom;
1874     rcTo32.left     = lprcTo->left;
1875     rcTo32.top      = lprcTo->top;
1876     rcTo32.right    = lprcTo->right;
1877     rcTo32.bottom   = lprcTo->bottom;
1878     return DrawAnimatedRects( WIN_Handle32(hwnd), idAni, &rcFrom32, &rcTo32 );
1879 }
1880
1881
1882 /***********************************************************************
1883  *              CreateWindowEx (USER.452)
1884  */
1885 HWND16 WINAPI CreateWindowEx16( DWORD exStyle, LPCSTR className,
1886                                 LPCSTR windowName, DWORD style, INT16 x,
1887                                 INT16 y, INT16 width, INT16 height,
1888                                 HWND16 parent, HMENU16 menu,
1889                                 HINSTANCE16 instance, LPVOID data )
1890 {
1891     CREATESTRUCTA cs;
1892     char buffer[256];
1893     HWND hwnd;
1894
1895     /* Fix the coordinates */
1896
1897     cs.x  = (x == CW_USEDEFAULT16) ? CW_USEDEFAULT : (INT)x;
1898     cs.y  = (y == CW_USEDEFAULT16) ? CW_USEDEFAULT : (INT)y;
1899     cs.cx = (width == CW_USEDEFAULT16) ? CW_USEDEFAULT : (INT)width;
1900     cs.cy = (height == CW_USEDEFAULT16) ? CW_USEDEFAULT : (INT)height;
1901
1902     /* Create the window */
1903
1904     cs.lpCreateParams = data;
1905     cs.hInstance      = HINSTANCE_32(instance);
1906     cs.hMenu          = HMENU_32(menu);
1907     cs.hwndParent     = WIN_Handle32( parent );
1908     cs.style          = style;
1909     cs.lpszName       = windowName;
1910     cs.lpszClass      = className;
1911     cs.dwExStyle      = exStyle;
1912
1913     /* load the menu */
1914     if (!menu && (style & (WS_CHILD | WS_POPUP)) != WS_CHILD)
1915     {
1916         WNDCLASSA class;
1917         HINSTANCE16 module = GetExePtr( instance );
1918
1919         if (GetClassInfoA( HINSTANCE_32(module), className, &class ))
1920             cs.hMenu = HMENU_32( LoadMenu16( module, class.lpszMenuName ));
1921     }
1922
1923     if (!IS_INTRESOURCE(className))
1924     {
1925         WCHAR bufferW[256];
1926
1927         if (!MultiByteToWideChar( CP_ACP, 0, className, -1, bufferW, sizeof(bufferW)/sizeof(WCHAR) ))
1928             return 0;
1929         hwnd = create_window16( (CREATESTRUCTW *)&cs, bufferW, HINSTANCE_32(instance), FALSE );
1930     }
1931     else
1932     {
1933         if (!GlobalGetAtomNameA( LOWORD(className), buffer, sizeof(buffer) )) return 0;
1934         cs.lpszClass = buffer;
1935         hwnd = create_window16( (CREATESTRUCTW *)&cs, (LPCWSTR)className, HINSTANCE_32(instance), FALSE );
1936     }
1937     return HWND_16( hwnd );
1938 }
1939
1940
1941 /***********************************************************************
1942  *              GetInternalWindowPos (USER.460)
1943  */
1944 UINT16 WINAPI GetInternalWindowPos16( HWND16 hwnd, LPRECT16 rectWnd, LPPOINT16 ptIcon )
1945 {
1946     WINDOWPLACEMENT16 wndpl;
1947
1948     if (!GetWindowPlacement16( hwnd, &wndpl )) return 0;
1949     if (rectWnd) *rectWnd = wndpl.rcNormalPosition;
1950     if (ptIcon)  *ptIcon = wndpl.ptMinPosition;
1951     return wndpl.showCmd;
1952 }
1953
1954
1955 /**************************************************************************
1956  *              SetInternalWindowPos   (USER.461)
1957  */
1958 void WINAPI SetInternalWindowPos16( HWND16 hwnd, UINT16 showCmd, LPRECT16 rect, LPPOINT16 pt )
1959 {
1960     RECT rc32;
1961     POINT pt32;
1962
1963     if (rect)
1964     {
1965         rc32.left   = rect->left;
1966         rc32.top    = rect->top;
1967         rc32.right  = rect->right;
1968         rc32.bottom = rect->bottom;
1969     }
1970     if (pt)
1971     {
1972         pt32.x = pt->x;
1973         pt32.y = pt->y;
1974     }
1975     SetInternalWindowPos( WIN_Handle32(hwnd), showCmd,
1976                           rect ? &rc32 : NULL, pt ? &pt32 : NULL );
1977 }
1978
1979
1980 /**************************************************************************
1981  *              CalcChildScroll   (USER.462)
1982  */
1983 void WINAPI CalcChildScroll16( HWND16 hwnd, WORD scroll )
1984 {
1985     CalcChildScroll( WIN_Handle32(hwnd), scroll );
1986 }
1987
1988
1989 /**************************************************************************
1990  *              ScrollChildren   (USER.463)
1991  */
1992 void WINAPI ScrollChildren16(HWND16 hwnd, UINT16 uMsg, WPARAM16 wParam, LPARAM lParam)
1993 {
1994     ScrollChildren( WIN_Handle32(hwnd), uMsg, wParam, lParam );
1995 }
1996
1997
1998 /**************************************************************************
1999  *              DragDetect   (USER.465)
2000  */
2001 BOOL16 WINAPI DragDetect16( HWND16 hwnd, POINT16 pt )
2002 {
2003     POINT pt32;
2004
2005     pt32.x = pt.x;
2006     pt32.y = pt.y;
2007     return DragDetect( WIN_Handle32(hwnd), pt32 );
2008 }
2009
2010
2011 /**************************************************************************
2012  *              SetScrollInfo   (USER.475)
2013  */
2014 INT16 WINAPI SetScrollInfo16( HWND16 hwnd, INT16 nBar, const SCROLLINFO *info, BOOL16 redraw )
2015 {
2016     return SetScrollInfo( WIN_Handle32(hwnd), nBar, info, redraw );
2017 }
2018
2019
2020 /**************************************************************************
2021  *              GetScrollInfo   (USER.476)
2022  */
2023 BOOL16 WINAPI GetScrollInfo16( HWND16 hwnd, INT16 nBar, LPSCROLLINFO info )
2024 {
2025     return GetScrollInfo( WIN_Handle32(hwnd), nBar, info );
2026 }
2027
2028
2029 /**************************************************************************
2030  *              EnableScrollBar   (USER.482)
2031  */
2032 BOOL16 WINAPI EnableScrollBar16( HWND16 hwnd, INT16 nBar, UINT16 flags )
2033 {
2034     return EnableScrollBar( WIN_Handle32(hwnd), nBar, flags );
2035 }
2036
2037
2038 /**************************************************************************
2039  *              GetShellWindow   (USER.600)
2040  */
2041 HWND16 WINAPI GetShellWindow16(void)
2042 {
2043     return HWND_16( GetShellWindow() );
2044 }
2045
2046
2047 /**************************************************************************
2048  *              GetForegroundWindow   (USER.608)
2049  */
2050 HWND16 WINAPI GetForegroundWindow16(void)
2051 {
2052     return HWND_16( GetForegroundWindow() );
2053 }
2054
2055
2056 /**************************************************************************
2057  *              SetForegroundWindow   (USER.609)
2058  */
2059 BOOL16 WINAPI SetForegroundWindow16( HWND16 hwnd )
2060 {
2061     return SetForegroundWindow( WIN_Handle32(hwnd) );
2062 }
2063
2064
2065 /**************************************************************************
2066  *              DrawCaptionTemp   (USER.657)
2067  */
2068 BOOL16 WINAPI DrawCaptionTemp16( HWND16 hwnd, HDC16 hdc, const RECT16 *rect,
2069                                  HFONT16 hFont, HICON16 hIcon, LPCSTR str, UINT16 uFlags )
2070 {
2071     RECT rect32;
2072
2073     if (rect)
2074     {
2075         rect32.left   = rect->left;
2076         rect32.top    = rect->top;
2077         rect32.right  = rect->right;
2078         rect32.bottom = rect->bottom;
2079     }
2080     return DrawCaptionTempA( WIN_Handle32(hwnd), HDC_32(hdc),
2081                              rect ? &rect32 : NULL, HFONT_32(hFont),
2082                              get_icon_32(hIcon), str, uFlags & 0x1f );
2083 }
2084
2085
2086 /**************************************************************************
2087  *              DrawCaption   (USER.660)
2088  */
2089 BOOL16 WINAPI DrawCaption16( HWND16 hwnd, HDC16 hdc, const RECT16 *rect, UINT16 flags )
2090 {
2091     RECT rect32;
2092
2093     if (rect)
2094     {
2095         rect32.left   = rect->left;
2096         rect32.top    = rect->top;
2097         rect32.right  = rect->right;
2098         rect32.bottom = rect->bottom;
2099     }
2100     return DrawCaption(WIN_Handle32(hwnd), HDC_32(hdc), rect ? &rect32 : NULL, flags);
2101 }
2102
2103
2104 /**************************************************************************
2105  *              GetMenuItemRect   (USER.665)
2106  */
2107 BOOL16 WINAPI GetMenuItemRect16( HWND16 hwnd, HMENU16 hMenu, UINT16 uItem,
2108                                  LPRECT16 rect)
2109 {
2110      RECT r32;
2111      BOOL res;
2112      if (!rect) return FALSE;
2113      res = GetMenuItemRect( WIN_Handle32(hwnd), HMENU_32(hMenu), uItem, &r32 );
2114      rect->left   = r32.left;
2115      rect->top    = r32.top;
2116      rect->right  = r32.right;
2117      rect->bottom = r32.bottom;
2118      return res;
2119 }
2120
2121
2122 /**************************************************************************
2123  *              SetWindowRgn   (USER.668)
2124  */
2125 INT16 WINAPI SetWindowRgn16( HWND16 hwnd, HRGN16 hrgn, BOOL16 redraw )
2126 {
2127     return SetWindowRgn( WIN_Handle32(hwnd), HRGN_32(hrgn), redraw );
2128 }
2129
2130
2131 /**************************************************************************
2132  *              MessageBoxIndirect   (USER.827)
2133  */
2134 INT16 WINAPI MessageBoxIndirect16( LPMSGBOXPARAMS16 msgbox )
2135 {
2136     char caption[256], text[256];
2137     MSGBOXPARAMSA msgbox32;
2138
2139     msgbox32.cbSize             = msgbox->cbSize;
2140     msgbox32.hwndOwner          = WIN_Handle32( msgbox->hwndOwner );
2141     msgbox32.hInstance          = 0;
2142     msgbox32.dwStyle            = msgbox->dwStyle;
2143     msgbox32.lpszIcon           = NULL;
2144     msgbox32.dwContextHelpId    = msgbox->dwContextHelpId;
2145     msgbox32.lpfnMsgBoxCallback = msgbox->lpfnMsgBoxCallback;
2146     msgbox32.dwLanguageId       = msgbox->dwLanguageId;
2147
2148     if (!HIWORD(msgbox->lpszCaption))
2149     {
2150         LoadString16( msgbox->hInstance, LOWORD(msgbox->lpszCaption), caption, sizeof(caption) );
2151         msgbox32.lpszCaption = caption;
2152     }
2153     else msgbox32.lpszCaption = MapSL(msgbox->lpszCaption);
2154
2155     if (!HIWORD(msgbox->lpszText))
2156     {
2157         LoadString16( msgbox->hInstance, LOWORD(msgbox->lpszText), text, sizeof(text) );
2158         msgbox32.lpszText = text;
2159     }
2160     else msgbox32.lpszText = MapSL(msgbox->lpszText);
2161
2162     if ((msgbox->dwStyle & MB_ICONMASK) == MB_USERICON)
2163     {
2164         FIXME( "user icon %s not supported\n", debugstr_a( MapSL(msgbox->lpszIcon) ));
2165         msgbox32.dwStyle &= ~MB_USERICON;
2166     }
2167
2168     return MessageBoxIndirectA( &msgbox32 );
2169 }