dsound: Add eax properties
[wine/multimedia.git] / dlls / user.exe16 / window.c
blobe81d9ace3aec415e7dc4cf62b2856faa8a43cb2d
1 /*
2 * 16-bit windowing functions
4 * Copyright 2001 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "wine/winuser16.h"
22 #include "wownt32.h"
23 #include "user_private.h"
24 #include "wine/list.h"
25 #include "wine/server.h"
26 #include "wine/debug.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(win);
30 /* size of buffer needed to store an atom string */
31 #define ATOM_BUFFER_SIZE 256
33 /* handle <--> handle16 conversions */
34 #define HANDLE_16(h32) (LOWORD(h32))
35 #define HANDLE_32(h16) ((HANDLE)(ULONG_PTR)(h16))
37 static HWND16 hwndSysModal;
39 struct class_entry
41 struct list entry;
42 ATOM atom;
43 HINSTANCE16 inst;
46 static struct list class_list = LIST_INIT( class_list );
48 struct wnd_enum_info
50 WNDENUMPROC16 proc;
51 LPARAM param;
54 /* callback for 16-bit window enumeration functions */
55 static BOOL CALLBACK wnd_enum_callback( HWND hwnd, LPARAM param )
57 const struct wnd_enum_info *info = (struct wnd_enum_info *)param;
58 WORD args[3];
59 DWORD ret;
61 args[2] = HWND_16(hwnd);
62 args[1] = HIWORD(info->param);
63 args[0] = LOWORD(info->param);
64 WOWCallback16Ex( (DWORD)info->proc, WCB16_PASCAL, sizeof(args), args, &ret );
65 return LOWORD(ret);
68 /* convert insert after window handle to 32-bit */
69 static inline HWND full_insert_after_hwnd( HWND16 hwnd )
71 HWND ret = WIN_Handle32( hwnd );
72 if (ret == (HWND)0xffff) ret = HWND_TOPMOST;
73 return ret;
76 void free_module_classes( HINSTANCE16 inst )
78 struct class_entry *class, *next;
80 LIST_FOR_EACH_ENTRY_SAFE( class, next, &class_list, struct class_entry, entry )
82 if (class->inst != inst) continue;
83 list_remove( &class->entry );
84 UnregisterClassA( (LPCSTR)MAKEINTATOM(class->atom), HINSTANCE_32(class->inst) );
85 HeapFree( GetProcessHeap(), 0, class );
89 /**************************************************************************
90 * MessageBox (USER.1)
92 INT16 WINAPI MessageBox16( HWND16 hwnd, LPCSTR text, LPCSTR title, UINT16 type )
94 return MessageBoxA( WIN_Handle32(hwnd), text, title, type );
98 /***********************************************************************
99 * SetTimer (USER.10)
101 UINT16 WINAPI SetTimer16( HWND16 hwnd, UINT16 id, UINT16 timeout, TIMERPROC16 proc )
103 TIMERPROC proc32 = (TIMERPROC)WINPROC_AllocProc16( (WNDPROC16)proc );
104 return SetTimer( WIN_Handle32(hwnd), id, timeout, proc32 );
108 /***********************************************************************
109 * SetSystemTimer (USER.11)
111 UINT16 WINAPI SetSystemTimer16( HWND16 hwnd, UINT16 id, UINT16 timeout, TIMERPROC16 proc )
113 TIMERPROC proc32 = (TIMERPROC)WINPROC_AllocProc16( (WNDPROC16)proc );
114 return SetSystemTimer( WIN_Handle32(hwnd), id, timeout, proc32 );
118 /**************************************************************************
119 * KillTimer (USER.12)
121 BOOL16 WINAPI KillTimer16( HWND16 hwnd, UINT16 id )
123 return KillTimer( WIN_Handle32(hwnd), id );
127 /**************************************************************************
128 * SetCapture (USER.18)
130 HWND16 WINAPI SetCapture16( HWND16 hwnd )
132 return HWND_16( SetCapture( WIN_Handle32(hwnd) ));
136 /**************************************************************************
137 * ReleaseCapture (USER.19)
139 BOOL16 WINAPI ReleaseCapture16(void)
141 return ReleaseCapture();
145 /**************************************************************************
146 * SetFocus (USER.22)
148 HWND16 WINAPI SetFocus16( HWND16 hwnd )
150 return HWND_16( SetFocus( WIN_Handle32(hwnd) ));
154 /**************************************************************************
155 * GetFocus (USER.23)
157 HWND16 WINAPI GetFocus16(void)
159 return HWND_16( GetFocus() );
163 /**************************************************************************
164 * RemoveProp (USER.24)
166 HANDLE16 WINAPI RemoveProp16( HWND16 hwnd, LPCSTR str )
168 return HANDLE_16(RemovePropA( WIN_Handle32(hwnd), str ));
172 /**************************************************************************
173 * GetProp (USER.25)
175 HANDLE16 WINAPI GetProp16( HWND16 hwnd, LPCSTR str )
177 return HANDLE_16(GetPropA( WIN_Handle32(hwnd), str ));
181 /**************************************************************************
182 * SetProp (USER.26)
184 BOOL16 WINAPI SetProp16( HWND16 hwnd, LPCSTR str, HANDLE16 handle )
186 return SetPropA( WIN_Handle32(hwnd), str, HANDLE_32(handle) );
190 /***********************************************************************
191 * EnumProps (USER.27)
193 INT16 WINAPI EnumProps16( HWND16 hwnd, PROPENUMPROC16 func )
195 int ret = -1, i, count, total = 32;
196 property_data_t *list;
198 while (total)
200 if (!(list = HeapAlloc( GetProcessHeap(), 0, total * sizeof(*list) ))) break;
201 count = 0;
202 SERVER_START_REQ( get_window_properties )
204 req->window = wine_server_user_handle( HWND_32(hwnd) );
205 wine_server_set_reply( req, list, total * sizeof(*list) );
206 if (!wine_server_call( req )) count = reply->total;
208 SERVER_END_REQ;
210 if (count && count <= total)
212 char string[ATOM_BUFFER_SIZE];
213 SEGPTR segptr = MapLS( string );
214 WORD args[4];
215 DWORD result;
217 for (i = 0; i < count; i++)
219 if (list[i].string) /* it was a string originally */
221 if (!GlobalGetAtomNameA( list[i].atom, string, ATOM_BUFFER_SIZE )) continue;
222 args[3] = hwnd;
223 args[2] = SELECTOROF(segptr);
224 args[1] = OFFSETOF(segptr);
225 args[0] = LOWORD(list[i].data);
227 else
229 args[3] = hwnd;
230 args[2] = 0;
231 args[1] = list[i].atom;
232 args[0] = LOWORD(list[i].data);
234 WOWCallback16Ex( (DWORD)func, WCB16_PASCAL, sizeof(args), args, &result );
235 if (!(ret = LOWORD(result))) break;
237 UnMapLS( segptr );
238 HeapFree( GetProcessHeap(), 0, list );
239 break;
241 HeapFree( GetProcessHeap(), 0, list );
242 total = count; /* restart with larger buffer */
244 return ret;
248 /**************************************************************************
249 * ClientToScreen (USER.28)
251 void WINAPI ClientToScreen16( HWND16 hwnd, LPPOINT16 lppnt )
253 MapWindowPoints16( hwnd, 0, lppnt, 1 );
257 /**************************************************************************
258 * ScreenToClient (USER.29)
260 void WINAPI ScreenToClient16( HWND16 hwnd, LPPOINT16 lppnt )
262 MapWindowPoints16( 0, hwnd, lppnt, 1 );
266 /**************************************************************************
267 * WindowFromPoint (USER.30)
269 HWND16 WINAPI WindowFromPoint16( POINT16 pt )
271 POINT pt32;
273 pt32.x = pt.x;
274 pt32.y = pt.y;
275 return HWND_16( WindowFromPoint( pt32 ) );
279 /**************************************************************************
280 * IsIconic (USER.31)
282 BOOL16 WINAPI IsIconic16(HWND16 hwnd)
284 return IsIconic( WIN_Handle32(hwnd) );
288 /**************************************************************************
289 * GetWindowRect (USER.32)
291 void WINAPI GetWindowRect16( HWND16 hwnd, LPRECT16 rect )
293 RECT rect32;
295 GetWindowRect( WIN_Handle32(hwnd), &rect32 );
296 rect->left = rect32.left;
297 rect->top = rect32.top;
298 rect->right = rect32.right;
299 rect->bottom = rect32.bottom;
303 /**************************************************************************
304 * GetClientRect (USER.33)
306 void WINAPI GetClientRect16( HWND16 hwnd, LPRECT16 rect )
308 RECT rect32;
310 GetClientRect( WIN_Handle32(hwnd), &rect32 );
311 rect->left = rect32.left;
312 rect->top = rect32.top;
313 rect->right = rect32.right;
314 rect->bottom = rect32.bottom;
318 /**************************************************************************
319 * EnableWindow (USER.34)
321 BOOL16 WINAPI EnableWindow16( HWND16 hwnd, BOOL16 enable )
323 return EnableWindow( WIN_Handle32(hwnd), enable );
327 /**************************************************************************
328 * IsWindowEnabled (USER.35)
330 BOOL16 WINAPI IsWindowEnabled16(HWND16 hwnd)
332 return IsWindowEnabled( WIN_Handle32(hwnd) );
336 /**************************************************************************
337 * GetWindowText (USER.36)
339 INT16 WINAPI GetWindowText16( HWND16 hwnd, SEGPTR lpString, INT16 nMaxCount )
341 return SendMessage16( hwnd, WM_GETTEXT, nMaxCount, lpString );
345 /**************************************************************************
346 * SetWindowText (USER.37)
348 BOOL16 WINAPI SetWindowText16( HWND16 hwnd, SEGPTR lpString )
350 return SendMessage16( hwnd, WM_SETTEXT, 0, lpString );
354 /**************************************************************************
355 * GetWindowTextLength (USER.38)
357 INT16 WINAPI GetWindowTextLength16( HWND16 hwnd )
359 return SendMessage16( hwnd, WM_GETTEXTLENGTH, 0, 0 );
363 /***********************************************************************
364 * BeginPaint (USER.39)
366 HDC16 WINAPI BeginPaint16( HWND16 hwnd, LPPAINTSTRUCT16 lps )
368 PAINTSTRUCT ps;
370 BeginPaint( WIN_Handle32(hwnd), &ps );
371 lps->hdc = HDC_16(ps.hdc);
372 lps->fErase = ps.fErase;
373 lps->rcPaint.top = ps.rcPaint.top;
374 lps->rcPaint.left = ps.rcPaint.left;
375 lps->rcPaint.right = ps.rcPaint.right;
376 lps->rcPaint.bottom = ps.rcPaint.bottom;
377 lps->fRestore = ps.fRestore;
378 lps->fIncUpdate = ps.fIncUpdate;
379 return lps->hdc;
383 /***********************************************************************
384 * EndPaint (USER.40)
386 BOOL16 WINAPI EndPaint16( HWND16 hwnd, const PAINTSTRUCT16* lps )
388 PAINTSTRUCT ps;
390 ps.hdc = HDC_32(lps->hdc);
391 return EndPaint( WIN_Handle32(hwnd), &ps );
395 /***********************************************************************
396 * CreateWindow (USER.41)
398 HWND16 WINAPI CreateWindow16( LPCSTR className, LPCSTR windowName,
399 DWORD style, INT16 x, INT16 y, INT16 width,
400 INT16 height, HWND16 parent, HMENU16 menu,
401 HINSTANCE16 instance, LPVOID data )
403 return CreateWindowEx16( 0, className, windowName, style,
404 x, y, width, height, parent, menu, instance, data );
408 /**************************************************************************
409 * ShowWindow (USER.42)
411 BOOL16 WINAPI ShowWindow16( HWND16 hwnd, INT16 cmd )
413 return ShowWindow( WIN_Handle32(hwnd), cmd );
417 /**************************************************************************
418 * CloseWindow (USER.43)
420 BOOL16 WINAPI CloseWindow16( HWND16 hwnd )
422 return CloseWindow( WIN_Handle32(hwnd) );
426 /**************************************************************************
427 * OpenIcon (USER.44)
429 BOOL16 WINAPI OpenIcon16( HWND16 hwnd )
431 return OpenIcon( WIN_Handle32(hwnd) );
435 /**************************************************************************
436 * BringWindowToTop (USER.45)
438 BOOL16 WINAPI BringWindowToTop16( HWND16 hwnd )
440 return BringWindowToTop( WIN_Handle32(hwnd) );
444 /**************************************************************************
445 * GetParent (USER.46)
447 HWND16 WINAPI GetParent16( HWND16 hwnd )
449 return HWND_16( GetParent( WIN_Handle32(hwnd) ));
453 /**************************************************************************
454 * IsWindow (USER.47)
456 BOOL16 WINAPI IsWindow16( HWND16 hwnd )
458 STACK16FRAME *frame = MapSL( (SEGPTR)NtCurrentTeb()->WOW32Reserved );
459 frame->es = USER_HeapSel;
460 /* don't use WIN_Handle32 here, we don't care about the full handle */
461 return IsWindow( HWND_32(hwnd) );
465 /**************************************************************************
466 * IsChild (USER.48)
468 BOOL16 WINAPI IsChild16( HWND16 parent, HWND16 child )
470 return IsChild( WIN_Handle32(parent), WIN_Handle32(child) );
474 /**************************************************************************
475 * IsWindowVisible (USER.49)
477 BOOL16 WINAPI IsWindowVisible16( HWND16 hwnd )
479 return IsWindowVisible( WIN_Handle32(hwnd) );
483 /**************************************************************************
484 * FindWindow (USER.50)
486 HWND16 WINAPI FindWindow16( LPCSTR className, LPCSTR title )
488 return HWND_16( FindWindowA( className, title ));
492 /**************************************************************************
493 * DestroyWindow (USER.53)
495 BOOL16 WINAPI DestroyWindow16( HWND16 hwnd )
497 return DestroyWindow( WIN_Handle32(hwnd) );
501 /*******************************************************************
502 * EnumWindows (USER.54)
504 BOOL16 WINAPI EnumWindows16( WNDENUMPROC16 func, LPARAM lParam )
506 struct wnd_enum_info info;
508 info.proc = func;
509 info.param = lParam;
510 return EnumWindows( wnd_enum_callback, (LPARAM)&info );
514 /**********************************************************************
515 * EnumChildWindows (USER.55)
517 BOOL16 WINAPI EnumChildWindows16( HWND16 parent, WNDENUMPROC16 func, LPARAM lParam )
519 struct wnd_enum_info info;
521 info.proc = func;
522 info.param = lParam;
523 return EnumChildWindows( WIN_Handle32(parent), wnd_enum_callback, (LPARAM)&info );
527 /**************************************************************************
528 * MoveWindow (USER.56)
530 BOOL16 WINAPI MoveWindow16( HWND16 hwnd, INT16 x, INT16 y, INT16 cx, INT16 cy, BOOL16 repaint )
532 return MoveWindow( WIN_Handle32(hwnd), x, y, cx, cy, repaint );
536 /***********************************************************************
537 * RegisterClass (USER.57)
539 ATOM WINAPI RegisterClass16( const WNDCLASS16 *wc )
541 WNDCLASSEX16 wcex;
543 wcex.cbSize = sizeof(wcex);
544 wcex.style = wc->style;
545 wcex.lpfnWndProc = wc->lpfnWndProc;
546 wcex.cbClsExtra = wc->cbClsExtra;
547 wcex.cbWndExtra = wc->cbWndExtra;
548 wcex.hInstance = wc->hInstance;
549 wcex.hIcon = wc->hIcon;
550 wcex.hCursor = wc->hCursor;
551 wcex.hbrBackground = wc->hbrBackground;
552 wcex.lpszMenuName = wc->lpszMenuName;
553 wcex.lpszClassName = wc->lpszClassName;
554 wcex.hIconSm = 0;
555 return RegisterClassEx16( &wcex );
559 /**************************************************************************
560 * GetClassName (USER.58)
562 INT16 WINAPI GetClassName16( HWND16 hwnd, LPSTR buffer, INT16 count )
564 return GetClassNameA( WIN_Handle32(hwnd), buffer, count );
568 /**************************************************************************
569 * SetActiveWindow (USER.59)
571 HWND16 WINAPI SetActiveWindow16( HWND16 hwnd )
573 return HWND_16( SetActiveWindow( WIN_Handle32(hwnd) ));
577 /**************************************************************************
578 * GetActiveWindow (USER.60)
580 HWND16 WINAPI GetActiveWindow16(void)
582 return HWND_16( GetActiveWindow() );
586 /**************************************************************************
587 * ScrollWindow (USER.61)
589 void WINAPI ScrollWindow16( HWND16 hwnd, INT16 dx, INT16 dy, const RECT16 *rect,
590 const RECT16 *clipRect )
592 RECT rect32, clipRect32;
594 if (rect)
596 rect32.left = rect->left;
597 rect32.top = rect->top;
598 rect32.right = rect->right;
599 rect32.bottom = rect->bottom;
601 if (clipRect)
603 clipRect32.left = clipRect->left;
604 clipRect32.top = clipRect->top;
605 clipRect32.right = clipRect->right;
606 clipRect32.bottom = clipRect->bottom;
608 ScrollWindow( WIN_Handle32(hwnd), dx, dy, rect ? &rect32 : NULL,
609 clipRect ? &clipRect32 : NULL );
613 /**************************************************************************
614 * SetScrollPos (USER.62)
616 INT16 WINAPI SetScrollPos16( HWND16 hwnd, INT16 nBar, INT16 nPos, BOOL16 redraw )
618 return SetScrollPos( WIN_Handle32(hwnd), nBar, nPos, redraw );
622 /**************************************************************************
623 * GetScrollPos (USER.63)
625 INT16 WINAPI GetScrollPos16( HWND16 hwnd, INT16 nBar )
627 return GetScrollPos( WIN_Handle32(hwnd), nBar );
631 /**************************************************************************
632 * SetScrollRange (USER.64)
634 void WINAPI SetScrollRange16( HWND16 hwnd, INT16 nBar, INT16 MinVal, INT16 MaxVal, BOOL16 redraw )
636 /* Invalid range -> range is set to (0,0) */
637 if ((INT)MaxVal - (INT)MinVal > 0x7fff) MinVal = MaxVal = 0;
638 SetScrollRange( WIN_Handle32(hwnd), nBar, MinVal, MaxVal, redraw );
642 /**************************************************************************
643 * GetScrollRange (USER.65)
645 BOOL16 WINAPI GetScrollRange16( HWND16 hwnd, INT16 nBar, LPINT16 lpMin, LPINT16 lpMax)
647 INT min, max;
648 BOOL ret = GetScrollRange( WIN_Handle32(hwnd), nBar, &min, &max );
649 if (lpMin) *lpMin = min;
650 if (lpMax) *lpMax = max;
651 return ret;
655 /**************************************************************************
656 * GetDC (USER.66)
658 HDC16 WINAPI GetDC16( HWND16 hwnd )
660 return HDC_16(GetDC( WIN_Handle32(hwnd) ));
664 /**************************************************************************
665 * GetWindowDC (USER.67)
667 HDC16 WINAPI GetWindowDC16( HWND16 hwnd )
669 return GetDCEx16( hwnd, 0, DCX_USESTYLE | DCX_WINDOW );
673 /**************************************************************************
674 * ReleaseDC (USER.68)
676 INT16 WINAPI ReleaseDC16( HWND16 hwnd, HDC16 hdc )
678 return (INT16)ReleaseDC( WIN_Handle32(hwnd), HDC_32(hdc) );
682 /**************************************************************************
683 * FlashWindow (USER.105)
685 BOOL16 WINAPI FlashWindow16( HWND16 hwnd, BOOL16 bInvert )
687 return FlashWindow( WIN_Handle32(hwnd), bInvert );
691 /**************************************************************************
692 * WindowFromDC (USER.117)
694 HWND16 WINAPI WindowFromDC16( HDC16 hDC )
696 return HWND_16( WindowFromDC( HDC_32(hDC) ) );
700 /**************************************************************************
701 * UpdateWindow (USER.124)
703 void WINAPI UpdateWindow16( HWND16 hwnd )
705 RedrawWindow16( hwnd, NULL, 0, RDW_UPDATENOW | RDW_ALLCHILDREN );
709 /**************************************************************************
710 * InvalidateRect (USER.125)
712 void WINAPI InvalidateRect16( HWND16 hwnd, const RECT16 *rect, BOOL16 erase )
714 RedrawWindow16( hwnd, rect, 0, RDW_INVALIDATE | (erase ? RDW_ERASE : 0) );
718 /**************************************************************************
719 * InvalidateRgn (USER.126)
721 void WINAPI InvalidateRgn16( HWND16 hwnd, HRGN16 hrgn, BOOL16 erase )
723 RedrawWindow16( hwnd, NULL, hrgn, RDW_INVALIDATE | (erase ? RDW_ERASE : 0) );
727 /**************************************************************************
728 * ValidateRect (USER.127)
730 void WINAPI ValidateRect16( HWND16 hwnd, const RECT16 *rect )
732 RedrawWindow16( hwnd, rect, 0, RDW_VALIDATE | RDW_NOCHILDREN );
736 /**************************************************************************
737 * ValidateRgn (USER.128)
739 void WINAPI ValidateRgn16( HWND16 hwnd, HRGN16 hrgn )
741 RedrawWindow16( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOCHILDREN );
745 /**************************************************************************
746 * GetClassWord (USER.129)
748 WORD WINAPI GetClassWord16( HWND16 hwnd, INT16 offset )
750 HICON icon;
752 switch (offset)
754 case GCLP_HCURSOR:
755 case GCLP_HICON:
756 case GCLP_HICONSM:
757 icon = (HICON)GetClassLongPtrW( WIN_Handle32(hwnd), offset );
758 return get_icon_16( icon );
760 return GetClassWord( WIN_Handle32(hwnd), offset );
764 /**************************************************************************
765 * SetClassWord (USER.130)
767 WORD WINAPI SetClassWord16( HWND16 hwnd, INT16 offset, WORD newval )
769 HICON icon;
771 switch (offset)
773 case GCLP_HCURSOR:
774 case GCLP_HICON:
775 case GCLP_HICONSM:
776 icon = (HICON)SetClassLongPtrW( WIN_Handle32(hwnd), offset, (ULONG_PTR)get_icon_32(newval) );
777 return get_icon_16( icon );
779 return SetClassWord( WIN_Handle32(hwnd), offset, newval );
783 /***********************************************************************
784 * GetClassLong (USER.131)
786 LONG WINAPI GetClassLong16( HWND16 hwnd16, INT16 offset )
788 LONG_PTR ret = GetClassLongA( WIN_Handle32(hwnd16), offset );
790 switch( offset )
792 case GCLP_WNDPROC:
793 return (LONG_PTR)WINPROC_GetProc16( (WNDPROC)ret, FALSE );
794 case GCLP_MENUNAME:
795 return MapLS( (void *)ret ); /* leak */
796 case GCLP_HCURSOR:
797 case GCLP_HICON:
798 case GCLP_HICONSM:
799 return get_icon_16( (HICON)ret );
800 default:
801 return ret;
806 /***********************************************************************
807 * SetClassLong (USER.132)
809 LONG WINAPI SetClassLong16( HWND16 hwnd16, INT16 offset, LONG newval )
811 HICON icon;
813 switch( offset )
815 case GCLP_HCURSOR:
816 case GCLP_HICON:
817 case GCLP_HICONSM:
818 icon = (HICON)SetClassLongPtrW( WIN_Handle32(hwnd16), offset, (ULONG_PTR)get_icon_32(newval) );
819 return get_icon_16( icon );
820 case GCLP_WNDPROC:
822 WNDPROC new_proc = WINPROC_AllocProc16( (WNDPROC16)newval );
823 WNDPROC old_proc = (WNDPROC)SetClassLongA( WIN_Handle32(hwnd16), offset, (LONG_PTR)new_proc );
824 return (LONG)WINPROC_GetProc16( old_proc, FALSE );
826 case GCLP_MENUNAME:
827 newval = (LONG)MapSL( newval );
828 /* fall through */
829 default:
830 return SetClassLongA( WIN_Handle32(hwnd16), offset, newval );
835 /**************************************************************************
836 * GetWindowWord (USER.133)
838 WORD WINAPI GetWindowWord16( HWND16 hwnd, INT16 offset )
840 return GetWindowWord( WIN_Handle32(hwnd), offset );
844 /**************************************************************************
845 * SetWindowWord (USER.134)
847 WORD WINAPI SetWindowWord16( HWND16 hwnd, INT16 offset, WORD newval )
849 return SetWindowWord( WIN_Handle32(hwnd), offset, newval );
853 /**********************************************************************
854 * GetWindowLong (USER.135)
856 LONG WINAPI GetWindowLong16( HWND16 hwnd16, INT16 offset )
858 HWND hwnd = WIN_Handle32( hwnd16 );
859 LONG_PTR retvalue;
860 BOOL is_winproc = (offset == GWLP_WNDPROC);
862 if (offset >= 0)
864 int cbWndExtra = GetClassLongA( hwnd, GCL_CBWNDEXTRA );
866 if (offset > (int)(cbWndExtra - sizeof(LONG)))
869 * Some programs try to access last element from 16 bit
870 * code using illegal offset value. Hopefully this is
871 * what those programs really expect.
873 if (cbWndExtra >= 4 && offset == cbWndExtra - sizeof(WORD))
875 offset = cbWndExtra - sizeof(LONG);
877 else
879 SetLastError( ERROR_INVALID_INDEX );
880 return 0;
883 else if (offset == DWLP_DLGPROC)
884 is_winproc = (wow_handlers32.get_dialog_info( hwnd, FALSE ) != NULL);
886 retvalue = GetWindowLongA( hwnd, offset );
887 if (is_winproc) retvalue = (LONG_PTR)WINPROC_GetProc16( (WNDPROC)retvalue, FALSE );
888 return retvalue;
892 /**********************************************************************
893 * SetWindowLong (USER.136)
895 LONG WINAPI SetWindowLong16( HWND16 hwnd16, INT16 offset, LONG newval )
897 HWND hwnd = WIN_Handle32( hwnd16 );
898 BOOL is_winproc = (offset == GWLP_WNDPROC);
900 if (offset == DWLP_DLGPROC)
901 is_winproc = (wow_handlers32.get_dialog_info( hwnd, FALSE ) != NULL);
903 if (is_winproc)
905 WNDPROC new_proc = WINPROC_AllocProc16( (WNDPROC16)newval );
906 WNDPROC old_proc = (WNDPROC)SetWindowLongPtrA( hwnd, offset, (LONG_PTR)new_proc );
907 return (LONG)WINPROC_GetProc16( old_proc, FALSE );
909 else return SetWindowLongA( hwnd, offset, newval );
913 /**************************************************************************
914 * OpenClipboard (USER.137)
916 BOOL16 WINAPI OpenClipboard16( HWND16 hwnd )
918 return OpenClipboard( WIN_Handle32(hwnd) );
922 /**************************************************************************
923 * GetClipboardOwner (USER.140)
925 HWND16 WINAPI GetClipboardOwner16(void)
927 return HWND_16( GetClipboardOwner() );
931 /**************************************************************************
932 * SetClipboardViewer (USER.147)
934 HWND16 WINAPI SetClipboardViewer16( HWND16 hwnd )
936 return HWND_16( SetClipboardViewer( WIN_Handle32(hwnd) ));
940 /**************************************************************************
941 * GetClipboardViewer (USER.148)
943 HWND16 WINAPI GetClipboardViewer16(void)
945 return HWND_16( GetClipboardViewer() );
949 /**************************************************************************
950 * ChangeClipboardChain (USER.149)
952 BOOL16 WINAPI ChangeClipboardChain16(HWND16 hwnd, HWND16 hwndNext)
954 return ChangeClipboardChain( WIN_Handle32(hwnd), WIN_Handle32(hwndNext) );
958 /**************************************************************************
959 * GetSystemMenu (USER.156)
961 HMENU16 WINAPI GetSystemMenu16( HWND16 hwnd, BOOL16 revert )
963 return HMENU_16(GetSystemMenu( WIN_Handle32(hwnd), revert ));
967 /**************************************************************************
968 * GetMenu (USER.157)
970 HMENU16 WINAPI GetMenu16( HWND16 hwnd )
972 return HMENU_16(GetMenu( WIN_Handle32(hwnd) ));
976 /**************************************************************************
977 * SetMenu (USER.158)
979 BOOL16 WINAPI SetMenu16( HWND16 hwnd, HMENU16 hMenu )
981 return SetMenu( WIN_Handle32(hwnd), HMENU_32(hMenu) );
985 /**************************************************************************
986 * DrawMenuBar (USER.160)
988 void WINAPI DrawMenuBar16( HWND16 hwnd )
990 DrawMenuBar( WIN_Handle32(hwnd) );
994 /**************************************************************************
995 * HiliteMenuItem (USER.162)
997 BOOL16 WINAPI HiliteMenuItem16( HWND16 hwnd, HMENU16 hMenu, UINT16 id, UINT16 wHilite )
999 return HiliteMenuItem( WIN_Handle32(hwnd), HMENU_32(hMenu), id, wHilite );
1003 /**************************************************************************
1004 * CreateCaret (USER.163)
1006 void WINAPI CreateCaret16( HWND16 hwnd, HBITMAP16 bitmap, INT16 width, INT16 height )
1008 CreateCaret( WIN_Handle32(hwnd), HBITMAP_32(bitmap), width, height );
1012 /*****************************************************************
1013 * DestroyCaret (USER.164)
1015 void WINAPI DestroyCaret16(void)
1017 DestroyCaret();
1021 /*****************************************************************
1022 * SetCaretPos (USER.165)
1024 void WINAPI SetCaretPos16( INT16 x, INT16 y )
1026 SetCaretPos( x, y );
1030 /**************************************************************************
1031 * HideCaret (USER.166)
1033 void WINAPI HideCaret16( HWND16 hwnd )
1035 HideCaret( WIN_Handle32(hwnd) );
1039 /**************************************************************************
1040 * ShowCaret (USER.167)
1042 void WINAPI ShowCaret16( HWND16 hwnd )
1044 ShowCaret( WIN_Handle32(hwnd) );
1048 /*****************************************************************
1049 * SetCaretBlinkTime (USER.168)
1051 void WINAPI SetCaretBlinkTime16( UINT16 msecs )
1053 SetCaretBlinkTime( msecs );
1057 /*****************************************************************
1058 * GetCaretBlinkTime (USER.169)
1060 UINT16 WINAPI GetCaretBlinkTime16(void)
1062 return GetCaretBlinkTime();
1066 /**************************************************************************
1067 * ArrangeIconicWindows (USER.170)
1069 UINT16 WINAPI ArrangeIconicWindows16( HWND16 parent)
1071 return ArrangeIconicWindows( WIN_Handle32(parent) );
1075 /**************************************************************************
1076 * SwitchToThisWindow (USER.172)
1078 void WINAPI SwitchToThisWindow16( HWND16 hwnd, BOOL16 restore )
1080 SwitchToThisWindow( WIN_Handle32(hwnd), restore );
1084 /**************************************************************************
1085 * KillSystemTimer (USER.182)
1087 BOOL16 WINAPI KillSystemTimer16( HWND16 hwnd, UINT16 id )
1089 return KillSystemTimer( WIN_Handle32(hwnd), id );
1093 /*****************************************************************
1094 * GetCaretPos (USER.183)
1096 void WINAPI GetCaretPos16( LPPOINT16 pt16 )
1098 POINT pt;
1099 if (GetCaretPos( &pt ))
1101 pt16->x = pt.x;
1102 pt16->y = pt.y;
1107 /**************************************************************************
1108 * SetSysModalWindow (USER.188)
1110 HWND16 WINAPI SetSysModalWindow16( HWND16 hwnd )
1112 HWND16 old = hwndSysModal;
1113 hwndSysModal = hwnd;
1114 return old;
1118 /**************************************************************************
1119 * GetSysModalWindow (USER.189)
1121 HWND16 WINAPI GetSysModalWindow16(void)
1123 return hwndSysModal;
1127 /**************************************************************************
1128 * GetUpdateRect (USER.190)
1130 BOOL16 WINAPI GetUpdateRect16( HWND16 hwnd, LPRECT16 rect, BOOL16 erase )
1132 RECT r;
1133 BOOL16 ret;
1135 if (!rect) return GetUpdateRect( WIN_Handle32(hwnd), NULL, erase );
1136 ret = GetUpdateRect( WIN_Handle32(hwnd), &r, erase );
1137 rect->left = r.left;
1138 rect->top = r.top;
1139 rect->right = r.right;
1140 rect->bottom = r.bottom;
1141 return ret;
1145 /**************************************************************************
1146 * ChildWindowFromPoint (USER.191)
1148 HWND16 WINAPI ChildWindowFromPoint16( HWND16 hwndParent, POINT16 pt )
1150 POINT pt32;
1152 pt32.x = pt.x;
1153 pt32.y = pt.y;
1154 return HWND_16( ChildWindowFromPoint( WIN_Handle32(hwndParent), pt32 ));
1158 /***********************************************************************
1159 * CascadeChildWindows (USER.198)
1161 void WINAPI CascadeChildWindows16( HWND16 parent, WORD action )
1163 CascadeWindows( WIN_Handle32(parent), action, NULL, 0, NULL );
1167 /***********************************************************************
1168 * TileChildWindows (USER.199)
1170 void WINAPI TileChildWindows16( HWND16 parent, WORD action )
1172 TileWindows( WIN_Handle32(parent), action, NULL, 0, NULL );
1176 /***********************************************************************
1177 * GetWindowTask (USER.224)
1179 HTASK16 WINAPI GetWindowTask16( HWND16 hwnd )
1181 DWORD tid = GetWindowThreadProcessId( HWND_32(hwnd), NULL );
1182 if (!tid) return 0;
1183 return HTASK_16(tid);
1186 /**********************************************************************
1187 * EnumTaskWindows (USER.225)
1189 BOOL16 WINAPI EnumTaskWindows16( HTASK16 hTask, WNDENUMPROC16 func, LPARAM lParam )
1191 struct wnd_enum_info info;
1192 DWORD tid = HTASK_32( hTask );
1194 if (!tid) return FALSE;
1195 info.proc = func;
1196 info.param = lParam;
1197 return EnumThreadWindows( tid, wnd_enum_callback, (LPARAM)&info );
1201 /**************************************************************************
1202 * GetTopWindow (USER.229)
1204 HWND16 WINAPI GetTopWindow16( HWND16 hwnd )
1206 return HWND_16( GetTopWindow( WIN_Handle32(hwnd) ));
1210 /**************************************************************************
1211 * GetNextWindow (USER.230)
1213 HWND16 WINAPI GetNextWindow16( HWND16 hwnd, WORD flag )
1215 if ((flag != GW_HWNDNEXT) && (flag != GW_HWNDPREV)) return 0;
1216 return GetWindow16( hwnd, flag );
1220 /**************************************************************************
1221 * SetWindowPos (USER.232)
1223 BOOL16 WINAPI SetWindowPos16( HWND16 hwnd, HWND16 hwndInsertAfter,
1224 INT16 x, INT16 y, INT16 cx, INT16 cy, WORD flags)
1226 return SetWindowPos( WIN_Handle32(hwnd), full_insert_after_hwnd(hwndInsertAfter),
1227 x, y, cx, cy, flags );
1231 /**************************************************************************
1232 * SetParent (USER.233)
1234 HWND16 WINAPI SetParent16( HWND16 hwndChild, HWND16 hwndNewParent )
1236 return HWND_16( SetParent( WIN_Handle32(hwndChild), WIN_Handle32(hwndNewParent) ));
1240 /**************************************************************************
1241 * GetCapture (USER.236)
1243 HWND16 WINAPI GetCapture16(void)
1245 return HWND_16( GetCapture() );
1249 /**************************************************************************
1250 * GetUpdateRgn (USER.237)
1252 INT16 WINAPI GetUpdateRgn16( HWND16 hwnd, HRGN16 hrgn, BOOL16 erase )
1254 return GetUpdateRgn( WIN_Handle32(hwnd), HRGN_32(hrgn), erase );
1258 /**************************************************************************
1259 * ExcludeUpdateRgn (USER.238)
1261 INT16 WINAPI ExcludeUpdateRgn16( HDC16 hdc, HWND16 hwnd )
1263 return ExcludeUpdateRgn( HDC_32(hdc), WIN_Handle32(hwnd) );
1267 /**************************************************************************
1268 * GetOpenClipboardWindow (USER.248)
1270 HWND16 WINAPI GetOpenClipboardWindow16(void)
1272 return HWND_16( GetOpenClipboardWindow() );
1276 /*******************************************************************
1277 * MapWindowPoints (USER.258)
1279 void WINAPI MapWindowPoints16( HWND16 hwndFrom, HWND16 hwndTo, LPPOINT16 lppt, UINT16 count )
1281 POINT buffer[8], *ppt = buffer;
1282 UINT i;
1284 if (count > 8) ppt = HeapAlloc( GetProcessHeap(), 0, count * sizeof(*ppt) );
1285 for (i = 0; i < count; i++)
1287 ppt[i].x = lppt[i].x;
1288 ppt[i].y = lppt[i].y;
1290 MapWindowPoints( WIN_Handle32(hwndFrom), WIN_Handle32(hwndTo), ppt, count );
1291 for (i = 0; i < count; i++)
1293 lppt[i].x = ppt[i].x;
1294 lppt[i].y = ppt[i].y;
1296 if (ppt != buffer) HeapFree( GetProcessHeap(), 0, ppt );
1300 /**************************************************************************
1301 * BeginDeferWindowPos (USER.259)
1303 HDWP16 WINAPI BeginDeferWindowPos16( INT16 count )
1305 return HDWP_16(BeginDeferWindowPos( count ));
1309 /**************************************************************************
1310 * DeferWindowPos (USER.260)
1312 HDWP16 WINAPI DeferWindowPos16( HDWP16 hdwp, HWND16 hwnd, HWND16 hwndAfter,
1313 INT16 x, INT16 y, INT16 cx, INT16 cy,
1314 UINT16 flags )
1316 return HDWP_16(DeferWindowPos( HDWP_32(hdwp), WIN_Handle32(hwnd),
1317 full_insert_after_hwnd(hwndAfter), x, y, cx, cy, flags ));
1321 /**************************************************************************
1322 * EndDeferWindowPos (USER.261)
1324 BOOL16 WINAPI EndDeferWindowPos16( HDWP16 hdwp )
1326 return EndDeferWindowPos(HDWP_32(hdwp));
1330 /**************************************************************************
1331 * GetWindow (USER.262)
1333 HWND16 WINAPI GetWindow16( HWND16 hwnd, WORD rel )
1335 return HWND_16( GetWindow( WIN_Handle32(hwnd), rel ) );
1339 /**************************************************************************
1340 * ShowOwnedPopups (USER.265)
1342 void WINAPI ShowOwnedPopups16( HWND16 owner, BOOL16 fShow )
1344 ShowOwnedPopups( WIN_Handle32(owner), fShow );
1348 /**************************************************************************
1349 * ShowScrollBar (USER.267)
1351 void WINAPI ShowScrollBar16( HWND16 hwnd, INT16 nBar, BOOL16 fShow )
1353 ShowScrollBar( WIN_Handle32(hwnd), nBar, fShow );
1357 /**************************************************************************
1358 * IsZoomed (USER.272)
1360 BOOL16 WINAPI IsZoomed16(HWND16 hwnd)
1362 return IsZoomed( WIN_Handle32(hwnd) );
1366 /**************************************************************************
1367 * GetDlgCtrlID (USER.277)
1369 INT16 WINAPI GetDlgCtrlID16( HWND16 hwnd )
1371 return GetDlgCtrlID( WIN_Handle32(hwnd) );
1375 /**************************************************************************
1376 * GetDesktopHwnd (USER.278)
1378 * Exactly the same thing as GetDesktopWindow(), but not documented.
1379 * Don't ask me why...
1381 HWND16 WINAPI GetDesktopHwnd16(void)
1383 return GetDesktopWindow16();
1387 /**************************************************************************
1388 * SetSystemMenu (USER.280)
1390 BOOL16 WINAPI SetSystemMenu16( HWND16 hwnd, HMENU16 hMenu )
1392 return SetSystemMenu( WIN_Handle32(hwnd), HMENU_32(hMenu) );
1396 /**************************************************************************
1397 * GetDesktopWindow (USER.286)
1399 HWND16 WINAPI GetDesktopWindow16(void)
1401 return HWND_16( GetDesktopWindow() );
1405 /**************************************************************************
1406 * GetLastActivePopup (USER.287)
1408 HWND16 WINAPI GetLastActivePopup16( HWND16 hwnd )
1410 return HWND_16( GetLastActivePopup( WIN_Handle32(hwnd) ));
1414 /**************************************************************************
1415 * RedrawWindow (USER.290)
1417 BOOL16 WINAPI RedrawWindow16( HWND16 hwnd, const RECT16 *rectUpdate,
1418 HRGN16 hrgnUpdate, UINT16 flags )
1420 if (rectUpdate)
1422 RECT r;
1423 r.left = rectUpdate->left;
1424 r.top = rectUpdate->top;
1425 r.right = rectUpdate->right;
1426 r.bottom = rectUpdate->bottom;
1427 return RedrawWindow(WIN_Handle32(hwnd), &r, HRGN_32(hrgnUpdate), flags);
1429 return RedrawWindow(WIN_Handle32(hwnd), NULL, HRGN_32(hrgnUpdate), flags);
1433 /**************************************************************************
1434 * LockWindowUpdate (USER.294)
1436 BOOL16 WINAPI LockWindowUpdate16( HWND16 hwnd )
1438 return LockWindowUpdate( WIN_Handle32(hwnd) );
1442 /**************************************************************************
1443 * ScrollWindowEx (USER.319)
1445 INT16 WINAPI ScrollWindowEx16( HWND16 hwnd, INT16 dx, INT16 dy,
1446 const RECT16 *rect, const RECT16 *clipRect,
1447 HRGN16 hrgnUpdate, LPRECT16 rcUpdate,
1448 UINT16 flags )
1450 RECT rect32, clipRect32, rcUpdate32;
1451 BOOL16 ret;
1453 if (rect)
1455 rect32.left = rect->left;
1456 rect32.top = rect->top;
1457 rect32.right = rect->right;
1458 rect32.bottom = rect->bottom;
1460 if (clipRect)
1462 clipRect32.left = clipRect->left;
1463 clipRect32.top = clipRect->top;
1464 clipRect32.right = clipRect->right;
1465 clipRect32.bottom = clipRect->bottom;
1467 ret = ScrollWindowEx( WIN_Handle32(hwnd), dx, dy, rect ? &rect32 : NULL,
1468 clipRect ? &clipRect32 : NULL, HRGN_32(hrgnUpdate),
1469 (rcUpdate) ? &rcUpdate32 : NULL, flags );
1470 if (rcUpdate)
1472 rcUpdate->left = rcUpdate32.left;
1473 rcUpdate->top = rcUpdate32.top;
1474 rcUpdate->right = rcUpdate32.right;
1475 rcUpdate->bottom = rcUpdate32.bottom;
1477 return ret;
1481 /**************************************************************************
1482 * FillWindow (USER.324)
1484 void WINAPI FillWindow16( HWND16 hwndParent, HWND16 hwnd, HDC16 hdc, HBRUSH16 hbrush )
1486 RECT rect;
1487 RECT16 rc16;
1488 GetClientRect( WIN_Handle32(hwnd), &rect );
1489 DPtoLP( HDC_32(hdc), (LPPOINT)&rect, 2 );
1490 rc16.left = rect.left;
1491 rc16.top = rect.top;
1492 rc16.right = rect.right;
1493 rc16.bottom = rect.bottom;
1494 PaintRect16( hwndParent, hwnd, hdc, hbrush, &rc16 );
1498 /**************************************************************************
1499 * PaintRect (USER.325)
1501 void WINAPI PaintRect16( HWND16 hwndParent, HWND16 hwnd, HDC16 hdc,
1502 HBRUSH16 hbrush, const RECT16 *rect)
1504 if (hbrush <= CTLCOLOR_STATIC)
1506 HWND parent = WIN_Handle32(hwndParent), hwnd32 = WIN_Handle32(hwnd);
1508 if (!parent) return;
1509 hbrush = SendMessageW( parent, WM_CTLCOLORMSGBOX + hbrush, hdc, (LPARAM)hwnd32 );
1510 if (!hbrush) hbrush = DefWindowProcW( parent, WM_CTLCOLORMSGBOX + hbrush,
1511 hdc, (LPARAM)hwnd32 );
1513 if (hbrush) FillRect16( hdc, rect, hbrush );
1517 /**************************************************************************
1518 * GetControlBrush (USER.326)
1520 HBRUSH16 WINAPI GetControlBrush16( HWND16 hwnd, HDC16 hdc, UINT16 ctlType )
1522 HBRUSH16 ret;
1523 HWND hwnd32 = WIN_Handle32(hwnd);
1524 HWND parent = GetParent( hwnd32 );
1526 if (!parent) parent = hwnd32;
1527 ret = SendMessageW( parent, WM_CTLCOLORMSGBOX + ctlType, hdc, (LPARAM)hwnd32 );
1528 if (!ret) ret = DefWindowProcW( parent, WM_CTLCOLORMSGBOX + ctlType,
1529 hdc, (LPARAM)hwnd32 );
1530 return ret;
1534 /**************************************************************************
1535 * GetDCEx (USER.359)
1537 HDC16 WINAPI GetDCEx16( HWND16 hwnd, HRGN16 hrgnClip, DWORD flags )
1539 return HDC_16(GetDCEx(WIN_Handle32(hwnd), HRGN_32(hrgnClip), flags));
1543 /**************************************************************************
1544 * GetWindowPlacement (USER.370)
1546 BOOL16 WINAPI GetWindowPlacement16( HWND16 hwnd, WINDOWPLACEMENT16 *wp16 )
1548 WINDOWPLACEMENT wpl;
1550 wpl.length = sizeof(wpl);
1551 if (!GetWindowPlacement( WIN_Handle32(hwnd), &wpl )) return FALSE;
1552 wp16->length = sizeof(*wp16);
1553 wp16->flags = wpl.flags;
1554 wp16->showCmd = wpl.showCmd;
1555 wp16->ptMinPosition.x = wpl.ptMinPosition.x;
1556 wp16->ptMinPosition.y = wpl.ptMinPosition.y;
1557 wp16->ptMaxPosition.x = wpl.ptMaxPosition.x;
1558 wp16->ptMaxPosition.y = wpl.ptMaxPosition.y;
1559 wp16->rcNormalPosition.left = wpl.rcNormalPosition.left;
1560 wp16->rcNormalPosition.top = wpl.rcNormalPosition.top;
1561 wp16->rcNormalPosition.right = wpl.rcNormalPosition.right;
1562 wp16->rcNormalPosition.bottom = wpl.rcNormalPosition.bottom;
1563 return TRUE;
1567 /**************************************************************************
1568 * SetWindowPlacement (USER.371)
1570 BOOL16 WINAPI SetWindowPlacement16( HWND16 hwnd, const WINDOWPLACEMENT16 *wp16 )
1572 WINDOWPLACEMENT wpl;
1574 if (!wp16) return FALSE;
1575 wpl.length = sizeof(wpl);
1576 wpl.flags = wp16->flags;
1577 wpl.showCmd = wp16->showCmd;
1578 wpl.ptMinPosition.x = wp16->ptMinPosition.x;
1579 wpl.ptMinPosition.y = wp16->ptMinPosition.y;
1580 wpl.ptMaxPosition.x = wp16->ptMaxPosition.x;
1581 wpl.ptMaxPosition.y = wp16->ptMaxPosition.y;
1582 wpl.rcNormalPosition.left = wp16->rcNormalPosition.left;
1583 wpl.rcNormalPosition.top = wp16->rcNormalPosition.top;
1584 wpl.rcNormalPosition.right = wp16->rcNormalPosition.right;
1585 wpl.rcNormalPosition.bottom = wp16->rcNormalPosition.bottom;
1586 return SetWindowPlacement( WIN_Handle32(hwnd), &wpl );
1590 /***********************************************************************
1591 * RegisterClassEx (USER.397)
1593 ATOM WINAPI RegisterClassEx16( const WNDCLASSEX16 *wc )
1595 struct class_entry *class;
1596 WNDCLASSEXA wc32;
1597 HINSTANCE16 inst;
1598 ATOM atom;
1600 inst = GetExePtr( wc->hInstance );
1601 if (!inst) inst = GetModuleHandle16( NULL );
1603 wc32.cbSize = sizeof(wc32);
1604 wc32.style = wc->style;
1605 wc32.lpfnWndProc = WINPROC_AllocProc16( wc->lpfnWndProc );
1606 wc32.cbClsExtra = wc->cbClsExtra;
1607 wc32.cbWndExtra = wc->cbWndExtra;
1608 wc32.hInstance = HINSTANCE_32(inst);
1609 wc32.hIcon = get_icon_32(wc->hIcon);
1610 wc32.hCursor = get_icon_32( wc->hCursor );
1611 wc32.hbrBackground = HBRUSH_32(wc->hbrBackground);
1612 wc32.lpszMenuName = MapSL(wc->lpszMenuName);
1613 wc32.lpszClassName = MapSL(wc->lpszClassName);
1614 wc32.hIconSm = get_icon_32(wc->hIconSm);
1615 atom = RegisterClassExA( &wc32 );
1616 if ((class = HeapAlloc( GetProcessHeap(), 0, sizeof(*class) )))
1618 class->atom = atom;
1619 class->inst = inst;
1620 list_add_tail( &class_list, &class->entry );
1622 return atom;
1626 /***********************************************************************
1627 * GetClassInfoEx (USER.398)
1629 * FIXME: this is just a guess, I have no idea if GetClassInfoEx() is the
1630 * same in Win16 as in Win32. --AJ
1632 BOOL16 WINAPI GetClassInfoEx16( HINSTANCE16 hInst16, SEGPTR name, WNDCLASSEX16 *wc )
1634 static HMODULE user32_module;
1635 WNDCLASSEXA wc32;
1636 HINSTANCE hInstance;
1637 BOOL ret;
1639 if (!user32_module) user32_module = GetModuleHandleA( "user32.dll" );
1640 if (hInst16 == GetModuleHandle16("user")) hInstance = user32_module;
1641 else hInstance = HINSTANCE_32(GetExePtr( hInst16 ));
1643 ret = GetClassInfoExA( hInstance, MapSL(name), &wc32 );
1645 if (ret)
1647 wc->lpfnWndProc = WINPROC_GetProc16( wc32.lpfnWndProc, FALSE );
1648 wc->style = wc32.style;
1649 wc->cbClsExtra = wc32.cbClsExtra;
1650 wc->cbWndExtra = wc32.cbWndExtra;
1651 wc->hInstance = (wc32.hInstance == user32_module) ? GetModuleHandle16("user") : HINSTANCE_16(wc32.hInstance);
1652 wc->hIcon = get_icon_16( wc32.hIcon );
1653 wc->hIconSm = get_icon_16( wc32.hIconSm );
1654 wc->hCursor = get_icon_16( wc32.hCursor );
1655 wc->hbrBackground = HBRUSH_16(wc32.hbrBackground);
1656 wc->lpszClassName = 0;
1657 wc->lpszMenuName = MapLS(wc32.lpszMenuName); /* FIXME: leak */
1659 return ret;
1663 /**************************************************************************
1664 * ChildWindowFromPointEx (USER.399)
1666 HWND16 WINAPI ChildWindowFromPointEx16( HWND16 hwndParent, POINT16 pt, UINT16 uFlags)
1668 POINT pt32;
1670 pt32.x = pt.x;
1671 pt32.y = pt.y;
1672 return HWND_16( ChildWindowFromPointEx( WIN_Handle32(hwndParent), pt32, uFlags ));
1676 /**************************************************************************
1677 * GetPriorityClipboardFormat (USER.402)
1679 INT16 WINAPI GetPriorityClipboardFormat16( UINT16 *list, INT16 count )
1681 int i;
1683 for (i = 0; i < count; i++)
1684 if (IsClipboardFormatAvailable( list[i] )) return list[i];
1685 return -1;
1689 /***********************************************************************
1690 * UnregisterClass (USER.403)
1692 BOOL16 WINAPI UnregisterClass16( LPCSTR className, HINSTANCE16 hInstance )
1694 ATOM atom;
1696 if (hInstance == GetModuleHandle16("user")) hInstance = 0;
1697 else hInstance = GetExePtr( hInstance );
1699 if ((atom = GlobalFindAtomA( className )))
1701 struct class_entry *class;
1702 LIST_FOR_EACH_ENTRY( class, &class_list, struct class_entry, entry )
1704 if (class->inst != hInstance) continue;
1705 if (class->atom != atom) continue;
1706 list_remove( &class->entry );
1707 HeapFree( GetProcessHeap(), 0, class );
1708 break;
1711 return UnregisterClassA( className, HINSTANCE_32(hInstance) );
1715 /***********************************************************************
1716 * GetClassInfo (USER.404)
1718 BOOL16 WINAPI GetClassInfo16( HINSTANCE16 hInst16, SEGPTR name, WNDCLASS16 *wc )
1720 WNDCLASSEX16 wcex;
1721 UINT16 ret = GetClassInfoEx16( hInst16, name, &wcex );
1723 if (ret)
1725 wc->style = wcex.style;
1726 wc->lpfnWndProc = wcex.lpfnWndProc;
1727 wc->cbClsExtra = wcex.cbClsExtra;
1728 wc->cbWndExtra = wcex.cbWndExtra;
1729 wc->hInstance = wcex.hInstance;
1730 wc->hIcon = wcex.hIcon;
1731 wc->hCursor = wcex.hCursor;
1732 wc->hbrBackground = wcex.hbrBackground;
1733 wc->lpszMenuName = wcex.lpszMenuName;
1734 wc->lpszClassName = wcex.lpszClassName;
1736 return ret;
1740 /**************************************************************************
1741 * TrackPopupMenu (USER.416)
1743 BOOL16 WINAPI TrackPopupMenu16( HMENU16 hMenu, UINT16 wFlags, INT16 x, INT16 y,
1744 INT16 nReserved, HWND16 hwnd, const RECT16 *lpRect )
1746 RECT r;
1747 if (lpRect)
1749 r.left = lpRect->left;
1750 r.top = lpRect->top;
1751 r.right = lpRect->right;
1752 r.bottom = lpRect->bottom;
1754 return TrackPopupMenu( HMENU_32(hMenu), wFlags, x, y, nReserved,
1755 WIN_Handle32(hwnd), lpRect ? &r : NULL );
1759 /**************************************************************************
1760 * FindWindowEx (USER.427)
1762 HWND16 WINAPI FindWindowEx16( HWND16 parent, HWND16 child, LPCSTR className, LPCSTR title )
1764 return HWND_16( FindWindowExA( WIN_Handle32(parent), WIN_Handle32(child),
1765 className, title ));
1769 /***********************************************************************
1770 * DefFrameProc (USER.445)
1772 LRESULT WINAPI DefFrameProc16( HWND16 hwnd, HWND16 hwndMDIClient,
1773 UINT16 message, WPARAM16 wParam, LPARAM lParam )
1775 switch (message)
1777 case WM_SETTEXT:
1778 lParam = (LPARAM)MapSL(lParam);
1779 /* fall through */
1780 case WM_COMMAND:
1781 case WM_NCACTIVATE:
1782 case WM_SETFOCUS:
1783 case WM_SIZE:
1784 return DefFrameProcA( WIN_Handle32(hwnd), WIN_Handle32(hwndMDIClient),
1785 message, wParam, lParam );
1787 case WM_NEXTMENU:
1789 MDINEXTMENU next_menu;
1790 DefFrameProcW( WIN_Handle32(hwnd), WIN_Handle32(hwndMDIClient),
1791 message, wParam, (LPARAM)&next_menu );
1792 return MAKELONG( HMENU_16(next_menu.hmenuNext), HWND_16(next_menu.hwndNext) );
1794 default:
1795 return DefWindowProc16(hwnd, message, wParam, lParam);
1800 /***********************************************************************
1801 * DefMDIChildProc (USER.447)
1803 LRESULT WINAPI DefMDIChildProc16( HWND16 hwnd, UINT16 message,
1804 WPARAM16 wParam, LPARAM lParam )
1806 switch (message)
1808 case WM_SETTEXT:
1809 return DefMDIChildProcA( WIN_Handle32(hwnd), message, wParam, (LPARAM)MapSL(lParam) );
1811 case WM_MENUCHAR:
1812 case WM_CLOSE:
1813 case WM_SETFOCUS:
1814 case WM_CHILDACTIVATE:
1815 case WM_SYSCOMMAND:
1816 case WM_SETVISIBLE:
1817 case WM_SIZE:
1818 case WM_SYSCHAR:
1819 return DefMDIChildProcW( WIN_Handle32(hwnd), message, wParam, lParam );
1821 case WM_GETMINMAXINFO:
1823 MINMAXINFO16 *mmi16 = MapSL(lParam);
1824 MINMAXINFO mmi;
1826 mmi.ptReserved.x = mmi16->ptReserved.x;
1827 mmi.ptReserved.y = mmi16->ptReserved.y;
1828 mmi.ptMaxSize.x = mmi16->ptMaxSize.x;
1829 mmi.ptMaxSize.y = mmi16->ptMaxSize.y;
1830 mmi.ptMaxPosition.x = mmi16->ptMaxPosition.x;
1831 mmi.ptMaxPosition.y = mmi16->ptMaxPosition.y;
1832 mmi.ptMinTrackSize.x = mmi16->ptMinTrackSize.x;
1833 mmi.ptMinTrackSize.y = mmi16->ptMinTrackSize.y;
1834 mmi.ptMaxTrackSize.x = mmi16->ptMaxTrackSize.x;
1835 mmi.ptMaxTrackSize.y = mmi16->ptMaxTrackSize.y;
1837 DefMDIChildProcW( WIN_Handle32(hwnd), message, wParam, (LPARAM)&mmi );
1839 mmi16->ptReserved.x = mmi.ptReserved.x;
1840 mmi16->ptReserved.y = mmi.ptReserved.y;
1841 mmi16->ptMaxSize.x = mmi.ptMaxSize.x;
1842 mmi16->ptMaxSize.y = mmi.ptMaxSize.y;
1843 mmi16->ptMaxPosition.x = mmi.ptMaxPosition.x;
1844 mmi16->ptMaxPosition.y = mmi.ptMaxPosition.y;
1845 mmi16->ptMinTrackSize.x = mmi.ptMinTrackSize.x;
1846 mmi16->ptMinTrackSize.y = mmi.ptMinTrackSize.y;
1847 mmi16->ptMaxTrackSize.x = mmi.ptMaxTrackSize.x;
1848 mmi16->ptMaxTrackSize.y = mmi.ptMaxTrackSize.y;
1849 return 0;
1851 case WM_NEXTMENU:
1853 MDINEXTMENU next_menu;
1854 DefMDIChildProcW( WIN_Handle32(hwnd), message, wParam, (LPARAM)&next_menu );
1855 return MAKELONG( HMENU_16(next_menu.hmenuNext), HWND_16(next_menu.hwndNext) );
1857 default:
1858 return DefWindowProc16(hwnd, message, wParam, lParam);
1863 /**************************************************************************
1864 * DrawAnimatedRects (USER.448)
1866 BOOL16 WINAPI DrawAnimatedRects16( HWND16 hwnd, INT16 idAni,
1867 const RECT16* lprcFrom, const RECT16* lprcTo )
1869 RECT rcFrom32, rcTo32;
1870 rcFrom32.left = lprcFrom->left;
1871 rcFrom32.top = lprcFrom->top;
1872 rcFrom32.right = lprcFrom->right;
1873 rcFrom32.bottom = lprcFrom->bottom;
1874 rcTo32.left = lprcTo->left;
1875 rcTo32.top = lprcTo->top;
1876 rcTo32.right = lprcTo->right;
1877 rcTo32.bottom = lprcTo->bottom;
1878 return DrawAnimatedRects( WIN_Handle32(hwnd), idAni, &rcFrom32, &rcTo32 );
1882 /***********************************************************************
1883 * CreateWindowEx (USER.452)
1885 HWND16 WINAPI CreateWindowEx16( DWORD exStyle, LPCSTR className,
1886 LPCSTR windowName, DWORD style, INT16 x,
1887 INT16 y, INT16 width, INT16 height,
1888 HWND16 parent, HMENU16 menu,
1889 HINSTANCE16 instance, LPVOID data )
1891 CREATESTRUCTA cs;
1892 char buffer[256];
1893 HWND hwnd;
1895 /* Fix the coordinates */
1897 cs.x = (x == CW_USEDEFAULT16) ? CW_USEDEFAULT : (INT)x;
1898 cs.y = (y == CW_USEDEFAULT16) ? CW_USEDEFAULT : (INT)y;
1899 cs.cx = (width == CW_USEDEFAULT16) ? CW_USEDEFAULT : (INT)width;
1900 cs.cy = (height == CW_USEDEFAULT16) ? CW_USEDEFAULT : (INT)height;
1902 /* Create the window */
1904 cs.lpCreateParams = data;
1905 cs.hInstance = HINSTANCE_32(instance);
1906 cs.hMenu = HMENU_32(menu);
1907 cs.hwndParent = WIN_Handle32( parent );
1908 cs.style = style;
1909 cs.lpszName = windowName;
1910 cs.lpszClass = className;
1911 cs.dwExStyle = exStyle;
1913 /* load the menu */
1914 if (!menu && (style & (WS_CHILD | WS_POPUP)) != WS_CHILD)
1916 WNDCLASSA class;
1917 HINSTANCE16 module = GetExePtr( instance );
1919 if (GetClassInfoA( HINSTANCE_32(module), className, &class ))
1920 cs.hMenu = HMENU_32( LoadMenu16( module, class.lpszMenuName ));
1923 if (!IS_INTRESOURCE(className))
1925 WCHAR bufferW[256];
1927 if (!MultiByteToWideChar( CP_ACP, 0, className, -1, bufferW, sizeof(bufferW)/sizeof(WCHAR) ))
1928 return 0;
1929 hwnd = create_window16( (CREATESTRUCTW *)&cs, bufferW, HINSTANCE_32(instance), FALSE );
1931 else
1933 if (!GlobalGetAtomNameA( LOWORD(className), buffer, sizeof(buffer) )) return 0;
1934 cs.lpszClass = buffer;
1935 hwnd = create_window16( (CREATESTRUCTW *)&cs, (LPCWSTR)className, HINSTANCE_32(instance), FALSE );
1937 return HWND_16( hwnd );
1941 /***********************************************************************
1942 * GetInternalWindowPos (USER.460)
1944 UINT16 WINAPI GetInternalWindowPos16( HWND16 hwnd, LPRECT16 rectWnd, LPPOINT16 ptIcon )
1946 WINDOWPLACEMENT16 wndpl;
1948 if (!GetWindowPlacement16( hwnd, &wndpl )) return 0;
1949 if (rectWnd) *rectWnd = wndpl.rcNormalPosition;
1950 if (ptIcon) *ptIcon = wndpl.ptMinPosition;
1951 return wndpl.showCmd;
1955 /**************************************************************************
1956 * SetInternalWindowPos (USER.461)
1958 void WINAPI SetInternalWindowPos16( HWND16 hwnd, UINT16 showCmd, LPRECT16 rect, LPPOINT16 pt )
1960 RECT rc32;
1961 POINT pt32;
1963 if (rect)
1965 rc32.left = rect->left;
1966 rc32.top = rect->top;
1967 rc32.right = rect->right;
1968 rc32.bottom = rect->bottom;
1970 if (pt)
1972 pt32.x = pt->x;
1973 pt32.y = pt->y;
1975 SetInternalWindowPos( WIN_Handle32(hwnd), showCmd,
1976 rect ? &rc32 : NULL, pt ? &pt32 : NULL );
1980 /**************************************************************************
1981 * CalcChildScroll (USER.462)
1983 void WINAPI CalcChildScroll16( HWND16 hwnd, WORD scroll )
1985 CalcChildScroll( WIN_Handle32(hwnd), scroll );
1989 /**************************************************************************
1990 * ScrollChildren (USER.463)
1992 void WINAPI ScrollChildren16(HWND16 hwnd, UINT16 uMsg, WPARAM16 wParam, LPARAM lParam)
1994 ScrollChildren( WIN_Handle32(hwnd), uMsg, wParam, lParam );
1998 /**************************************************************************
1999 * DragDetect (USER.465)
2001 BOOL16 WINAPI DragDetect16( HWND16 hwnd, POINT16 pt )
2003 POINT pt32;
2005 pt32.x = pt.x;
2006 pt32.y = pt.y;
2007 return DragDetect( WIN_Handle32(hwnd), pt32 );
2011 /**************************************************************************
2012 * SetScrollInfo (USER.475)
2014 INT16 WINAPI SetScrollInfo16( HWND16 hwnd, INT16 nBar, const SCROLLINFO *info, BOOL16 redraw )
2016 return SetScrollInfo( WIN_Handle32(hwnd), nBar, info, redraw );
2020 /**************************************************************************
2021 * GetScrollInfo (USER.476)
2023 BOOL16 WINAPI GetScrollInfo16( HWND16 hwnd, INT16 nBar, LPSCROLLINFO info )
2025 return GetScrollInfo( WIN_Handle32(hwnd), nBar, info );
2029 /**************************************************************************
2030 * EnableScrollBar (USER.482)
2032 BOOL16 WINAPI EnableScrollBar16( HWND16 hwnd, INT16 nBar, UINT16 flags )
2034 return EnableScrollBar( WIN_Handle32(hwnd), nBar, flags );
2038 /**************************************************************************
2039 * GetShellWindow (USER.600)
2041 HWND16 WINAPI GetShellWindow16(void)
2043 return HWND_16( GetShellWindow() );
2047 /**************************************************************************
2048 * GetForegroundWindow (USER.608)
2050 HWND16 WINAPI GetForegroundWindow16(void)
2052 return HWND_16( GetForegroundWindow() );
2056 /**************************************************************************
2057 * SetForegroundWindow (USER.609)
2059 BOOL16 WINAPI SetForegroundWindow16( HWND16 hwnd )
2061 return SetForegroundWindow( WIN_Handle32(hwnd) );
2065 /**************************************************************************
2066 * DrawCaptionTemp (USER.657)
2068 BOOL16 WINAPI DrawCaptionTemp16( HWND16 hwnd, HDC16 hdc, const RECT16 *rect,
2069 HFONT16 hFont, HICON16 hIcon, LPCSTR str, UINT16 uFlags )
2071 RECT rect32;
2073 if (rect)
2075 rect32.left = rect->left;
2076 rect32.top = rect->top;
2077 rect32.right = rect->right;
2078 rect32.bottom = rect->bottom;
2080 return DrawCaptionTempA( WIN_Handle32(hwnd), HDC_32(hdc),
2081 rect ? &rect32 : NULL, HFONT_32(hFont),
2082 get_icon_32(hIcon), str, uFlags & 0x1f );
2086 /**************************************************************************
2087 * DrawCaption (USER.660)
2089 BOOL16 WINAPI DrawCaption16( HWND16 hwnd, HDC16 hdc, const RECT16 *rect, UINT16 flags )
2091 RECT rect32;
2093 if (rect)
2095 rect32.left = rect->left;
2096 rect32.top = rect->top;
2097 rect32.right = rect->right;
2098 rect32.bottom = rect->bottom;
2100 return DrawCaption(WIN_Handle32(hwnd), HDC_32(hdc), rect ? &rect32 : NULL, flags);
2104 /**************************************************************************
2105 * GetMenuItemRect (USER.665)
2107 BOOL16 WINAPI GetMenuItemRect16( HWND16 hwnd, HMENU16 hMenu, UINT16 uItem,
2108 LPRECT16 rect)
2110 RECT r32;
2111 BOOL res;
2112 if (!rect) return FALSE;
2113 res = GetMenuItemRect( WIN_Handle32(hwnd), HMENU_32(hMenu), uItem, &r32 );
2114 rect->left = r32.left;
2115 rect->top = r32.top;
2116 rect->right = r32.right;
2117 rect->bottom = r32.bottom;
2118 return res;
2122 /**************************************************************************
2123 * SetWindowRgn (USER.668)
2125 INT16 WINAPI SetWindowRgn16( HWND16 hwnd, HRGN16 hrgn, BOOL16 redraw )
2127 return SetWindowRgn( WIN_Handle32(hwnd), HRGN_32(hrgn), redraw );
2131 /**************************************************************************
2132 * MessageBoxIndirect (USER.827)
2134 INT16 WINAPI MessageBoxIndirect16( LPMSGBOXPARAMS16 msgbox )
2136 char caption[256], text[256];
2137 MSGBOXPARAMSA msgbox32;
2139 msgbox32.cbSize = msgbox->cbSize;
2140 msgbox32.hwndOwner = WIN_Handle32( msgbox->hwndOwner );
2141 msgbox32.hInstance = 0;
2142 msgbox32.dwStyle = msgbox->dwStyle;
2143 msgbox32.lpszIcon = NULL;
2144 msgbox32.dwContextHelpId = msgbox->dwContextHelpId;
2145 msgbox32.lpfnMsgBoxCallback = msgbox->lpfnMsgBoxCallback;
2146 msgbox32.dwLanguageId = msgbox->dwLanguageId;
2148 if (!HIWORD(msgbox->lpszCaption))
2150 LoadString16( msgbox->hInstance, LOWORD(msgbox->lpszCaption), caption, sizeof(caption) );
2151 msgbox32.lpszCaption = caption;
2153 else msgbox32.lpszCaption = MapSL(msgbox->lpszCaption);
2155 if (!HIWORD(msgbox->lpszText))
2157 LoadString16( msgbox->hInstance, LOWORD(msgbox->lpszText), text, sizeof(text) );
2158 msgbox32.lpszText = text;
2160 else msgbox32.lpszText = MapSL(msgbox->lpszText);
2162 if ((msgbox->dwStyle & MB_ICONMASK) == MB_USERICON)
2164 FIXME( "user icon %s not supported\n", debugstr_a( MapSL(msgbox->lpszIcon) ));
2165 msgbox32.dwStyle &= ~MB_USERICON;
2168 return MessageBoxIndirectA( &msgbox32 );