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 hwnd16, INT16 offset )
826 HWND hwnd = WIN_Handle32( hwnd16 );
828 BOOL is_winproc = (offset == GWLP_WNDPROC);
832 int cbWndExtra = GetClassLongA( hwnd, GCL_CBWNDEXTRA );
834 if (offset > (int)(cbWndExtra - sizeof(LONG)))
837 * Some programs try to access last element from 16 bit
838 * code using illegal offset value. Hopefully this is
839 * what those programs really expect.
841 if (cbWndExtra >= 4 && offset == cbWndExtra - sizeof(WORD))
843 offset = cbWndExtra - sizeof(LONG);
847 SetLastError( ERROR_INVALID_INDEX );
851 else if (offset == DWLP_DLGPROC) is_winproc = (DIALOG_get_info( hwnd, FALSE ) != NULL);
853 retvalue = GetWindowLongA( hwnd, offset );
854 if (is_winproc) retvalue = (LONG_PTR)WINPROC_GetProc16( (WNDPROC)retvalue, FALSE );
859 /**********************************************************************
860 * SetWindowLong (USER.136)
862 LONG WINAPI SetWindowLong16( HWND16 hwnd16, INT16 offset, LONG newval )
864 HWND hwnd = WIN_Handle32( hwnd16 );
865 BOOL is_winproc = (offset == GWLP_WNDPROC);
867 if (offset == DWLP_DLGPROC) is_winproc = (DIALOG_get_info( hwnd, FALSE ) != NULL);
871 WNDPROC new_proc = WINPROC_AllocProc16( (WNDPROC16)newval );
872 WNDPROC old_proc = (WNDPROC)SetWindowLongPtrA( hwnd, offset, (LONG_PTR)new_proc );
873 return (LONG)WINPROC_GetProc16( old_proc, FALSE );
875 else return SetWindowLongA( hwnd, offset, newval );
879 /**************************************************************************
880 * OpenClipboard (USER.137)
882 BOOL16 WINAPI OpenClipboard16( HWND16 hwnd )
884 return OpenClipboard( WIN_Handle32(hwnd) );
888 /**************************************************************************
889 * GetClipboardOwner (USER.140)
891 HWND16 WINAPI GetClipboardOwner16(void)
893 return HWND_16( GetClipboardOwner() );
897 /**************************************************************************
898 * SetClipboardViewer (USER.147)
900 HWND16 WINAPI SetClipboardViewer16( HWND16 hwnd )
902 return HWND_16( SetClipboardViewer( WIN_Handle32(hwnd) ));
906 /**************************************************************************
907 * GetClipboardViewer (USER.148)
909 HWND16 WINAPI GetClipboardViewer16(void)
911 return HWND_16( GetClipboardViewer() );
915 /**************************************************************************
916 * ChangeClipboardChain (USER.149)
918 BOOL16 WINAPI ChangeClipboardChain16(HWND16 hwnd, HWND16 hwndNext)
920 return ChangeClipboardChain( WIN_Handle32(hwnd), WIN_Handle32(hwndNext) );
924 /**************************************************************************
925 * GetSystemMenu (USER.156)
927 HMENU16 WINAPI GetSystemMenu16( HWND16 hwnd, BOOL16 revert )
929 return HMENU_16(GetSystemMenu( WIN_Handle32(hwnd), revert ));
933 /**************************************************************************
936 HMENU16 WINAPI GetMenu16( HWND16 hwnd )
938 return HMENU_16(GetMenu( WIN_Handle32(hwnd) ));
942 /**************************************************************************
945 BOOL16 WINAPI SetMenu16( HWND16 hwnd, HMENU16 hMenu )
947 return SetMenu( WIN_Handle32(hwnd), HMENU_32(hMenu) );
951 /**************************************************************************
952 * DrawMenuBar (USER.160)
954 void WINAPI DrawMenuBar16( HWND16 hwnd )
956 DrawMenuBar( WIN_Handle32(hwnd) );
960 /**************************************************************************
961 * HiliteMenuItem (USER.162)
963 BOOL16 WINAPI HiliteMenuItem16( HWND16 hwnd, HMENU16 hMenu, UINT16 id, UINT16 wHilite )
965 return HiliteMenuItem( WIN_Handle32(hwnd), HMENU_32(hMenu), id, wHilite );
969 /**************************************************************************
970 * CreateCaret (USER.163)
972 void WINAPI CreateCaret16( HWND16 hwnd, HBITMAP16 bitmap, INT16 width, INT16 height )
974 CreateCaret( WIN_Handle32(hwnd), HBITMAP_32(bitmap), width, height );
978 /*****************************************************************
979 * DestroyCaret (USER.164)
981 void WINAPI DestroyCaret16(void)
987 /*****************************************************************
988 * SetCaretPos (USER.165)
990 void WINAPI SetCaretPos16( INT16 x, INT16 y )
996 /**************************************************************************
997 * HideCaret (USER.166)
999 void WINAPI HideCaret16( HWND16 hwnd )
1001 HideCaret( WIN_Handle32(hwnd) );
1005 /**************************************************************************
1006 * ShowCaret (USER.167)
1008 void WINAPI ShowCaret16( HWND16 hwnd )
1010 ShowCaret( WIN_Handle32(hwnd) );
1014 /*****************************************************************
1015 * SetCaretBlinkTime (USER.168)
1017 void WINAPI SetCaretBlinkTime16( UINT16 msecs )
1019 SetCaretBlinkTime( msecs );
1023 /*****************************************************************
1024 * GetCaretBlinkTime (USER.169)
1026 UINT16 WINAPI GetCaretBlinkTime16(void)
1028 return GetCaretBlinkTime();
1032 /**************************************************************************
1033 * ArrangeIconicWindows (USER.170)
1035 UINT16 WINAPI ArrangeIconicWindows16( HWND16 parent)
1037 return ArrangeIconicWindows( WIN_Handle32(parent) );
1041 /**************************************************************************
1042 * SwitchToThisWindow (USER.172)
1044 void WINAPI SwitchToThisWindow16( HWND16 hwnd, BOOL16 restore )
1046 SwitchToThisWindow( WIN_Handle32(hwnd), restore );
1050 /**************************************************************************
1051 * KillSystemTimer (USER.182)
1053 BOOL16 WINAPI KillSystemTimer16( HWND16 hwnd, UINT16 id )
1055 return KillSystemTimer( WIN_Handle32(hwnd), id );
1059 /*****************************************************************
1060 * GetCaretPos (USER.183)
1062 void WINAPI GetCaretPos16( LPPOINT16 pt16 )
1065 if (GetCaretPos( &pt ))
1073 /**************************************************************************
1074 * SetSysModalWindow (USER.188)
1076 HWND16 WINAPI SetSysModalWindow16( HWND16 hwnd )
1078 HWND16 old = hwndSysModal;
1079 hwndSysModal = hwnd;
1084 /**************************************************************************
1085 * GetSysModalWindow (USER.189)
1087 HWND16 WINAPI GetSysModalWindow16(void)
1089 return hwndSysModal;
1093 /**************************************************************************
1094 * GetUpdateRect (USER.190)
1096 BOOL16 WINAPI GetUpdateRect16( HWND16 hwnd, LPRECT16 rect, BOOL16 erase )
1101 if (!rect) return GetUpdateRect( WIN_Handle32(hwnd), NULL, erase );
1102 ret = GetUpdateRect( WIN_Handle32(hwnd), &r, erase );
1103 rect->left = r.left;
1105 rect->right = r.right;
1106 rect->bottom = r.bottom;
1111 /**************************************************************************
1112 * ChildWindowFromPoint (USER.191)
1114 HWND16 WINAPI ChildWindowFromPoint16( HWND16 hwndParent, POINT16 pt )
1120 return HWND_16( ChildWindowFromPoint( WIN_Handle32(hwndParent), pt32 ));
1124 /***********************************************************************
1125 * CascadeChildWindows (USER.198)
1127 void WINAPI CascadeChildWindows16( HWND16 parent, WORD action )
1129 CascadeWindows( WIN_Handle32(parent), action, NULL, 0, NULL );
1133 /***********************************************************************
1134 * TileChildWindows (USER.199)
1136 void WINAPI TileChildWindows16( HWND16 parent, WORD action )
1138 TileWindows( WIN_Handle32(parent), action, NULL, 0, NULL );
1142 /***********************************************************************
1143 * GetWindowTask (USER.224)
1145 HTASK16 WINAPI GetWindowTask16( HWND16 hwnd )
1147 DWORD tid = GetWindowThreadProcessId( HWND_32(hwnd), NULL );
1149 return HTASK_16(tid);
1152 /**********************************************************************
1153 * EnumTaskWindows (USER.225)
1155 BOOL16 WINAPI EnumTaskWindows16( HTASK16 hTask, WNDENUMPROC16 func, LPARAM lParam )
1157 struct wnd_enum_info info;
1158 DWORD tid = HTASK_32( hTask );
1160 if (!tid) return FALSE;
1162 info.param = lParam;
1163 return EnumThreadWindows( tid, wnd_enum_callback, (LPARAM)&info );
1167 /**************************************************************************
1168 * GetTopWindow (USER.229)
1170 HWND16 WINAPI GetTopWindow16( HWND16 hwnd )
1172 return HWND_16( GetTopWindow( WIN_Handle32(hwnd) ));
1176 /**************************************************************************
1177 * GetNextWindow (USER.230)
1179 HWND16 WINAPI GetNextWindow16( HWND16 hwnd, WORD flag )
1181 if ((flag != GW_HWNDNEXT) && (flag != GW_HWNDPREV)) return 0;
1182 return GetWindow16( hwnd, flag );
1186 /**************************************************************************
1187 * SetWindowPos (USER.232)
1189 BOOL16 WINAPI SetWindowPos16( HWND16 hwnd, HWND16 hwndInsertAfter,
1190 INT16 x, INT16 y, INT16 cx, INT16 cy, WORD flags)
1192 return SetWindowPos( WIN_Handle32(hwnd), full_insert_after_hwnd(hwndInsertAfter),
1193 x, y, cx, cy, flags );
1197 /**************************************************************************
1198 * SetParent (USER.233)
1200 HWND16 WINAPI SetParent16( HWND16 hwndChild, HWND16 hwndNewParent )
1202 return HWND_16( SetParent( WIN_Handle32(hwndChild), WIN_Handle32(hwndNewParent) ));
1206 /**************************************************************************
1207 * GetCapture (USER.236)
1209 HWND16 WINAPI GetCapture16(void)
1211 return HWND_16( GetCapture() );
1215 /**************************************************************************
1216 * GetUpdateRgn (USER.237)
1218 INT16 WINAPI GetUpdateRgn16( HWND16 hwnd, HRGN16 hrgn, BOOL16 erase )
1220 return GetUpdateRgn( WIN_Handle32(hwnd), HRGN_32(hrgn), erase );
1224 /**************************************************************************
1225 * ExcludeUpdateRgn (USER.238)
1227 INT16 WINAPI ExcludeUpdateRgn16( HDC16 hdc, HWND16 hwnd )
1229 return ExcludeUpdateRgn( HDC_32(hdc), WIN_Handle32(hwnd) );
1233 /**************************************************************************
1234 * GetOpenClipboardWindow (USER.248)
1236 HWND16 WINAPI GetOpenClipboardWindow16(void)
1238 return HWND_16( GetOpenClipboardWindow() );
1242 /*******************************************************************
1243 * MapWindowPoints (USER.258)
1245 void WINAPI MapWindowPoints16( HWND16 hwndFrom, HWND16 hwndTo, LPPOINT16 lppt, UINT16 count )
1247 POINT buffer[8], *ppt = buffer;
1250 if (count > 8) ppt = HeapAlloc( GetProcessHeap(), 0, count * sizeof(*ppt) );
1251 for (i = 0; i < count; i++)
1253 ppt[i].x = lppt[i].x;
1254 ppt[i].y = lppt[i].y;
1256 MapWindowPoints( WIN_Handle32(hwndFrom), WIN_Handle32(hwndTo), ppt, count );
1257 for (i = 0; i < count; i++)
1259 lppt[i].x = ppt[i].x;
1260 lppt[i].y = ppt[i].y;
1262 if (ppt != buffer) HeapFree( GetProcessHeap(), 0, ppt );
1266 /**************************************************************************
1267 * BeginDeferWindowPos (USER.259)
1269 HDWP16 WINAPI BeginDeferWindowPos16( INT16 count )
1271 return HDWP_16(BeginDeferWindowPos( count ));
1275 /**************************************************************************
1276 * DeferWindowPos (USER.260)
1278 HDWP16 WINAPI DeferWindowPos16( HDWP16 hdwp, HWND16 hwnd, HWND16 hwndAfter,
1279 INT16 x, INT16 y, INT16 cx, INT16 cy,
1282 return HDWP_16(DeferWindowPos( HDWP_32(hdwp), WIN_Handle32(hwnd),
1283 full_insert_after_hwnd(hwndAfter), x, y, cx, cy, flags ));
1287 /**************************************************************************
1288 * EndDeferWindowPos (USER.261)
1290 BOOL16 WINAPI EndDeferWindowPos16( HDWP16 hdwp )
1292 return EndDeferWindowPos(HDWP_32(hdwp));
1296 /**************************************************************************
1297 * GetWindow (USER.262)
1299 HWND16 WINAPI GetWindow16( HWND16 hwnd, WORD rel )
1301 return HWND_16( GetWindow( WIN_Handle32(hwnd), rel ) );
1305 /**************************************************************************
1306 * ShowOwnedPopups (USER.265)
1308 void WINAPI ShowOwnedPopups16( HWND16 owner, BOOL16 fShow )
1310 ShowOwnedPopups( WIN_Handle32(owner), fShow );
1314 /**************************************************************************
1315 * ShowScrollBar (USER.267)
1317 void WINAPI ShowScrollBar16( HWND16 hwnd, INT16 nBar, BOOL16 fShow )
1319 ShowScrollBar( WIN_Handle32(hwnd), nBar, fShow );
1323 /**************************************************************************
1324 * IsZoomed (USER.272)
1326 BOOL16 WINAPI IsZoomed16(HWND16 hwnd)
1328 return IsZoomed( WIN_Handle32(hwnd) );
1332 /**************************************************************************
1333 * GetDlgCtrlID (USER.277)
1335 INT16 WINAPI GetDlgCtrlID16( HWND16 hwnd )
1337 return GetDlgCtrlID( WIN_Handle32(hwnd) );
1341 /**************************************************************************
1342 * GetDesktopHwnd (USER.278)
1344 * Exactly the same thing as GetDesktopWindow(), but not documented.
1345 * Don't ask me why...
1347 HWND16 WINAPI GetDesktopHwnd16(void)
1349 return GetDesktopWindow16();
1353 /**************************************************************************
1354 * SetSystemMenu (USER.280)
1356 BOOL16 WINAPI SetSystemMenu16( HWND16 hwnd, HMENU16 hMenu )
1358 return SetSystemMenu( WIN_Handle32(hwnd), HMENU_32(hMenu) );
1362 /**************************************************************************
1363 * GetDesktopWindow (USER.286)
1365 HWND16 WINAPI GetDesktopWindow16(void)
1367 return HWND_16( GetDesktopWindow() );
1371 /**************************************************************************
1372 * GetLastActivePopup (USER.287)
1374 HWND16 WINAPI GetLastActivePopup16( HWND16 hwnd )
1376 return HWND_16( GetLastActivePopup( WIN_Handle32(hwnd) ));
1380 /**************************************************************************
1381 * RedrawWindow (USER.290)
1383 BOOL16 WINAPI RedrawWindow16( HWND16 hwnd, const RECT16 *rectUpdate,
1384 HRGN16 hrgnUpdate, UINT16 flags )
1389 r.left = rectUpdate->left;
1390 r.top = rectUpdate->top;
1391 r.right = rectUpdate->right;
1392 r.bottom = rectUpdate->bottom;
1393 return RedrawWindow(WIN_Handle32(hwnd), &r, HRGN_32(hrgnUpdate), flags);
1395 return RedrawWindow(WIN_Handle32(hwnd), NULL, HRGN_32(hrgnUpdate), flags);
1399 /**************************************************************************
1400 * LockWindowUpdate (USER.294)
1402 BOOL16 WINAPI LockWindowUpdate16( HWND16 hwnd )
1404 return LockWindowUpdate( WIN_Handle32(hwnd) );
1408 /**************************************************************************
1409 * ScrollWindowEx (USER.319)
1411 INT16 WINAPI ScrollWindowEx16( HWND16 hwnd, INT16 dx, INT16 dy,
1412 const RECT16 *rect, const RECT16 *clipRect,
1413 HRGN16 hrgnUpdate, LPRECT16 rcUpdate,
1416 RECT rect32, clipRect32, rcUpdate32;
1421 rect32.left = rect->left;
1422 rect32.top = rect->top;
1423 rect32.right = rect->right;
1424 rect32.bottom = rect->bottom;
1428 clipRect32.left = clipRect->left;
1429 clipRect32.top = clipRect->top;
1430 clipRect32.right = clipRect->right;
1431 clipRect32.bottom = clipRect->bottom;
1433 ret = ScrollWindowEx( WIN_Handle32(hwnd), dx, dy, rect ? &rect32 : NULL,
1434 clipRect ? &clipRect32 : NULL, HRGN_32(hrgnUpdate),
1435 (rcUpdate) ? &rcUpdate32 : NULL, flags );
1438 rcUpdate->left = rcUpdate32.left;
1439 rcUpdate->top = rcUpdate32.top;
1440 rcUpdate->right = rcUpdate32.right;
1441 rcUpdate->bottom = rcUpdate32.bottom;
1447 /**************************************************************************
1448 * FillWindow (USER.324)
1450 void WINAPI FillWindow16( HWND16 hwndParent, HWND16 hwnd, HDC16 hdc, HBRUSH16 hbrush )
1454 GetClientRect( WIN_Handle32(hwnd), &rect );
1455 DPtoLP( HDC_32(hdc), (LPPOINT)&rect, 2 );
1456 rc16.left = rect.left;
1457 rc16.top = rect.top;
1458 rc16.right = rect.right;
1459 rc16.bottom = rect.bottom;
1460 PaintRect16( hwndParent, hwnd, hdc, hbrush, &rc16 );
1464 /**************************************************************************
1465 * PaintRect (USER.325)
1467 void WINAPI PaintRect16( HWND16 hwndParent, HWND16 hwnd, HDC16 hdc,
1468 HBRUSH16 hbrush, const RECT16 *rect)
1470 if (hbrush <= CTLCOLOR_STATIC)
1472 HWND parent = WIN_Handle32(hwndParent), hwnd32 = WIN_Handle32(hwnd);
1474 if (!parent) return;
1475 hbrush = SendMessageW( parent, WM_CTLCOLORMSGBOX + hbrush, (WPARAM)hdc, (LPARAM)hwnd32 );
1476 if (!hbrush) hbrush = DefWindowProcW( parent, WM_CTLCOLORMSGBOX + hbrush,
1477 (WPARAM)hdc, (LPARAM)hwnd32 );
1479 if (hbrush) FillRect16( hdc, rect, hbrush );
1483 /**************************************************************************
1484 * GetControlBrush (USER.326)
1486 HBRUSH16 WINAPI GetControlBrush16( HWND16 hwnd, HDC16 hdc, UINT16 ctlType )
1489 HWND hwnd32 = WIN_Handle32(hwnd);
1490 HWND parent = GetParent( hwnd32 );
1492 if (!parent) parent = hwnd32;
1493 ret = SendMessageW( parent, WM_CTLCOLORMSGBOX + ctlType, (WPARAM)hdc, (LPARAM)hwnd32 );
1494 if (!ret) ret = DefWindowProcW( parent, WM_CTLCOLORMSGBOX + ctlType,
1495 (WPARAM)hdc, (LPARAM)hwnd32 );
1500 /**************************************************************************
1501 * GetDCEx (USER.359)
1503 HDC16 WINAPI GetDCEx16( HWND16 hwnd, HRGN16 hrgnClip, DWORD flags )
1505 return HDC_16(GetDCEx(WIN_Handle32(hwnd), HRGN_32(hrgnClip), flags));
1509 /**************************************************************************
1510 * GetWindowPlacement (USER.370)
1512 BOOL16 WINAPI GetWindowPlacement16( HWND16 hwnd, WINDOWPLACEMENT16 *wp16 )
1514 WINDOWPLACEMENT wpl;
1516 wpl.length = sizeof(wpl);
1517 if (!GetWindowPlacement( WIN_Handle32(hwnd), &wpl )) return FALSE;
1518 wp16->length = sizeof(*wp16);
1519 wp16->flags = wpl.flags;
1520 wp16->showCmd = wpl.showCmd;
1521 wp16->ptMinPosition.x = wpl.ptMinPosition.x;
1522 wp16->ptMinPosition.y = wpl.ptMinPosition.y;
1523 wp16->ptMaxPosition.x = wpl.ptMaxPosition.x;
1524 wp16->ptMaxPosition.y = wpl.ptMaxPosition.y;
1525 wp16->rcNormalPosition.left = wpl.rcNormalPosition.left;
1526 wp16->rcNormalPosition.top = wpl.rcNormalPosition.top;
1527 wp16->rcNormalPosition.right = wpl.rcNormalPosition.right;
1528 wp16->rcNormalPosition.bottom = wpl.rcNormalPosition.bottom;
1533 /**************************************************************************
1534 * SetWindowPlacement (USER.371)
1536 BOOL16 WINAPI SetWindowPlacement16( HWND16 hwnd, const WINDOWPLACEMENT16 *wp16 )
1538 WINDOWPLACEMENT wpl;
1540 if (!wp16) return FALSE;
1541 wpl.length = sizeof(wpl);
1542 wpl.flags = wp16->flags;
1543 wpl.showCmd = wp16->showCmd;
1544 wpl.ptMinPosition.x = wp16->ptMinPosition.x;
1545 wpl.ptMinPosition.y = wp16->ptMinPosition.y;
1546 wpl.ptMaxPosition.x = wp16->ptMaxPosition.x;
1547 wpl.ptMaxPosition.y = wp16->ptMaxPosition.y;
1548 wpl.rcNormalPosition.left = wp16->rcNormalPosition.left;
1549 wpl.rcNormalPosition.top = wp16->rcNormalPosition.top;
1550 wpl.rcNormalPosition.right = wp16->rcNormalPosition.right;
1551 wpl.rcNormalPosition.bottom = wp16->rcNormalPosition.bottom;
1552 return SetWindowPlacement( WIN_Handle32(hwnd), &wpl );
1556 /***********************************************************************
1557 * RegisterClassEx (USER.397)
1559 ATOM WINAPI RegisterClassEx16( const WNDCLASSEX16 *wc )
1561 struct class_entry *class;
1566 inst = GetExePtr( wc->hInstance );
1567 if (!inst) inst = GetModuleHandle16( NULL );
1569 wc32.cbSize = sizeof(wc32);
1570 wc32.style = wc->style;
1571 wc32.lpfnWndProc = WINPROC_AllocProc16( wc->lpfnWndProc );
1572 wc32.cbClsExtra = wc->cbClsExtra;
1573 wc32.cbWndExtra = wc->cbWndExtra;
1574 wc32.hInstance = HINSTANCE_32(inst);
1575 wc32.hIcon = HICON_32(wc->hIcon);
1576 wc32.hCursor = HCURSOR_32(wc->hCursor);
1577 wc32.hbrBackground = HBRUSH_32(wc->hbrBackground);
1578 wc32.lpszMenuName = MapSL(wc->lpszMenuName);
1579 wc32.lpszClassName = MapSL(wc->lpszClassName);
1580 wc32.hIconSm = HICON_32(wc->hIconSm);
1581 atom = RegisterClassExA( &wc32 );
1582 if ((class = HeapAlloc( GetProcessHeap(), 0, sizeof(*class) )))
1586 list_add_tail( &class_list, &class->entry );
1592 /***********************************************************************
1593 * GetClassInfoEx (USER.398)
1595 * FIXME: this is just a guess, I have no idea if GetClassInfoEx() is the
1596 * same in Win16 as in Win32. --AJ
1598 BOOL16 WINAPI GetClassInfoEx16( HINSTANCE16 hInst16, SEGPTR name, WNDCLASSEX16 *wc )
1601 HINSTANCE hInstance;
1604 if (hInst16 == GetModuleHandle16("user")) hInstance = user32_module;
1605 else hInstance = HINSTANCE_32(GetExePtr( hInst16 ));
1607 ret = GetClassInfoExA( hInstance, MapSL(name), &wc32 );
1611 wc->lpfnWndProc = WINPROC_GetProc16( wc32.lpfnWndProc, FALSE );
1612 wc->style = wc32.style;
1613 wc->cbClsExtra = wc32.cbClsExtra;
1614 wc->cbWndExtra = wc32.cbWndExtra;
1615 wc->hInstance = (wc32.hInstance == user32_module) ? GetModuleHandle16("user") : HINSTANCE_16(wc32.hInstance);
1616 wc->hIcon = HICON_16(wc32.hIcon);
1617 wc->hIconSm = HICON_16(wc32.hIconSm);
1618 wc->hCursor = HCURSOR_16(wc32.hCursor);
1619 wc->hbrBackground = HBRUSH_16(wc32.hbrBackground);
1620 wc->lpszClassName = 0;
1621 wc->lpszMenuName = MapLS(wc32.lpszMenuName); /* FIXME: leak */
1627 /**************************************************************************
1628 * ChildWindowFromPointEx (USER.399)
1630 HWND16 WINAPI ChildWindowFromPointEx16( HWND16 hwndParent, POINT16 pt, UINT16 uFlags)
1636 return HWND_16( ChildWindowFromPointEx( WIN_Handle32(hwndParent), pt32, uFlags ));
1640 /**************************************************************************
1641 * GetPriorityClipboardFormat (USER.402)
1643 INT16 WINAPI GetPriorityClipboardFormat16( UINT16 *list, INT16 count )
1647 for (i = 0; i < count; i++)
1648 if (IsClipboardFormatAvailable( list[i] )) return list[i];
1653 /***********************************************************************
1654 * UnregisterClass (USER.403)
1656 BOOL16 WINAPI UnregisterClass16( LPCSTR className, HINSTANCE16 hInstance )
1660 if (hInstance == GetModuleHandle16("user")) hInstance = 0;
1661 else hInstance = GetExePtr( hInstance );
1663 if ((atom = GlobalFindAtomA( className )))
1665 struct class_entry *class;
1666 LIST_FOR_EACH_ENTRY( class, &class_list, struct class_entry, entry )
1668 if (class->inst != hInstance) continue;
1669 if (class->atom != atom) continue;
1670 list_remove( &class->entry );
1671 HeapFree( GetProcessHeap(), 0, class );
1675 return UnregisterClassA( className, HINSTANCE_32(hInstance) );
1679 /***********************************************************************
1680 * GetClassInfo (USER.404)
1682 BOOL16 WINAPI GetClassInfo16( HINSTANCE16 hInst16, SEGPTR name, WNDCLASS16 *wc )
1685 UINT16 ret = GetClassInfoEx16( hInst16, name, &wcex );
1689 wc->style = wcex.style;
1690 wc->lpfnWndProc = wcex.lpfnWndProc;
1691 wc->cbClsExtra = wcex.cbClsExtra;
1692 wc->cbWndExtra = wcex.cbWndExtra;
1693 wc->hInstance = wcex.hInstance;
1694 wc->hIcon = wcex.hIcon;
1695 wc->hCursor = wcex.hCursor;
1696 wc->hbrBackground = wcex.hbrBackground;
1697 wc->lpszMenuName = wcex.lpszMenuName;
1698 wc->lpszClassName = wcex.lpszClassName;
1704 /**************************************************************************
1705 * TrackPopupMenu (USER.416)
1707 BOOL16 WINAPI TrackPopupMenu16( HMENU16 hMenu, UINT16 wFlags, INT16 x, INT16 y,
1708 INT16 nReserved, HWND16 hwnd, const RECT16 *lpRect )
1713 r.left = lpRect->left;
1714 r.top = lpRect->top;
1715 r.right = lpRect->right;
1716 r.bottom = lpRect->bottom;
1718 return TrackPopupMenu( HMENU_32(hMenu), wFlags, x, y, nReserved,
1719 WIN_Handle32(hwnd), lpRect ? &r : NULL );
1723 /**************************************************************************
1724 * FindWindowEx (USER.427)
1726 HWND16 WINAPI FindWindowEx16( HWND16 parent, HWND16 child, LPCSTR className, LPCSTR title )
1728 return HWND_16( FindWindowExA( WIN_Handle32(parent), WIN_Handle32(child),
1729 className, title ));
1733 /***********************************************************************
1734 * DefFrameProc (USER.445)
1736 LRESULT WINAPI DefFrameProc16( HWND16 hwnd, HWND16 hwndMDIClient,
1737 UINT16 message, WPARAM16 wParam, LPARAM lParam )
1742 lParam = (LPARAM)MapSL(lParam);
1748 return DefFrameProcA( WIN_Handle32(hwnd), WIN_Handle32(hwndMDIClient),
1749 message, wParam, lParam );
1753 MDINEXTMENU next_menu;
1754 DefFrameProcW( WIN_Handle32(hwnd), WIN_Handle32(hwndMDIClient),
1755 message, wParam, (LPARAM)&next_menu );
1756 return MAKELONG( HMENU_16(next_menu.hmenuNext), HWND_16(next_menu.hwndNext) );
1759 return DefWindowProc16(hwnd, message, wParam, lParam);
1764 /***********************************************************************
1765 * DefMDIChildProc (USER.447)
1767 LRESULT WINAPI DefMDIChildProc16( HWND16 hwnd, UINT16 message,
1768 WPARAM16 wParam, LPARAM lParam )
1773 return DefMDIChildProcA( WIN_Handle32(hwnd), message, wParam, (LPARAM)MapSL(lParam) );
1778 case WM_CHILDACTIVATE:
1783 return DefMDIChildProcW( WIN_Handle32(hwnd), message, wParam, lParam );
1785 case WM_GETMINMAXINFO:
1787 MINMAXINFO16 *mmi16 = MapSL(lParam);
1790 mmi.ptReserved.x = mmi16->ptReserved.x;
1791 mmi.ptReserved.y = mmi16->ptReserved.y;
1792 mmi.ptMaxSize.x = mmi16->ptMaxSize.x;
1793 mmi.ptMaxSize.y = mmi16->ptMaxSize.y;
1794 mmi.ptMaxPosition.x = mmi16->ptMaxPosition.x;
1795 mmi.ptMaxPosition.y = mmi16->ptMaxPosition.y;
1796 mmi.ptMinTrackSize.x = mmi16->ptMinTrackSize.x;
1797 mmi.ptMinTrackSize.y = mmi16->ptMinTrackSize.y;
1798 mmi.ptMaxTrackSize.x = mmi16->ptMaxTrackSize.x;
1799 mmi.ptMaxTrackSize.y = mmi16->ptMaxTrackSize.y;
1801 DefMDIChildProcW( WIN_Handle32(hwnd), message, wParam, (LPARAM)&mmi );
1803 mmi16->ptReserved.x = mmi.ptReserved.x;
1804 mmi16->ptReserved.y = mmi.ptReserved.y;
1805 mmi16->ptMaxSize.x = mmi.ptMaxSize.x;
1806 mmi16->ptMaxSize.y = mmi.ptMaxSize.y;
1807 mmi16->ptMaxPosition.x = mmi.ptMaxPosition.x;
1808 mmi16->ptMaxPosition.y = mmi.ptMaxPosition.y;
1809 mmi16->ptMinTrackSize.x = mmi.ptMinTrackSize.x;
1810 mmi16->ptMinTrackSize.y = mmi.ptMinTrackSize.y;
1811 mmi16->ptMaxTrackSize.x = mmi.ptMaxTrackSize.x;
1812 mmi16->ptMaxTrackSize.y = mmi.ptMaxTrackSize.y;
1817 MDINEXTMENU next_menu;
1818 DefMDIChildProcW( WIN_Handle32(hwnd), message, wParam, (LPARAM)&next_menu );
1819 return MAKELONG( HMENU_16(next_menu.hmenuNext), HWND_16(next_menu.hwndNext) );
1822 return DefWindowProc16(hwnd, message, wParam, lParam);
1827 /**************************************************************************
1828 * DrawAnimatedRects (USER.448)
1830 BOOL16 WINAPI DrawAnimatedRects16( HWND16 hwnd, INT16 idAni,
1831 const RECT16* lprcFrom, const RECT16* lprcTo )
1833 RECT rcFrom32, rcTo32;
1834 rcFrom32.left = lprcFrom->left;
1835 rcFrom32.top = lprcFrom->top;
1836 rcFrom32.right = lprcFrom->right;
1837 rcFrom32.bottom = lprcFrom->bottom;
1838 rcTo32.left = lprcTo->left;
1839 rcTo32.top = lprcTo->top;
1840 rcTo32.right = lprcTo->right;
1841 rcTo32.bottom = lprcTo->bottom;
1842 return DrawAnimatedRects( WIN_Handle32(hwnd), idAni, &rcFrom32, &rcTo32 );
1846 /***********************************************************************
1847 * CreateWindowEx (USER.452)
1849 HWND16 WINAPI CreateWindowEx16( DWORD exStyle, LPCSTR className,
1850 LPCSTR windowName, DWORD style, INT16 x,
1851 INT16 y, INT16 width, INT16 height,
1852 HWND16 parent, HMENU16 menu,
1853 HINSTANCE16 instance, LPVOID data )
1859 /* Fix the coordinates */
1861 cs.x = (x == CW_USEDEFAULT16) ? CW_USEDEFAULT : (INT)x;
1862 cs.y = (y == CW_USEDEFAULT16) ? CW_USEDEFAULT : (INT)y;
1863 cs.cx = (width == CW_USEDEFAULT16) ? CW_USEDEFAULT : (INT)width;
1864 cs.cy = (height == CW_USEDEFAULT16) ? CW_USEDEFAULT : (INT)height;
1866 /* Create the window */
1868 cs.lpCreateParams = data;
1869 cs.hInstance = HINSTANCE_32(instance);
1870 cs.hMenu = HMENU_32(menu);
1871 cs.hwndParent = WIN_Handle32( parent );
1873 cs.lpszName = windowName;
1874 cs.lpszClass = className;
1875 cs.dwExStyle = exStyle;
1878 if (!menu && (style & (WS_CHILD | WS_POPUP)) != WS_CHILD)
1881 HINSTANCE16 module = GetExePtr( instance );
1883 if (GetClassInfoA( HINSTANCE_32(module), className, &class ))
1884 cs.hMenu = HMENU_32( LoadMenu16( module, class.lpszMenuName ));
1887 if (!IS_INTRESOURCE(className))
1891 if (!MultiByteToWideChar( CP_ACP, 0, className, -1, bufferW, sizeof(bufferW)/sizeof(WCHAR) ))
1893 hwnd = create_window16( (CREATESTRUCTW *)&cs, bufferW, HINSTANCE_32(instance), 0 );
1897 if (!GlobalGetAtomNameA( LOWORD(className), buffer, sizeof(buffer) )) return 0;
1898 cs.lpszClass = buffer;
1899 hwnd = create_window16( (CREATESTRUCTW *)&cs, (LPCWSTR)className, HINSTANCE_32(instance), 0 );
1901 return HWND_16( hwnd );
1905 /***********************************************************************
1906 * GetInternalWindowPos (USER.460)
1908 UINT16 WINAPI GetInternalWindowPos16( HWND16 hwnd, LPRECT16 rectWnd, LPPOINT16 ptIcon )
1910 WINDOWPLACEMENT16 wndpl;
1912 if (!GetWindowPlacement16( hwnd, &wndpl )) return 0;
1913 if (rectWnd) *rectWnd = wndpl.rcNormalPosition;
1914 if (ptIcon) *ptIcon = wndpl.ptMinPosition;
1915 return wndpl.showCmd;
1919 /**************************************************************************
1920 * SetInternalWindowPos (USER.461)
1922 void WINAPI SetInternalWindowPos16( HWND16 hwnd, UINT16 showCmd, LPRECT16 rect, LPPOINT16 pt )
1929 rc32.left = rect->left;
1930 rc32.top = rect->top;
1931 rc32.right = rect->right;
1932 rc32.bottom = rect->bottom;
1939 SetInternalWindowPos( WIN_Handle32(hwnd), showCmd,
1940 rect ? &rc32 : NULL, pt ? &pt32 : NULL );
1944 /**************************************************************************
1945 * CalcChildScroll (USER.462)
1947 void WINAPI CalcChildScroll16( HWND16 hwnd, WORD scroll )
1949 CalcChildScroll( WIN_Handle32(hwnd), scroll );
1953 /**************************************************************************
1954 * ScrollChildren (USER.463)
1956 void WINAPI ScrollChildren16(HWND16 hwnd, UINT16 uMsg, WPARAM16 wParam, LPARAM lParam)
1958 ScrollChildren( WIN_Handle32(hwnd), uMsg, wParam, lParam );
1962 /**************************************************************************
1963 * DragDetect (USER.465)
1965 BOOL16 WINAPI DragDetect16( HWND16 hwnd, POINT16 pt )
1971 return DragDetect( WIN_Handle32(hwnd), pt32 );
1975 /**************************************************************************
1976 * SetScrollInfo (USER.475)
1978 INT16 WINAPI SetScrollInfo16( HWND16 hwnd, INT16 nBar, const SCROLLINFO *info, BOOL16 redraw )
1980 return SetScrollInfo( WIN_Handle32(hwnd), nBar, info, redraw );
1984 /**************************************************************************
1985 * GetScrollInfo (USER.476)
1987 BOOL16 WINAPI GetScrollInfo16( HWND16 hwnd, INT16 nBar, LPSCROLLINFO info )
1989 return GetScrollInfo( WIN_Handle32(hwnd), nBar, info );
1993 /**************************************************************************
1994 * EnableScrollBar (USER.482)
1996 BOOL16 WINAPI EnableScrollBar16( HWND16 hwnd, INT16 nBar, UINT16 flags )
1998 return EnableScrollBar( WIN_Handle32(hwnd), nBar, flags );
2002 /**************************************************************************
2003 * GetShellWindow (USER.600)
2005 HWND16 WINAPI GetShellWindow16(void)
2007 return HWND_16( GetShellWindow() );
2011 /**************************************************************************
2012 * GetForegroundWindow (USER.608)
2014 HWND16 WINAPI GetForegroundWindow16(void)
2016 return HWND_16( GetForegroundWindow() );
2020 /**************************************************************************
2021 * SetForegroundWindow (USER.609)
2023 BOOL16 WINAPI SetForegroundWindow16( HWND16 hwnd )
2025 return SetForegroundWindow( WIN_Handle32(hwnd) );
2029 /**************************************************************************
2030 * DrawCaptionTemp (USER.657)
2032 BOOL16 WINAPI DrawCaptionTemp16( HWND16 hwnd, HDC16 hdc, const RECT16 *rect,
2033 HFONT16 hFont, HICON16 hIcon, LPCSTR str, UINT16 uFlags )
2039 rect32.left = rect->left;
2040 rect32.top = rect->top;
2041 rect32.right = rect->right;
2042 rect32.bottom = rect->bottom;
2044 return DrawCaptionTempA( WIN_Handle32(hwnd), HDC_32(hdc),
2045 rect ? &rect32 : NULL, HFONT_32(hFont),
2046 HICON_32(hIcon), str, uFlags & 0x1f );
2050 /**************************************************************************
2051 * DrawCaption (USER.660)
2053 BOOL16 WINAPI DrawCaption16( HWND16 hwnd, HDC16 hdc, const RECT16 *rect, UINT16 flags )
2059 rect32.left = rect->left;
2060 rect32.top = rect->top;
2061 rect32.right = rect->right;
2062 rect32.bottom = rect->bottom;
2064 return DrawCaption(WIN_Handle32(hwnd), HDC_32(hdc), rect ? &rect32 : NULL, flags);
2068 /**************************************************************************
2069 * GetMenuItemRect (USER.665)
2071 BOOL16 WINAPI GetMenuItemRect16( HWND16 hwnd, HMENU16 hMenu, UINT16 uItem,
2076 if (!rect) return FALSE;
2077 res = GetMenuItemRect( WIN_Handle32(hwnd), HMENU_32(hMenu), uItem, &r32 );
2078 rect->left = r32.left;
2079 rect->top = r32.top;
2080 rect->right = r32.right;
2081 rect->bottom = r32.bottom;
2086 /**************************************************************************
2087 * SetWindowRgn (USER.668)
2089 INT16 WINAPI SetWindowRgn16( HWND16 hwnd, HRGN16 hrgn, BOOL16 redraw )
2091 return SetWindowRgn( WIN_Handle32(hwnd), HRGN_32(hrgn), redraw );
2095 /**************************************************************************
2096 * MessageBoxIndirect (USER.827)
2098 INT16 WINAPI MessageBoxIndirect16( LPMSGBOXPARAMS16 msgbox )
2100 MSGBOXPARAMSA msgbox32;
2102 msgbox32.cbSize = msgbox->cbSize;
2103 msgbox32.hwndOwner = WIN_Handle32( msgbox->hwndOwner );
2104 msgbox32.hInstance = HINSTANCE_32(msgbox->hInstance);
2105 msgbox32.lpszText = MapSL(msgbox->lpszText);
2106 msgbox32.lpszCaption = MapSL(msgbox->lpszCaption);
2107 msgbox32.dwStyle = msgbox->dwStyle;
2108 msgbox32.lpszIcon = MapSL(msgbox->lpszIcon);
2109 msgbox32.dwContextHelpId = msgbox->dwContextHelpId;
2110 msgbox32.lpfnMsgBoxCallback = msgbox->lpfnMsgBoxCallback;
2111 msgbox32.dwLanguageId = msgbox->dwLanguageId;
2112 return MessageBoxIndirectA( &msgbox32 );