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