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