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"
25 #include "user_private.h"
26 #include "wine/list.h"
27 #include "wine/server.h"
29 /* size of buffer needed to store an atom string */
30 #define ATOM_BUFFER_SIZE 256
32 /* handle <--> handle16 conversions */
33 #define HANDLE_16(h32) (LOWORD(h32))
34 #define HANDLE_32(h16) ((HANDLE)(ULONG_PTR)(h16))
36 static HWND16 hwndSysModal;
45 static struct list class_list = LIST_INIT( class_list );
53 /* callback for 16-bit window enumeration functions */
54 static BOOL CALLBACK wnd_enum_callback( HWND hwnd, LPARAM param )
56 const struct wnd_enum_info *info = (struct wnd_enum_info *)param;
60 args[2] = HWND_16(hwnd);
61 args[1] = HIWORD(info->param);
62 args[0] = LOWORD(info->param);
63 WOWCallback16Ex( (DWORD)info->proc, WCB16_PASCAL, sizeof(args), args, &ret );
67 /* convert insert after window handle to 32-bit */
68 static inline HWND full_insert_after_hwnd( HWND16 hwnd )
70 HWND ret = WIN_Handle32( hwnd );
71 if (ret == (HWND)0xffff) ret = HWND_TOPMOST;
75 void free_module_classes( HINSTANCE16 inst )
77 struct class_entry *class, *next;
79 LIST_FOR_EACH_ENTRY_SAFE( class, next, &class_list, struct class_entry, entry )
81 if (class->inst != inst) continue;
82 list_remove( &class->entry );
83 UnregisterClassA( (LPCSTR)MAKEINTATOM(class->atom), HINSTANCE_32(class->inst) );
84 HeapFree( GetProcessHeap(), 0, class );
88 /**************************************************************************
91 INT16 WINAPI MessageBox16( HWND16 hwnd, LPCSTR text, LPCSTR title, UINT16 type )
93 return MessageBoxA( WIN_Handle32(hwnd), text, title, type );
97 /***********************************************************************
100 UINT16 WINAPI SetTimer16( HWND16 hwnd, UINT16 id, UINT16 timeout, TIMERPROC16 proc )
102 TIMERPROC proc32 = (TIMERPROC)WINPROC_AllocProc16( (WNDPROC16)proc );
103 return SetTimer( WIN_Handle32(hwnd), id, timeout, proc32 );
107 /***********************************************************************
108 * SetSystemTimer (USER.11)
110 UINT16 WINAPI SetSystemTimer16( HWND16 hwnd, UINT16 id, UINT16 timeout, TIMERPROC16 proc )
112 TIMERPROC proc32 = (TIMERPROC)WINPROC_AllocProc16( (WNDPROC16)proc );
113 return SetSystemTimer( WIN_Handle32(hwnd), id, timeout, proc32 );
117 /**************************************************************************
118 * KillTimer (USER.12)
120 BOOL16 WINAPI KillTimer16( HWND16 hwnd, UINT16 id )
122 return KillTimer( WIN_Handle32(hwnd), id );
126 /**************************************************************************
127 * SetCapture (USER.18)
129 HWND16 WINAPI SetCapture16( HWND16 hwnd )
131 return HWND_16( SetCapture( WIN_Handle32(hwnd) ));
135 /**************************************************************************
136 * ReleaseCapture (USER.19)
138 BOOL16 WINAPI ReleaseCapture16(void)
140 return ReleaseCapture();
144 /**************************************************************************
147 HWND16 WINAPI SetFocus16( HWND16 hwnd )
149 return HWND_16( SetFocus( WIN_Handle32(hwnd) ));
153 /**************************************************************************
156 HWND16 WINAPI GetFocus16(void)
158 return HWND_16( GetFocus() );
162 /**************************************************************************
163 * RemoveProp (USER.24)
165 HANDLE16 WINAPI RemoveProp16( HWND16 hwnd, LPCSTR str )
167 return HANDLE_16(RemovePropA( WIN_Handle32(hwnd), str ));
171 /**************************************************************************
174 HANDLE16 WINAPI GetProp16( HWND16 hwnd, LPCSTR str )
176 return HANDLE_16(GetPropA( WIN_Handle32(hwnd), str ));
180 /**************************************************************************
183 BOOL16 WINAPI SetProp16( HWND16 hwnd, LPCSTR str, HANDLE16 handle )
185 return SetPropA( WIN_Handle32(hwnd), str, HANDLE_32(handle) );
189 /***********************************************************************
190 * EnumProps (USER.27)
192 INT16 WINAPI EnumProps16( HWND16 hwnd, PROPENUMPROC16 func )
194 int ret = -1, i, count, total = 32;
195 property_data_t *list;
199 if (!(list = HeapAlloc( GetProcessHeap(), 0, total * sizeof(*list) ))) break;
201 SERVER_START_REQ( get_window_properties )
203 req->window = wine_server_user_handle( HWND_32(hwnd) );
204 wine_server_set_reply( req, list, total * sizeof(*list) );
205 if (!wine_server_call( req )) count = reply->total;
209 if (count && count <= total)
211 char string[ATOM_BUFFER_SIZE];
212 SEGPTR segptr = MapLS( string );
216 for (i = 0; i < count; i++)
218 if (list[i].string) /* it was a string originally */
220 if (!GlobalGetAtomNameA( list[i].atom, string, ATOM_BUFFER_SIZE )) continue;
222 args[2] = SELECTOROF(segptr);
223 args[1] = OFFSETOF(segptr);
224 args[0] = LOWORD(list[i].data);
230 args[1] = list[i].atom;
231 args[0] = LOWORD(list[i].data);
233 WOWCallback16Ex( (DWORD)func, WCB16_PASCAL, sizeof(args), args, &result );
234 if (!(ret = LOWORD(result))) break;
237 HeapFree( GetProcessHeap(), 0, list );
240 HeapFree( GetProcessHeap(), 0, list );
241 total = count; /* restart with larger buffer */
247 /**************************************************************************
248 * ClientToScreen (USER.28)
250 void WINAPI ClientToScreen16( HWND16 hwnd, LPPOINT16 lppnt )
252 MapWindowPoints16( hwnd, 0, lppnt, 1 );
256 /**************************************************************************
257 * ScreenToClient (USER.29)
259 void WINAPI ScreenToClient16( HWND16 hwnd, LPPOINT16 lppnt )
261 MapWindowPoints16( 0, hwnd, lppnt, 1 );
265 /**************************************************************************
266 * WindowFromPoint (USER.30)
268 HWND16 WINAPI WindowFromPoint16( POINT16 pt )
274 return HWND_16( WindowFromPoint( pt32 ) );
278 /**************************************************************************
281 BOOL16 WINAPI IsIconic16(HWND16 hwnd)
283 return IsIconic( WIN_Handle32(hwnd) );
287 /**************************************************************************
288 * GetWindowRect (USER.32)
290 void WINAPI GetWindowRect16( HWND16 hwnd, LPRECT16 rect )
294 GetWindowRect( WIN_Handle32(hwnd), &rect32 );
295 rect->left = rect32.left;
296 rect->top = rect32.top;
297 rect->right = rect32.right;
298 rect->bottom = rect32.bottom;
302 /**************************************************************************
303 * GetClientRect (USER.33)
305 void WINAPI GetClientRect16( HWND16 hwnd, LPRECT16 rect )
309 GetClientRect( WIN_Handle32(hwnd), &rect32 );
310 rect->left = rect32.left;
311 rect->top = rect32.top;
312 rect->right = rect32.right;
313 rect->bottom = rect32.bottom;
317 /**************************************************************************
318 * EnableWindow (USER.34)
320 BOOL16 WINAPI EnableWindow16( HWND16 hwnd, BOOL16 enable )
322 return EnableWindow( WIN_Handle32(hwnd), enable );
326 /**************************************************************************
327 * IsWindowEnabled (USER.35)
329 BOOL16 WINAPI IsWindowEnabled16(HWND16 hwnd)
331 return IsWindowEnabled( WIN_Handle32(hwnd) );
335 /**************************************************************************
336 * GetWindowText (USER.36)
338 INT16 WINAPI GetWindowText16( HWND16 hwnd, SEGPTR lpString, INT16 nMaxCount )
340 return SendMessage16( hwnd, WM_GETTEXT, nMaxCount, lpString );
344 /**************************************************************************
345 * SetWindowText (USER.37)
347 BOOL16 WINAPI SetWindowText16( HWND16 hwnd, SEGPTR lpString )
349 return SendMessage16( hwnd, WM_SETTEXT, 0, (LPARAM)lpString );
353 /**************************************************************************
354 * GetWindowTextLength (USER.38)
356 INT16 WINAPI GetWindowTextLength16( HWND16 hwnd )
358 return SendMessage16( hwnd, WM_GETTEXTLENGTH, 0, 0 );
362 /***********************************************************************
363 * BeginPaint (USER.39)
365 HDC16 WINAPI BeginPaint16( HWND16 hwnd, LPPAINTSTRUCT16 lps )
369 BeginPaint( WIN_Handle32(hwnd), &ps );
370 lps->hdc = HDC_16(ps.hdc);
371 lps->fErase = ps.fErase;
372 lps->rcPaint.top = ps.rcPaint.top;
373 lps->rcPaint.left = ps.rcPaint.left;
374 lps->rcPaint.right = ps.rcPaint.right;
375 lps->rcPaint.bottom = ps.rcPaint.bottom;
376 lps->fRestore = ps.fRestore;
377 lps->fIncUpdate = ps.fIncUpdate;
382 /***********************************************************************
385 BOOL16 WINAPI EndPaint16( HWND16 hwnd, const PAINTSTRUCT16* lps )
389 ps.hdc = HDC_32(lps->hdc);
390 return EndPaint( WIN_Handle32(hwnd), &ps );
394 /***********************************************************************
395 * CreateWindow (USER.41)
397 HWND16 WINAPI CreateWindow16( LPCSTR className, LPCSTR windowName,
398 DWORD style, INT16 x, INT16 y, INT16 width,
399 INT16 height, HWND16 parent, HMENU16 menu,
400 HINSTANCE16 instance, LPVOID data )
402 return CreateWindowEx16( 0, className, windowName, style,
403 x, y, width, height, parent, menu, instance, data );
407 /**************************************************************************
408 * ShowWindow (USER.42)
410 BOOL16 WINAPI ShowWindow16( HWND16 hwnd, INT16 cmd )
412 return ShowWindow( WIN_Handle32(hwnd), cmd );
416 /**************************************************************************
417 * CloseWindow (USER.43)
419 BOOL16 WINAPI CloseWindow16( HWND16 hwnd )
421 return CloseWindow( WIN_Handle32(hwnd) );
425 /**************************************************************************
428 BOOL16 WINAPI OpenIcon16( HWND16 hwnd )
430 return OpenIcon( WIN_Handle32(hwnd) );
434 /**************************************************************************
435 * BringWindowToTop (USER.45)
437 BOOL16 WINAPI BringWindowToTop16( HWND16 hwnd )
439 return BringWindowToTop( WIN_Handle32(hwnd) );
443 /**************************************************************************
444 * GetParent (USER.46)
446 HWND16 WINAPI GetParent16( HWND16 hwnd )
448 return HWND_16( GetParent( WIN_Handle32(hwnd) ));
452 /**************************************************************************
455 BOOL16 WINAPI IsWindow16( HWND16 hwnd )
457 STACK16FRAME *frame = MapSL( (SEGPTR)NtCurrentTeb()->WOW32Reserved );
458 frame->es = USER_HeapSel;
459 /* don't use WIN_Handle32 here, we don't care about the full handle */
460 return IsWindow( HWND_32(hwnd) );
464 /**************************************************************************
467 BOOL16 WINAPI IsChild16( HWND16 parent, HWND16 child )
469 return IsChild( WIN_Handle32(parent), WIN_Handle32(child) );
473 /**************************************************************************
474 * IsWindowVisible (USER.49)
476 BOOL16 WINAPI IsWindowVisible16( HWND16 hwnd )
478 return IsWindowVisible( WIN_Handle32(hwnd) );
482 /**************************************************************************
483 * FindWindow (USER.50)
485 HWND16 WINAPI FindWindow16( LPCSTR className, LPCSTR title )
487 return HWND_16( FindWindowA( className, title ));
491 /**************************************************************************
492 * DestroyWindow (USER.53)
494 BOOL16 WINAPI DestroyWindow16( HWND16 hwnd )
496 return DestroyWindow( WIN_Handle32(hwnd) );
500 /*******************************************************************
501 * EnumWindows (USER.54)
503 BOOL16 WINAPI EnumWindows16( WNDENUMPROC16 func, LPARAM lParam )
505 struct wnd_enum_info info;
509 return EnumWindows( wnd_enum_callback, (LPARAM)&info );
513 /**********************************************************************
514 * EnumChildWindows (USER.55)
516 BOOL16 WINAPI EnumChildWindows16( HWND16 parent, WNDENUMPROC16 func, LPARAM lParam )
518 struct wnd_enum_info info;
522 return EnumChildWindows( WIN_Handle32(parent), wnd_enum_callback, (LPARAM)&info );
526 /**************************************************************************
527 * MoveWindow (USER.56)
529 BOOL16 WINAPI MoveWindow16( HWND16 hwnd, INT16 x, INT16 y, INT16 cx, INT16 cy, BOOL16 repaint )
531 return MoveWindow( WIN_Handle32(hwnd), x, y, cx, cy, repaint );
535 /***********************************************************************
536 * RegisterClass (USER.57)
538 ATOM WINAPI RegisterClass16( const WNDCLASS16 *wc )
542 wcex.cbSize = sizeof(wcex);
543 wcex.style = wc->style;
544 wcex.lpfnWndProc = wc->lpfnWndProc;
545 wcex.cbClsExtra = wc->cbClsExtra;
546 wcex.cbWndExtra = wc->cbWndExtra;
547 wcex.hInstance = wc->hInstance;
548 wcex.hIcon = wc->hIcon;
549 wcex.hCursor = wc->hCursor;
550 wcex.hbrBackground = wc->hbrBackground;
551 wcex.lpszMenuName = wc->lpszMenuName;
552 wcex.lpszClassName = wc->lpszClassName;
554 return RegisterClassEx16( &wcex );
558 /**************************************************************************
559 * GetClassName (USER.58)
561 INT16 WINAPI GetClassName16( HWND16 hwnd, LPSTR buffer, INT16 count )
563 return GetClassNameA( WIN_Handle32(hwnd), buffer, count );
567 /**************************************************************************
568 * SetActiveWindow (USER.59)
570 HWND16 WINAPI SetActiveWindow16( HWND16 hwnd )
572 return HWND_16( SetActiveWindow( WIN_Handle32(hwnd) ));
576 /**************************************************************************
577 * GetActiveWindow (USER.60)
579 HWND16 WINAPI GetActiveWindow16(void)
581 return HWND_16( GetActiveWindow() );
585 /**************************************************************************
586 * ScrollWindow (USER.61)
588 void WINAPI ScrollWindow16( HWND16 hwnd, INT16 dx, INT16 dy, const RECT16 *rect,
589 const RECT16 *clipRect )
591 RECT rect32, clipRect32;
595 rect32.left = rect->left;
596 rect32.top = rect->top;
597 rect32.right = rect->right;
598 rect32.bottom = rect->bottom;
602 clipRect32.left = clipRect->left;
603 clipRect32.top = clipRect->top;
604 clipRect32.right = clipRect->right;
605 clipRect32.bottom = clipRect->bottom;
607 ScrollWindow( WIN_Handle32(hwnd), dx, dy, rect ? &rect32 : NULL,
608 clipRect ? &clipRect32 : NULL );
612 /**************************************************************************
613 * SetScrollPos (USER.62)
615 INT16 WINAPI SetScrollPos16( HWND16 hwnd, INT16 nBar, INT16 nPos, BOOL16 redraw )
617 return SetScrollPos( WIN_Handle32(hwnd), nBar, nPos, redraw );
621 /**************************************************************************
622 * GetScrollPos (USER.63)
624 INT16 WINAPI GetScrollPos16( HWND16 hwnd, INT16 nBar )
626 return GetScrollPos( WIN_Handle32(hwnd), nBar );
630 /**************************************************************************
631 * SetScrollRange (USER.64)
633 void WINAPI SetScrollRange16( HWND16 hwnd, INT16 nBar, INT16 MinVal, INT16 MaxVal, BOOL16 redraw )
635 /* Invalid range -> range is set to (0,0) */
636 if ((INT)MaxVal - (INT)MinVal > 0x7fff) MinVal = MaxVal = 0;
637 SetScrollRange( WIN_Handle32(hwnd), nBar, MinVal, MaxVal, redraw );
641 /**************************************************************************
642 * GetScrollRange (USER.65)
644 BOOL16 WINAPI GetScrollRange16( HWND16 hwnd, INT16 nBar, LPINT16 lpMin, LPINT16 lpMax)
647 BOOL ret = GetScrollRange( WIN_Handle32(hwnd), nBar, &min, &max );
648 if (lpMin) *lpMin = min;
649 if (lpMax) *lpMax = max;
654 /**************************************************************************
657 HDC16 WINAPI GetDC16( HWND16 hwnd )
659 return HDC_16(GetDC( WIN_Handle32(hwnd) ));
663 /**************************************************************************
664 * GetWindowDC (USER.67)
666 HDC16 WINAPI GetWindowDC16( HWND16 hwnd )
668 return GetDCEx16( hwnd, 0, DCX_USESTYLE | DCX_WINDOW );
672 /**************************************************************************
673 * ReleaseDC (USER.68)
675 INT16 WINAPI ReleaseDC16( HWND16 hwnd, HDC16 hdc )
677 return (INT16)ReleaseDC( WIN_Handle32(hwnd), HDC_32(hdc) );
681 /**************************************************************************
682 * FlashWindow (USER.105)
684 BOOL16 WINAPI FlashWindow16( HWND16 hwnd, BOOL16 bInvert )
686 return FlashWindow( WIN_Handle32(hwnd), bInvert );
690 /**************************************************************************
691 * WindowFromDC (USER.117)
693 HWND16 WINAPI WindowFromDC16( HDC16 hDC )
695 return HWND_16( WindowFromDC( HDC_32(hDC) ) );
699 /**************************************************************************
700 * UpdateWindow (USER.124)
702 void WINAPI UpdateWindow16( HWND16 hwnd )
704 RedrawWindow16( hwnd, NULL, 0, RDW_UPDATENOW | RDW_ALLCHILDREN );
708 /**************************************************************************
709 * InvalidateRect (USER.125)
711 void WINAPI InvalidateRect16( HWND16 hwnd, const RECT16 *rect, BOOL16 erase )
713 RedrawWindow16( hwnd, rect, 0, RDW_INVALIDATE | (erase ? RDW_ERASE : 0) );
717 /**************************************************************************
718 * InvalidateRgn (USER.126)
720 void WINAPI InvalidateRgn16( HWND16 hwnd, HRGN16 hrgn, BOOL16 erase )
722 RedrawWindow16( hwnd, NULL, hrgn, RDW_INVALIDATE | (erase ? RDW_ERASE : 0) );
726 /**************************************************************************
727 * ValidateRect (USER.127)
729 void WINAPI ValidateRect16( HWND16 hwnd, const RECT16 *rect )
731 RedrawWindow16( hwnd, rect, 0, RDW_VALIDATE | RDW_NOCHILDREN );
735 /**************************************************************************
736 * ValidateRgn (USER.128)
738 void WINAPI ValidateRgn16( HWND16 hwnd, HRGN16 hrgn )
740 RedrawWindow16( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOCHILDREN );
744 /**************************************************************************
745 * GetClassWord (USER.129)
747 WORD WINAPI GetClassWord16( HWND16 hwnd, INT16 offset )
749 return GetClassWord( WIN_Handle32(hwnd), offset );
753 /**************************************************************************
754 * SetClassWord (USER.130)
756 WORD WINAPI SetClassWord16( HWND16 hwnd, INT16 offset, WORD newval )
758 return SetClassWord( WIN_Handle32(hwnd), offset, newval );
762 /***********************************************************************
763 * GetClassLong (USER.131)
765 LONG WINAPI GetClassLong16( HWND16 hwnd16, INT16 offset )
767 LONG_PTR ret = GetClassLongA( WIN_Handle32(hwnd16), offset );
772 return (LONG_PTR)WINPROC_GetProc16( (WNDPROC)ret, FALSE );
774 return MapLS( (void *)ret ); /* leak */
781 /***********************************************************************
782 * SetClassLong (USER.132)
784 LONG WINAPI SetClassLong16( HWND16 hwnd16, INT16 offset, LONG newval )
790 WNDPROC new_proc = WINPROC_AllocProc16( (WNDPROC16)newval );
791 WNDPROC old_proc = (WNDPROC)SetClassLongA( WIN_Handle32(hwnd16), offset, (LONG_PTR)new_proc );
792 return (LONG)WINPROC_GetProc16( old_proc, FALSE );
795 newval = (LONG)MapSL( newval );
798 return SetClassLongA( WIN_Handle32(hwnd16), offset, newval );
803 /**************************************************************************
804 * GetWindowWord (USER.133)
806 WORD WINAPI GetWindowWord16( HWND16 hwnd, INT16 offset )
808 return GetWindowWord( WIN_Handle32(hwnd), offset );
812 /**************************************************************************
813 * SetWindowWord (USER.134)
815 WORD WINAPI SetWindowWord16( HWND16 hwnd, INT16 offset, WORD newval )
817 return SetWindowWord( WIN_Handle32(hwnd), offset, newval );
821 /**********************************************************************
822 * GetWindowLong (USER.135)
824 LONG WINAPI GetWindowLong16( HWND16 hwnd, INT16 offset )
828 BOOL is_winproc = (offset == GWLP_WNDPROC);
832 if (!(wndPtr = WIN_GetPtr( WIN_Handle32(hwnd) )))
834 SetLastError( ERROR_INVALID_WINDOW_HANDLE );
837 if (wndPtr != WND_OTHER_PROCESS && wndPtr != WND_DESKTOP)
839 if (offset > (int)(wndPtr->cbWndExtra - sizeof(LONG)))
842 * Some programs try to access last element from 16 bit
843 * code using illegal offset value. Hopefully this is
844 * what those programs really expect.
846 if (wndPtr->cbWndExtra >= 4 && offset == wndPtr->cbWndExtra - sizeof(WORD))
848 offset = wndPtr->cbWndExtra - sizeof(LONG);
852 WIN_ReleasePtr( wndPtr );
853 SetLastError( ERROR_INVALID_INDEX );
857 is_winproc = ((offset == DWLP_DLGPROC) && (wndPtr->flags & WIN_ISDIALOG));
858 WIN_ReleasePtr( wndPtr );
861 retvalue = GetWindowLongA( WIN_Handle32(hwnd), offset );
862 if (is_winproc) retvalue = (LONG_PTR)WINPROC_GetProc16( (WNDPROC)retvalue, FALSE );
867 /**********************************************************************
868 * SetWindowLong (USER.136)
870 LONG WINAPI SetWindowLong16( HWND16 hwnd, INT16 offset, LONG newval )
873 BOOL is_winproc = (offset == GWLP_WNDPROC);
875 if (offset == DWLP_DLGPROC)
877 if (!(wndPtr = WIN_GetPtr( WIN_Handle32(hwnd) )))
879 SetLastError( ERROR_INVALID_WINDOW_HANDLE );
882 if (wndPtr != WND_OTHER_PROCESS && wndPtr != WND_DESKTOP)
884 is_winproc = ((wndPtr->cbWndExtra - sizeof(LONG_PTR) >= DWLP_DLGPROC) &&
885 (wndPtr->flags & WIN_ISDIALOG));
886 WIN_ReleasePtr( wndPtr );
892 WNDPROC new_proc = WINPROC_AllocProc16( (WNDPROC16)newval );
893 WNDPROC old_proc = (WNDPROC)SetWindowLongPtrA( WIN_Handle32(hwnd), offset, (LONG_PTR)new_proc );
894 return (LONG)WINPROC_GetProc16( old_proc, FALSE );
896 else return SetWindowLongA( WIN_Handle32(hwnd), offset, newval );
900 /**************************************************************************
901 * OpenClipboard (USER.137)
903 BOOL16 WINAPI OpenClipboard16( HWND16 hwnd )
905 return OpenClipboard( WIN_Handle32(hwnd) );
909 /**************************************************************************
910 * GetClipboardOwner (USER.140)
912 HWND16 WINAPI GetClipboardOwner16(void)
914 return HWND_16( GetClipboardOwner() );
918 /**************************************************************************
919 * SetClipboardViewer (USER.147)
921 HWND16 WINAPI SetClipboardViewer16( HWND16 hwnd )
923 return HWND_16( SetClipboardViewer( WIN_Handle32(hwnd) ));
927 /**************************************************************************
928 * GetClipboardViewer (USER.148)
930 HWND16 WINAPI GetClipboardViewer16(void)
932 return HWND_16( GetClipboardViewer() );
936 /**************************************************************************
937 * ChangeClipboardChain (USER.149)
939 BOOL16 WINAPI ChangeClipboardChain16(HWND16 hwnd, HWND16 hwndNext)
941 return ChangeClipboardChain( WIN_Handle32(hwnd), WIN_Handle32(hwndNext) );
945 /**************************************************************************
946 * GetSystemMenu (USER.156)
948 HMENU16 WINAPI GetSystemMenu16( HWND16 hwnd, BOOL16 revert )
950 return HMENU_16(GetSystemMenu( WIN_Handle32(hwnd), revert ));
954 /**************************************************************************
957 HMENU16 WINAPI GetMenu16( HWND16 hwnd )
959 return HMENU_16(GetMenu( WIN_Handle32(hwnd) ));
963 /**************************************************************************
966 BOOL16 WINAPI SetMenu16( HWND16 hwnd, HMENU16 hMenu )
968 return SetMenu( WIN_Handle32(hwnd), HMENU_32(hMenu) );
972 /**************************************************************************
973 * DrawMenuBar (USER.160)
975 void WINAPI DrawMenuBar16( HWND16 hwnd )
977 DrawMenuBar( WIN_Handle32(hwnd) );
981 /**************************************************************************
982 * HiliteMenuItem (USER.162)
984 BOOL16 WINAPI HiliteMenuItem16( HWND16 hwnd, HMENU16 hMenu, UINT16 id, UINT16 wHilite )
986 return HiliteMenuItem( WIN_Handle32(hwnd), HMENU_32(hMenu), id, wHilite );
990 /**************************************************************************
991 * CreateCaret (USER.163)
993 void WINAPI CreateCaret16( HWND16 hwnd, HBITMAP16 bitmap, INT16 width, INT16 height )
995 CreateCaret( WIN_Handle32(hwnd), HBITMAP_32(bitmap), width, height );
999 /*****************************************************************
1000 * DestroyCaret (USER.164)
1002 void WINAPI DestroyCaret16(void)
1008 /*****************************************************************
1009 * SetCaretPos (USER.165)
1011 void WINAPI SetCaretPos16( INT16 x, INT16 y )
1013 SetCaretPos( x, y );
1017 /**************************************************************************
1018 * HideCaret (USER.166)
1020 void WINAPI HideCaret16( HWND16 hwnd )
1022 HideCaret( WIN_Handle32(hwnd) );
1026 /**************************************************************************
1027 * ShowCaret (USER.167)
1029 void WINAPI ShowCaret16( HWND16 hwnd )
1031 ShowCaret( WIN_Handle32(hwnd) );
1035 /*****************************************************************
1036 * SetCaretBlinkTime (USER.168)
1038 void WINAPI SetCaretBlinkTime16( UINT16 msecs )
1040 SetCaretBlinkTime( msecs );
1044 /*****************************************************************
1045 * GetCaretBlinkTime (USER.169)
1047 UINT16 WINAPI GetCaretBlinkTime16(void)
1049 return GetCaretBlinkTime();
1053 /**************************************************************************
1054 * ArrangeIconicWindows (USER.170)
1056 UINT16 WINAPI ArrangeIconicWindows16( HWND16 parent)
1058 return ArrangeIconicWindows( WIN_Handle32(parent) );
1062 /**************************************************************************
1063 * SwitchToThisWindow (USER.172)
1065 void WINAPI SwitchToThisWindow16( HWND16 hwnd, BOOL16 restore )
1067 SwitchToThisWindow( WIN_Handle32(hwnd), restore );
1071 /**************************************************************************
1072 * KillSystemTimer (USER.182)
1074 BOOL16 WINAPI KillSystemTimer16( HWND16 hwnd, UINT16 id )
1076 return KillSystemTimer( WIN_Handle32(hwnd), id );
1080 /*****************************************************************
1081 * GetCaretPos (USER.183)
1083 void WINAPI GetCaretPos16( LPPOINT16 pt16 )
1086 if (GetCaretPos( &pt ))
1094 /**************************************************************************
1095 * SetSysModalWindow (USER.188)
1097 HWND16 WINAPI SetSysModalWindow16( HWND16 hwnd )
1099 HWND16 old = hwndSysModal;
1100 hwndSysModal = hwnd;
1105 /**************************************************************************
1106 * GetSysModalWindow (USER.189)
1108 HWND16 WINAPI GetSysModalWindow16(void)
1110 return hwndSysModal;
1114 /**************************************************************************
1115 * GetUpdateRect (USER.190)
1117 BOOL16 WINAPI GetUpdateRect16( HWND16 hwnd, LPRECT16 rect, BOOL16 erase )
1122 if (!rect) return GetUpdateRect( WIN_Handle32(hwnd), NULL, erase );
1123 ret = GetUpdateRect( WIN_Handle32(hwnd), &r, erase );
1124 rect->left = r.left;
1126 rect->right = r.right;
1127 rect->bottom = r.bottom;
1132 /**************************************************************************
1133 * ChildWindowFromPoint (USER.191)
1135 HWND16 WINAPI ChildWindowFromPoint16( HWND16 hwndParent, POINT16 pt )
1141 return HWND_16( ChildWindowFromPoint( WIN_Handle32(hwndParent), pt32 ));
1145 /***********************************************************************
1146 * CascadeChildWindows (USER.198)
1148 void WINAPI CascadeChildWindows16( HWND16 parent, WORD action )
1150 CascadeWindows( WIN_Handle32(parent), action, NULL, 0, NULL );
1154 /***********************************************************************
1155 * TileChildWindows (USER.199)
1157 void WINAPI TileChildWindows16( HWND16 parent, WORD action )
1159 TileWindows( WIN_Handle32(parent), action, NULL, 0, NULL );
1163 /***********************************************************************
1164 * GetWindowTask (USER.224)
1166 HTASK16 WINAPI GetWindowTask16( HWND16 hwnd )
1168 DWORD tid = GetWindowThreadProcessId( HWND_32(hwnd), NULL );
1170 return HTASK_16(tid);
1173 /**********************************************************************
1174 * EnumTaskWindows (USER.225)
1176 BOOL16 WINAPI EnumTaskWindows16( HTASK16 hTask, WNDENUMPROC16 func, LPARAM lParam )
1178 struct wnd_enum_info info;
1179 DWORD tid = HTASK_32( hTask );
1181 if (!tid) return FALSE;
1183 info.param = lParam;
1184 return EnumThreadWindows( tid, wnd_enum_callback, (LPARAM)&info );
1188 /**************************************************************************
1189 * GetTopWindow (USER.229)
1191 HWND16 WINAPI GetTopWindow16( HWND16 hwnd )
1193 return HWND_16( GetTopWindow( WIN_Handle32(hwnd) ));
1197 /**************************************************************************
1198 * GetNextWindow (USER.230)
1200 HWND16 WINAPI GetNextWindow16( HWND16 hwnd, WORD flag )
1202 if ((flag != GW_HWNDNEXT) && (flag != GW_HWNDPREV)) return 0;
1203 return GetWindow16( hwnd, flag );
1207 /**************************************************************************
1208 * SetWindowPos (USER.232)
1210 BOOL16 WINAPI SetWindowPos16( HWND16 hwnd, HWND16 hwndInsertAfter,
1211 INT16 x, INT16 y, INT16 cx, INT16 cy, WORD flags)
1213 return SetWindowPos( WIN_Handle32(hwnd), full_insert_after_hwnd(hwndInsertAfter),
1214 x, y, cx, cy, flags );
1218 /**************************************************************************
1219 * SetParent (USER.233)
1221 HWND16 WINAPI SetParent16( HWND16 hwndChild, HWND16 hwndNewParent )
1223 return HWND_16( SetParent( WIN_Handle32(hwndChild), WIN_Handle32(hwndNewParent) ));
1227 /**************************************************************************
1228 * GetCapture (USER.236)
1230 HWND16 WINAPI GetCapture16(void)
1232 return HWND_16( GetCapture() );
1236 /**************************************************************************
1237 * GetUpdateRgn (USER.237)
1239 INT16 WINAPI GetUpdateRgn16( HWND16 hwnd, HRGN16 hrgn, BOOL16 erase )
1241 return GetUpdateRgn( WIN_Handle32(hwnd), HRGN_32(hrgn), erase );
1245 /**************************************************************************
1246 * ExcludeUpdateRgn (USER.238)
1248 INT16 WINAPI ExcludeUpdateRgn16( HDC16 hdc, HWND16 hwnd )
1250 return ExcludeUpdateRgn( HDC_32(hdc), WIN_Handle32(hwnd) );
1254 /**************************************************************************
1255 * GetOpenClipboardWindow (USER.248)
1257 HWND16 WINAPI GetOpenClipboardWindow16(void)
1259 return HWND_16( GetOpenClipboardWindow() );
1263 /*******************************************************************
1264 * MapWindowPoints (USER.258)
1266 void WINAPI MapWindowPoints16( HWND16 hwndFrom, HWND16 hwndTo, LPPOINT16 lppt, UINT16 count )
1268 POINT buffer[8], *ppt = buffer;
1271 if (count > 8) ppt = HeapAlloc( GetProcessHeap(), 0, count * sizeof(*ppt) );
1272 for (i = 0; i < count; i++)
1274 ppt[i].x = lppt[i].x;
1275 ppt[i].y = lppt[i].y;
1277 MapWindowPoints( WIN_Handle32(hwndFrom), WIN_Handle32(hwndTo), ppt, count );
1278 for (i = 0; i < count; i++)
1280 lppt[i].x = ppt[i].x;
1281 lppt[i].y = ppt[i].y;
1283 if (ppt != buffer) HeapFree( GetProcessHeap(), 0, ppt );
1287 /**************************************************************************
1288 * BeginDeferWindowPos (USER.259)
1290 HDWP16 WINAPI BeginDeferWindowPos16( INT16 count )
1292 return HDWP_16(BeginDeferWindowPos( count ));
1296 /**************************************************************************
1297 * DeferWindowPos (USER.260)
1299 HDWP16 WINAPI DeferWindowPos16( HDWP16 hdwp, HWND16 hwnd, HWND16 hwndAfter,
1300 INT16 x, INT16 y, INT16 cx, INT16 cy,
1303 return HDWP_16(DeferWindowPos( HDWP_32(hdwp), WIN_Handle32(hwnd),
1304 full_insert_after_hwnd(hwndAfter), x, y, cx, cy, flags ));
1308 /**************************************************************************
1309 * EndDeferWindowPos (USER.261)
1311 BOOL16 WINAPI EndDeferWindowPos16( HDWP16 hdwp )
1313 return EndDeferWindowPos(HDWP_32(hdwp));
1317 /**************************************************************************
1318 * GetWindow (USER.262)
1320 HWND16 WINAPI GetWindow16( HWND16 hwnd, WORD rel )
1322 return HWND_16( GetWindow( WIN_Handle32(hwnd), rel ) );
1326 /**************************************************************************
1327 * ShowOwnedPopups (USER.265)
1329 void WINAPI ShowOwnedPopups16( HWND16 owner, BOOL16 fShow )
1331 ShowOwnedPopups( WIN_Handle32(owner), fShow );
1335 /**************************************************************************
1336 * ShowScrollBar (USER.267)
1338 void WINAPI ShowScrollBar16( HWND16 hwnd, INT16 nBar, BOOL16 fShow )
1340 ShowScrollBar( WIN_Handle32(hwnd), nBar, fShow );
1344 /**************************************************************************
1345 * IsZoomed (USER.272)
1347 BOOL16 WINAPI IsZoomed16(HWND16 hwnd)
1349 return IsZoomed( WIN_Handle32(hwnd) );
1353 /**************************************************************************
1354 * GetDlgCtrlID (USER.277)
1356 INT16 WINAPI GetDlgCtrlID16( HWND16 hwnd )
1358 return GetDlgCtrlID( WIN_Handle32(hwnd) );
1362 /**************************************************************************
1363 * GetDesktopHwnd (USER.278)
1365 * Exactly the same thing as GetDesktopWindow(), but not documented.
1366 * Don't ask me why...
1368 HWND16 WINAPI GetDesktopHwnd16(void)
1370 return GetDesktopWindow16();
1374 /**************************************************************************
1375 * SetSystemMenu (USER.280)
1377 BOOL16 WINAPI SetSystemMenu16( HWND16 hwnd, HMENU16 hMenu )
1379 return SetSystemMenu( WIN_Handle32(hwnd), HMENU_32(hMenu) );
1383 /**************************************************************************
1384 * GetDesktopWindow (USER.286)
1386 HWND16 WINAPI GetDesktopWindow16(void)
1388 return HWND_16( GetDesktopWindow() );
1392 /**************************************************************************
1393 * GetLastActivePopup (USER.287)
1395 HWND16 WINAPI GetLastActivePopup16( HWND16 hwnd )
1397 return HWND_16( GetLastActivePopup( WIN_Handle32(hwnd) ));
1401 /**************************************************************************
1402 * RedrawWindow (USER.290)
1404 BOOL16 WINAPI RedrawWindow16( HWND16 hwnd, const RECT16 *rectUpdate,
1405 HRGN16 hrgnUpdate, UINT16 flags )
1410 r.left = rectUpdate->left;
1411 r.top = rectUpdate->top;
1412 r.right = rectUpdate->right;
1413 r.bottom = rectUpdate->bottom;
1414 return RedrawWindow(WIN_Handle32(hwnd), &r, HRGN_32(hrgnUpdate), flags);
1416 return RedrawWindow(WIN_Handle32(hwnd), NULL, HRGN_32(hrgnUpdate), flags);
1420 /**************************************************************************
1421 * LockWindowUpdate (USER.294)
1423 BOOL16 WINAPI LockWindowUpdate16( HWND16 hwnd )
1425 return LockWindowUpdate( WIN_Handle32(hwnd) );
1429 /**************************************************************************
1430 * ScrollWindowEx (USER.319)
1432 INT16 WINAPI ScrollWindowEx16( HWND16 hwnd, INT16 dx, INT16 dy,
1433 const RECT16 *rect, const RECT16 *clipRect,
1434 HRGN16 hrgnUpdate, LPRECT16 rcUpdate,
1437 RECT rect32, clipRect32, rcUpdate32;
1442 rect32.left = rect->left;
1443 rect32.top = rect->top;
1444 rect32.right = rect->right;
1445 rect32.bottom = rect->bottom;
1449 clipRect32.left = clipRect->left;
1450 clipRect32.top = clipRect->top;
1451 clipRect32.right = clipRect->right;
1452 clipRect32.bottom = clipRect->bottom;
1454 ret = ScrollWindowEx( WIN_Handle32(hwnd), dx, dy, rect ? &rect32 : NULL,
1455 clipRect ? &clipRect32 : NULL, HRGN_32(hrgnUpdate),
1456 (rcUpdate) ? &rcUpdate32 : NULL, flags );
1459 rcUpdate->left = rcUpdate32.left;
1460 rcUpdate->top = rcUpdate32.top;
1461 rcUpdate->right = rcUpdate32.right;
1462 rcUpdate->bottom = rcUpdate32.bottom;
1468 /**************************************************************************
1469 * FillWindow (USER.324)
1471 void WINAPI FillWindow16( HWND16 hwndParent, HWND16 hwnd, HDC16 hdc, HBRUSH16 hbrush )
1475 GetClientRect( WIN_Handle32(hwnd), &rect );
1476 DPtoLP( HDC_32(hdc), (LPPOINT)&rect, 2 );
1477 rc16.left = rect.left;
1478 rc16.top = rect.top;
1479 rc16.right = rect.right;
1480 rc16.bottom = rect.bottom;
1481 PaintRect16( hwndParent, hwnd, hdc, hbrush, &rc16 );
1485 /**************************************************************************
1486 * PaintRect (USER.325)
1488 void WINAPI PaintRect16( HWND16 hwndParent, HWND16 hwnd, HDC16 hdc,
1489 HBRUSH16 hbrush, const RECT16 *rect)
1491 if (hbrush <= CTLCOLOR_STATIC)
1493 HWND parent = WIN_Handle32(hwndParent), hwnd32 = WIN_Handle32(hwnd);
1495 if (!parent) return;
1496 hbrush = SendMessageW( parent, WM_CTLCOLORMSGBOX + hbrush, (WPARAM)hdc, (LPARAM)hwnd32 );
1497 if (!hbrush) hbrush = DefWindowProcW( parent, WM_CTLCOLORMSGBOX + hbrush,
1498 (WPARAM)hdc, (LPARAM)hwnd32 );
1500 if (hbrush) FillRect16( hdc, rect, hbrush );
1504 /**************************************************************************
1505 * GetControlBrush (USER.326)
1507 HBRUSH16 WINAPI GetControlBrush16( HWND16 hwnd, HDC16 hdc, UINT16 ctlType )
1510 HWND hwnd32 = WIN_Handle32(hwnd);
1511 HWND parent = GetParent( hwnd32 );
1513 if (!parent) parent = hwnd32;
1514 ret = SendMessageW( parent, WM_CTLCOLORMSGBOX + ctlType, (WPARAM)hdc, (LPARAM)hwnd32 );
1515 if (!ret) ret = DefWindowProcW( parent, WM_CTLCOLORMSGBOX + ctlType,
1516 (WPARAM)hdc, (LPARAM)hwnd32 );
1521 /**************************************************************************
1522 * GetDCEx (USER.359)
1524 HDC16 WINAPI GetDCEx16( HWND16 hwnd, HRGN16 hrgnClip, DWORD flags )
1526 return HDC_16(GetDCEx(WIN_Handle32(hwnd), HRGN_32(hrgnClip), flags));
1530 /**************************************************************************
1531 * GetWindowPlacement (USER.370)
1533 BOOL16 WINAPI GetWindowPlacement16( HWND16 hwnd, WINDOWPLACEMENT16 *wp16 )
1535 WINDOWPLACEMENT wpl;
1537 wpl.length = sizeof(wpl);
1538 if (!GetWindowPlacement( WIN_Handle32(hwnd), &wpl )) return FALSE;
1539 wp16->length = sizeof(*wp16);
1540 wp16->flags = wpl.flags;
1541 wp16->showCmd = wpl.showCmd;
1542 wp16->ptMinPosition.x = wpl.ptMinPosition.x;
1543 wp16->ptMinPosition.y = wpl.ptMinPosition.y;
1544 wp16->ptMaxPosition.x = wpl.ptMaxPosition.x;
1545 wp16->ptMaxPosition.y = wpl.ptMaxPosition.y;
1546 wp16->rcNormalPosition.left = wpl.rcNormalPosition.left;
1547 wp16->rcNormalPosition.top = wpl.rcNormalPosition.top;
1548 wp16->rcNormalPosition.right = wpl.rcNormalPosition.right;
1549 wp16->rcNormalPosition.bottom = wpl.rcNormalPosition.bottom;
1554 /**************************************************************************
1555 * SetWindowPlacement (USER.371)
1557 BOOL16 WINAPI SetWindowPlacement16( HWND16 hwnd, const WINDOWPLACEMENT16 *wp16 )
1559 WINDOWPLACEMENT wpl;
1561 if (!wp16) return FALSE;
1562 wpl.length = sizeof(wpl);
1563 wpl.flags = wp16->flags;
1564 wpl.showCmd = wp16->showCmd;
1565 wpl.ptMinPosition.x = wp16->ptMinPosition.x;
1566 wpl.ptMinPosition.y = wp16->ptMinPosition.y;
1567 wpl.ptMaxPosition.x = wp16->ptMaxPosition.x;
1568 wpl.ptMaxPosition.y = wp16->ptMaxPosition.y;
1569 wpl.rcNormalPosition.left = wp16->rcNormalPosition.left;
1570 wpl.rcNormalPosition.top = wp16->rcNormalPosition.top;
1571 wpl.rcNormalPosition.right = wp16->rcNormalPosition.right;
1572 wpl.rcNormalPosition.bottom = wp16->rcNormalPosition.bottom;
1573 return SetWindowPlacement( WIN_Handle32(hwnd), &wpl );
1577 /***********************************************************************
1578 * RegisterClassEx (USER.397)
1580 ATOM WINAPI RegisterClassEx16( const WNDCLASSEX16 *wc )
1582 struct class_entry *class;
1587 inst = GetExePtr( wc->hInstance );
1588 if (!inst) inst = GetModuleHandle16( NULL );
1590 wc32.cbSize = sizeof(wc32);
1591 wc32.style = wc->style;
1592 wc32.lpfnWndProc = WINPROC_AllocProc16( wc->lpfnWndProc );
1593 wc32.cbClsExtra = wc->cbClsExtra;
1594 wc32.cbWndExtra = wc->cbWndExtra;
1595 wc32.hInstance = HINSTANCE_32(inst);
1596 wc32.hIcon = HICON_32(wc->hIcon);
1597 wc32.hCursor = HCURSOR_32(wc->hCursor);
1598 wc32.hbrBackground = HBRUSH_32(wc->hbrBackground);
1599 wc32.lpszMenuName = MapSL(wc->lpszMenuName);
1600 wc32.lpszClassName = MapSL(wc->lpszClassName);
1601 wc32.hIconSm = HICON_32(wc->hIconSm);
1602 atom = RegisterClassExA( &wc32 );
1603 if ((class = HeapAlloc( GetProcessHeap(), 0, sizeof(*class) )))
1607 list_add_tail( &class_list, &class->entry );
1613 /***********************************************************************
1614 * GetClassInfoEx (USER.398)
1616 * FIXME: this is just a guess, I have no idea if GetClassInfoEx() is the
1617 * same in Win16 as in Win32. --AJ
1619 BOOL16 WINAPI GetClassInfoEx16( HINSTANCE16 hInst16, SEGPTR name, WNDCLASSEX16 *wc )
1622 HINSTANCE hInstance;
1625 if (hInst16 == GetModuleHandle16("user")) hInstance = user32_module;
1626 else hInstance = HINSTANCE_32(GetExePtr( hInst16 ));
1628 ret = GetClassInfoExA( hInstance, MapSL(name), &wc32 );
1632 wc->lpfnWndProc = WINPROC_GetProc16( wc32.lpfnWndProc, FALSE );
1633 wc->style = wc32.style;
1634 wc->cbClsExtra = wc32.cbClsExtra;
1635 wc->cbWndExtra = wc32.cbWndExtra;
1636 wc->hInstance = (wc32.hInstance == user32_module) ? GetModuleHandle16("user") : HINSTANCE_16(wc32.hInstance);
1637 wc->hIcon = HICON_16(wc32.hIcon);
1638 wc->hIconSm = HICON_16(wc32.hIconSm);
1639 wc->hCursor = HCURSOR_16(wc32.hCursor);
1640 wc->hbrBackground = HBRUSH_16(wc32.hbrBackground);
1641 wc->lpszClassName = 0;
1642 wc->lpszMenuName = MapLS(wc32.lpszMenuName); /* FIXME: leak */
1648 /**************************************************************************
1649 * ChildWindowFromPointEx (USER.399)
1651 HWND16 WINAPI ChildWindowFromPointEx16( HWND16 hwndParent, POINT16 pt, UINT16 uFlags)
1657 return HWND_16( ChildWindowFromPointEx( WIN_Handle32(hwndParent), pt32, uFlags ));
1661 /**************************************************************************
1662 * GetPriorityClipboardFormat (USER.402)
1664 INT16 WINAPI GetPriorityClipboardFormat16( UINT16 *list, INT16 count )
1668 for (i = 0; i < count; i++)
1669 if (IsClipboardFormatAvailable( list[i] )) return list[i];
1674 /***********************************************************************
1675 * UnregisterClass (USER.403)
1677 BOOL16 WINAPI UnregisterClass16( LPCSTR className, HINSTANCE16 hInstance )
1681 if (hInstance == GetModuleHandle16("user")) hInstance = 0;
1682 else hInstance = GetExePtr( hInstance );
1684 if ((atom = GlobalFindAtomA( className )))
1686 struct class_entry *class;
1687 LIST_FOR_EACH_ENTRY( class, &class_list, struct class_entry, entry )
1689 if (class->inst != hInstance) continue;
1690 if (class->atom != atom) continue;
1691 list_remove( &class->entry );
1692 HeapFree( GetProcessHeap(), 0, class );
1696 return UnregisterClassA( className, HINSTANCE_32(hInstance) );
1700 /***********************************************************************
1701 * GetClassInfo (USER.404)
1703 BOOL16 WINAPI GetClassInfo16( HINSTANCE16 hInst16, SEGPTR name, WNDCLASS16 *wc )
1706 UINT16 ret = GetClassInfoEx16( hInst16, name, &wcex );
1710 wc->style = wcex.style;
1711 wc->lpfnWndProc = wcex.lpfnWndProc;
1712 wc->cbClsExtra = wcex.cbClsExtra;
1713 wc->cbWndExtra = wcex.cbWndExtra;
1714 wc->hInstance = wcex.hInstance;
1715 wc->hIcon = wcex.hIcon;
1716 wc->hCursor = wcex.hCursor;
1717 wc->hbrBackground = wcex.hbrBackground;
1718 wc->lpszMenuName = wcex.lpszMenuName;
1719 wc->lpszClassName = wcex.lpszClassName;
1725 /**************************************************************************
1726 * TrackPopupMenu (USER.416)
1728 BOOL16 WINAPI TrackPopupMenu16( HMENU16 hMenu, UINT16 wFlags, INT16 x, INT16 y,
1729 INT16 nReserved, HWND16 hwnd, const RECT16 *lpRect )
1734 r.left = lpRect->left;
1735 r.top = lpRect->top;
1736 r.right = lpRect->right;
1737 r.bottom = lpRect->bottom;
1739 return TrackPopupMenu( HMENU_32(hMenu), wFlags, x, y, nReserved,
1740 WIN_Handle32(hwnd), lpRect ? &r : NULL );
1744 /**************************************************************************
1745 * FindWindowEx (USER.427)
1747 HWND16 WINAPI FindWindowEx16( HWND16 parent, HWND16 child, LPCSTR className, LPCSTR title )
1749 return HWND_16( FindWindowExA( WIN_Handle32(parent), WIN_Handle32(child),
1750 className, title ));
1754 /***********************************************************************
1755 * DefFrameProc (USER.445)
1757 LRESULT WINAPI DefFrameProc16( HWND16 hwnd, HWND16 hwndMDIClient,
1758 UINT16 message, WPARAM16 wParam, LPARAM lParam )
1763 lParam = (LPARAM)MapSL(lParam);
1769 return DefFrameProcA( WIN_Handle32(hwnd), WIN_Handle32(hwndMDIClient),
1770 message, wParam, lParam );
1774 MDINEXTMENU next_menu;
1775 DefFrameProcW( WIN_Handle32(hwnd), WIN_Handle32(hwndMDIClient),
1776 message, wParam, (LPARAM)&next_menu );
1777 return MAKELONG( HMENU_16(next_menu.hmenuNext), HWND_16(next_menu.hwndNext) );
1780 return DefWindowProc16(hwnd, message, wParam, lParam);
1785 /***********************************************************************
1786 * DefMDIChildProc (USER.447)
1788 LRESULT WINAPI DefMDIChildProc16( HWND16 hwnd, UINT16 message,
1789 WPARAM16 wParam, LPARAM lParam )
1794 return DefMDIChildProcA( WIN_Handle32(hwnd), message, wParam, (LPARAM)MapSL(lParam) );
1799 case WM_CHILDACTIVATE:
1804 return DefMDIChildProcW( WIN_Handle32(hwnd), message, wParam, lParam );
1806 case WM_GETMINMAXINFO:
1808 MINMAXINFO16 *mmi16 = MapSL(lParam);
1811 mmi.ptReserved.x = mmi16->ptReserved.x;
1812 mmi.ptReserved.y = mmi16->ptReserved.y;
1813 mmi.ptMaxSize.x = mmi16->ptMaxSize.x;
1814 mmi.ptMaxSize.y = mmi16->ptMaxSize.y;
1815 mmi.ptMaxPosition.x = mmi16->ptMaxPosition.x;
1816 mmi.ptMaxPosition.y = mmi16->ptMaxPosition.y;
1817 mmi.ptMinTrackSize.x = mmi16->ptMinTrackSize.x;
1818 mmi.ptMinTrackSize.y = mmi16->ptMinTrackSize.y;
1819 mmi.ptMaxTrackSize.x = mmi16->ptMaxTrackSize.x;
1820 mmi.ptMaxTrackSize.y = mmi16->ptMaxTrackSize.y;
1822 DefMDIChildProcW( WIN_Handle32(hwnd), message, wParam, (LPARAM)&mmi );
1824 mmi16->ptReserved.x = mmi.ptReserved.x;
1825 mmi16->ptReserved.y = mmi.ptReserved.y;
1826 mmi16->ptMaxSize.x = mmi.ptMaxSize.x;
1827 mmi16->ptMaxSize.y = mmi.ptMaxSize.y;
1828 mmi16->ptMaxPosition.x = mmi.ptMaxPosition.x;
1829 mmi16->ptMaxPosition.y = mmi.ptMaxPosition.y;
1830 mmi16->ptMinTrackSize.x = mmi.ptMinTrackSize.x;
1831 mmi16->ptMinTrackSize.y = mmi.ptMinTrackSize.y;
1832 mmi16->ptMaxTrackSize.x = mmi.ptMaxTrackSize.x;
1833 mmi16->ptMaxTrackSize.y = mmi.ptMaxTrackSize.y;
1838 MDINEXTMENU next_menu;
1839 DefMDIChildProcW( WIN_Handle32(hwnd), message, wParam, (LPARAM)&next_menu );
1840 return MAKELONG( HMENU_16(next_menu.hmenuNext), HWND_16(next_menu.hwndNext) );
1843 return DefWindowProc16(hwnd, message, wParam, lParam);
1848 /**************************************************************************
1849 * DrawAnimatedRects (USER.448)
1851 BOOL16 WINAPI DrawAnimatedRects16( HWND16 hwnd, INT16 idAni,
1852 const RECT16* lprcFrom, const RECT16* lprcTo )
1854 RECT rcFrom32, rcTo32;
1855 rcFrom32.left = lprcFrom->left;
1856 rcFrom32.top = lprcFrom->top;
1857 rcFrom32.right = lprcFrom->right;
1858 rcFrom32.bottom = lprcFrom->bottom;
1859 rcTo32.left = lprcTo->left;
1860 rcTo32.top = lprcTo->top;
1861 rcTo32.right = lprcTo->right;
1862 rcTo32.bottom = lprcTo->bottom;
1863 return DrawAnimatedRects( WIN_Handle32(hwnd), idAni, &rcFrom32, &rcTo32 );
1867 /***********************************************************************
1868 * CreateWindowEx (USER.452)
1870 HWND16 WINAPI CreateWindowEx16( DWORD exStyle, LPCSTR className,
1871 LPCSTR windowName, DWORD style, INT16 x,
1872 INT16 y, INT16 width, INT16 height,
1873 HWND16 parent, HMENU16 menu,
1874 HINSTANCE16 instance, LPVOID data )
1880 /* Fix the coordinates */
1882 cs.x = (x == CW_USEDEFAULT16) ? CW_USEDEFAULT : (INT)x;
1883 cs.y = (y == CW_USEDEFAULT16) ? CW_USEDEFAULT : (INT)y;
1884 cs.cx = (width == CW_USEDEFAULT16) ? CW_USEDEFAULT : (INT)width;
1885 cs.cy = (height == CW_USEDEFAULT16) ? CW_USEDEFAULT : (INT)height;
1887 /* Create the window */
1889 cs.lpCreateParams = data;
1890 cs.hInstance = HINSTANCE_32(instance);
1891 cs.hMenu = HMENU_32(menu);
1892 cs.hwndParent = WIN_Handle32( parent );
1894 cs.lpszName = windowName;
1895 cs.lpszClass = className;
1896 cs.dwExStyle = exStyle;
1899 if (!menu && (style & (WS_CHILD | WS_POPUP)) != WS_CHILD)
1902 HINSTANCE16 module = GetExePtr( instance );
1904 if (GetClassInfoA( HINSTANCE_32(module), className, &class ))
1905 cs.hMenu = HMENU_32( LoadMenu16( module, class.lpszMenuName ));
1908 if (!IS_INTRESOURCE(className))
1912 if (!MultiByteToWideChar( CP_ACP, 0, className, -1, bufferW, sizeof(bufferW)/sizeof(WCHAR) ))
1914 hwnd = create_window16( (CREATESTRUCTW *)&cs, bufferW, HINSTANCE_32(instance), 0 );
1918 if (!GlobalGetAtomNameA( LOWORD(className), buffer, sizeof(buffer) )) return 0;
1919 cs.lpszClass = buffer;
1920 hwnd = create_window16( (CREATESTRUCTW *)&cs, (LPCWSTR)className, HINSTANCE_32(instance), 0 );
1922 return HWND_16( hwnd );
1926 /***********************************************************************
1927 * GetInternalWindowPos (USER.460)
1929 UINT16 WINAPI GetInternalWindowPos16( HWND16 hwnd, LPRECT16 rectWnd, LPPOINT16 ptIcon )
1931 WINDOWPLACEMENT16 wndpl;
1933 if (!GetWindowPlacement16( hwnd, &wndpl )) return 0;
1934 if (rectWnd) *rectWnd = wndpl.rcNormalPosition;
1935 if (ptIcon) *ptIcon = wndpl.ptMinPosition;
1936 return wndpl.showCmd;
1940 /**************************************************************************
1941 * SetInternalWindowPos (USER.461)
1943 void WINAPI SetInternalWindowPos16( HWND16 hwnd, UINT16 showCmd, LPRECT16 rect, LPPOINT16 pt )
1950 rc32.left = rect->left;
1951 rc32.top = rect->top;
1952 rc32.right = rect->right;
1953 rc32.bottom = rect->bottom;
1960 SetInternalWindowPos( WIN_Handle32(hwnd), showCmd,
1961 rect ? &rc32 : NULL, pt ? &pt32 : NULL );
1965 /**************************************************************************
1966 * CalcChildScroll (USER.462)
1968 void WINAPI CalcChildScroll16( HWND16 hwnd, WORD scroll )
1970 CalcChildScroll( WIN_Handle32(hwnd), scroll );
1974 /**************************************************************************
1975 * ScrollChildren (USER.463)
1977 void WINAPI ScrollChildren16(HWND16 hwnd, UINT16 uMsg, WPARAM16 wParam, LPARAM lParam)
1979 ScrollChildren( WIN_Handle32(hwnd), uMsg, wParam, lParam );
1983 /**************************************************************************
1984 * DragDetect (USER.465)
1986 BOOL16 WINAPI DragDetect16( HWND16 hwnd, POINT16 pt )
1992 return DragDetect( WIN_Handle32(hwnd), pt32 );
1996 /**************************************************************************
1997 * SetScrollInfo (USER.475)
1999 INT16 WINAPI SetScrollInfo16( HWND16 hwnd, INT16 nBar, const SCROLLINFO *info, BOOL16 redraw )
2001 return SetScrollInfo( WIN_Handle32(hwnd), nBar, info, redraw );
2005 /**************************************************************************
2006 * GetScrollInfo (USER.476)
2008 BOOL16 WINAPI GetScrollInfo16( HWND16 hwnd, INT16 nBar, LPSCROLLINFO info )
2010 return GetScrollInfo( WIN_Handle32(hwnd), nBar, info );
2014 /**************************************************************************
2015 * EnableScrollBar (USER.482)
2017 BOOL16 WINAPI EnableScrollBar16( HWND16 hwnd, INT16 nBar, UINT16 flags )
2019 return EnableScrollBar( WIN_Handle32(hwnd), nBar, flags );
2023 /**************************************************************************
2024 * GetShellWindow (USER.600)
2026 HWND16 WINAPI GetShellWindow16(void)
2028 return HWND_16( GetShellWindow() );
2032 /**************************************************************************
2033 * GetForegroundWindow (USER.608)
2035 HWND16 WINAPI GetForegroundWindow16(void)
2037 return HWND_16( GetForegroundWindow() );
2041 /**************************************************************************
2042 * SetForegroundWindow (USER.609)
2044 BOOL16 WINAPI SetForegroundWindow16( HWND16 hwnd )
2046 return SetForegroundWindow( WIN_Handle32(hwnd) );
2050 /**************************************************************************
2051 * DrawCaptionTemp (USER.657)
2053 BOOL16 WINAPI DrawCaptionTemp16( HWND16 hwnd, HDC16 hdc, const RECT16 *rect,
2054 HFONT16 hFont, HICON16 hIcon, LPCSTR str, UINT16 uFlags )
2060 rect32.left = rect->left;
2061 rect32.top = rect->top;
2062 rect32.right = rect->right;
2063 rect32.bottom = rect->bottom;
2065 return DrawCaptionTempA( WIN_Handle32(hwnd), HDC_32(hdc),
2066 rect ? &rect32 : NULL, HFONT_32(hFont),
2067 HICON_32(hIcon), str, uFlags & 0x1f );
2071 /**************************************************************************
2072 * DrawCaption (USER.660)
2074 BOOL16 WINAPI DrawCaption16( HWND16 hwnd, HDC16 hdc, const RECT16 *rect, UINT16 flags )
2080 rect32.left = rect->left;
2081 rect32.top = rect->top;
2082 rect32.right = rect->right;
2083 rect32.bottom = rect->bottom;
2085 return DrawCaption(WIN_Handle32(hwnd), HDC_32(hdc), rect ? &rect32 : NULL, flags);
2089 /**************************************************************************
2090 * GetMenuItemRect (USER.665)
2092 BOOL16 WINAPI GetMenuItemRect16( HWND16 hwnd, HMENU16 hMenu, UINT16 uItem,
2097 if (!rect) return FALSE;
2098 res = GetMenuItemRect( WIN_Handle32(hwnd), HMENU_32(hMenu), uItem, &r32 );
2099 rect->left = r32.left;
2100 rect->top = r32.top;
2101 rect->right = r32.right;
2102 rect->bottom = r32.bottom;
2107 /**************************************************************************
2108 * SetWindowRgn (USER.668)
2110 INT16 WINAPI SetWindowRgn16( HWND16 hwnd, HRGN16 hrgn, BOOL16 redraw )
2112 return SetWindowRgn( WIN_Handle32(hwnd), HRGN_32(hrgn), redraw );
2116 /**************************************************************************
2117 * MessageBoxIndirect (USER.827)
2119 INT16 WINAPI MessageBoxIndirect16( LPMSGBOXPARAMS16 msgbox )
2121 MSGBOXPARAMSA msgbox32;
2123 msgbox32.cbSize = msgbox->cbSize;
2124 msgbox32.hwndOwner = WIN_Handle32( msgbox->hwndOwner );
2125 msgbox32.hInstance = HINSTANCE_32(msgbox->hInstance);
2126 msgbox32.lpszText = MapSL(msgbox->lpszText);
2127 msgbox32.lpszCaption = MapSL(msgbox->lpszCaption);
2128 msgbox32.dwStyle = msgbox->dwStyle;
2129 msgbox32.lpszIcon = MapSL(msgbox->lpszIcon);
2130 msgbox32.dwContextHelpId = msgbox->dwContextHelpId;
2131 msgbox32.lpfnMsgBoxCallback = msgbox->lpfnMsgBoxCallback;
2132 msgbox32.dwLanguageId = msgbox->dwLanguageId;
2133 return MessageBoxIndirectA( &msgbox32 );