dmsynth: Remove DECLSPEC_HIDDEN usage.
[wine.git] / dlls / user.exe16 / window.c
blobeac3468a6e0f6d5de6af65f465257c946368d9c8
1 /*
2 * 16-bit windowing functions
4 * Copyright 2001 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "wine/winuser16.h"
22 #include "wownt32.h"
23 #include "user_private.h"
24 #include "wine/list.h"
25 #include "wine/server.h"
26 #include "wine/debug.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(win);
30 /* size of buffer needed to store an atom string */
31 #define ATOM_BUFFER_SIZE 256
33 /* handle <--> handle16 conversions */
34 #define HANDLE_16(h32) (LOWORD(h32))
35 #define HANDLE_32(h16) ((HANDLE)(ULONG_PTR)(h16))
37 static HWND16 hwndSysModal;
39 struct class_entry
41 struct list entry;
42 ATOM atom;
43 HINSTANCE16 inst;
46 static struct list class_list = LIST_INIT( class_list );
48 struct wnd_enum_info
50 WNDENUMPROC16 proc;
51 LPARAM param;
54 /* callback for 16-bit window enumeration functions */
55 static BOOL CALLBACK wnd_enum_callback( HWND hwnd, LPARAM param )
57 const struct wnd_enum_info *info = (struct wnd_enum_info *)param;
58 WORD args[3];
59 DWORD ret;
61 args[2] = HWND_16(hwnd);
62 args[1] = HIWORD(info->param);
63 args[0] = LOWORD(info->param);
64 WOWCallback16Ex( (DWORD)info->proc, WCB16_PASCAL, sizeof(args), args, &ret );
65 return LOWORD(ret);
68 /* convert insert after window handle to 32-bit */
69 static inline HWND full_insert_after_hwnd( HWND16 hwnd )
71 HWND ret = WIN_Handle32( hwnd );
72 if (ret == (HWND)0xffff) ret = HWND_TOPMOST;
73 return ret;
76 void free_module_classes( HINSTANCE16 inst )
78 struct class_entry *class, *next;
80 LIST_FOR_EACH_ENTRY_SAFE( class, next, &class_list, struct class_entry, entry )
82 if (class->inst != inst) continue;
83 list_remove( &class->entry );
84 UnregisterClassA( (LPCSTR)MAKEINTATOM(class->atom), HINSTANCE_32(class->inst) );
85 HeapFree( GetProcessHeap(), 0, class );
89 /**************************************************************************
90 * MessageBox (USER.1)
92 INT16 WINAPI MessageBox16( HWND16 hwnd, LPCSTR text, LPCSTR title, UINT16 type )
94 return MessageBoxA( WIN_Handle32(hwnd), text, title, type );
98 /***********************************************************************
99 * SetTimer (USER.10)
101 UINT16 WINAPI SetTimer16( HWND16 hwnd, UINT16 id, UINT16 timeout, TIMERPROC16 proc )
103 TIMERPROC proc32 = (TIMERPROC)WINPROC_AllocProc16( (WNDPROC16)proc );
104 return SetTimer( WIN_Handle32(hwnd), id, timeout, proc32 );
108 /***********************************************************************
109 * SetSystemTimer (USER.11)
111 UINT16 WINAPI SetSystemTimer16( HWND16 hwnd, UINT16 id, UINT16 timeout, TIMERPROC16 proc )
113 TIMERPROC proc32 = (TIMERPROC)WINPROC_AllocProc16( (WNDPROC16)proc );
114 return SetTimer( WIN_Handle32(hwnd), (UINT_PTR)id | SYSTEM_TIMER_FLAG, timeout, proc32 );
118 /**************************************************************************
119 * KillTimer (USER.12)
121 BOOL16 WINAPI KillTimer16( HWND16 hwnd, UINT16 id )
123 return KillTimer( WIN_Handle32(hwnd), id );
127 /**************************************************************************
128 * SetCapture (USER.18)
130 HWND16 WINAPI SetCapture16( HWND16 hwnd )
132 return HWND_16( SetCapture( WIN_Handle32(hwnd) ));
136 /**************************************************************************
137 * ReleaseCapture (USER.19)
139 BOOL16 WINAPI ReleaseCapture16(void)
141 return ReleaseCapture();
145 /**************************************************************************
146 * SetFocus (USER.22)
148 HWND16 WINAPI SetFocus16( HWND16 hwnd )
150 return HWND_16( SetFocus( WIN_Handle32(hwnd) ));
154 /**************************************************************************
155 * GetFocus (USER.23)
157 HWND16 WINAPI GetFocus16(void)
159 return HWND_16( GetFocus() );
163 /**************************************************************************
164 * RemoveProp (USER.24)
166 HANDLE16 WINAPI RemoveProp16( HWND16 hwnd, LPCSTR str )
168 return HANDLE_16(RemovePropA( WIN_Handle32(hwnd), str ));
172 /**************************************************************************
173 * GetProp (USER.25)
175 HANDLE16 WINAPI GetProp16( HWND16 hwnd, LPCSTR str )
177 return HANDLE_16(GetPropA( WIN_Handle32(hwnd), str ));
181 /**************************************************************************
182 * SetProp (USER.26)
184 BOOL16 WINAPI SetProp16( HWND16 hwnd, LPCSTR str, HANDLE16 handle )
186 return SetPropA( WIN_Handle32(hwnd), str, HANDLE_32(handle) );
190 /***********************************************************************
191 * EnumProps (USER.27)
193 INT16 WINAPI EnumProps16( HWND16 hwnd, PROPENUMPROC16 func )
195 int ret = -1, i, count, total = 32;
196 property_data_t *list;
198 while (total)
200 if (!(list = HeapAlloc( GetProcessHeap(), 0, total * sizeof(*list) ))) break;
201 count = 0;
202 SERVER_START_REQ( get_window_properties )
204 req->window = wine_server_user_handle( HWND_32(hwnd) );
205 wine_server_set_reply( req, list, total * sizeof(*list) );
206 if (!wine_server_call( req )) count = reply->total;
208 SERVER_END_REQ;
210 if (count && count <= total)
212 char string[ATOM_BUFFER_SIZE];
213 SEGPTR segptr = MapLS( string );
214 WORD args[4];
215 DWORD result;
217 for (i = 0; i < count; i++)
219 if (list[i].string) /* it was a string originally */
221 if (!GlobalGetAtomNameA( list[i].atom, string, ATOM_BUFFER_SIZE )) continue;
222 args[3] = hwnd;
223 args[2] = SELECTOROF(segptr);
224 args[1] = OFFSETOF(segptr);
225 args[0] = LOWORD(list[i].data);
227 else
229 args[3] = hwnd;
230 args[2] = 0;
231 args[1] = list[i].atom;
232 args[0] = LOWORD(list[i].data);
234 WOWCallback16Ex( (DWORD)func, WCB16_PASCAL, sizeof(args), args, &result );
235 if (!(ret = LOWORD(result))) break;
237 UnMapLS( segptr );
238 HeapFree( GetProcessHeap(), 0, list );
239 break;
241 HeapFree( GetProcessHeap(), 0, list );
242 total = count; /* restart with larger buffer */
244 return ret;
248 /**************************************************************************
249 * ClientToScreen (USER.28)
251 void WINAPI ClientToScreen16( HWND16 hwnd, LPPOINT16 lppnt )
253 MapWindowPoints16( hwnd, 0, lppnt, 1 );
257 /**************************************************************************
258 * ScreenToClient (USER.29)
260 void WINAPI ScreenToClient16( HWND16 hwnd, LPPOINT16 lppnt )
262 MapWindowPoints16( 0, hwnd, lppnt, 1 );
266 /**************************************************************************
267 * WindowFromPoint (USER.30)
269 HWND16 WINAPI WindowFromPoint16( POINT16 pt )
271 POINT pt32;
273 pt32.x = pt.x;
274 pt32.y = pt.y;
275 return HWND_16( WindowFromPoint( pt32 ) );
279 /**************************************************************************
280 * IsIconic (USER.31)
282 BOOL16 WINAPI IsIconic16(HWND16 hwnd)
284 return IsIconic( WIN_Handle32(hwnd) );
288 /**************************************************************************
289 * GetWindowRect (USER.32)
291 void WINAPI GetWindowRect16( HWND16 hwnd, LPRECT16 rect )
293 RECT rect32;
295 GetWindowRect( WIN_Handle32(hwnd), &rect32 );
296 rect->left = rect32.left;
297 rect->top = rect32.top;
298 rect->right = rect32.right;
299 rect->bottom = rect32.bottom;
303 /**************************************************************************
304 * GetClientRect (USER.33)
306 void WINAPI GetClientRect16( HWND16 hwnd, LPRECT16 rect )
308 RECT rect32;
310 GetClientRect( WIN_Handle32(hwnd), &rect32 );
311 rect->left = rect32.left;
312 rect->top = rect32.top;
313 rect->right = rect32.right;
314 rect->bottom = rect32.bottom;
318 /**************************************************************************
319 * EnableWindow (USER.34)
321 BOOL16 WINAPI EnableWindow16( HWND16 hwnd, BOOL16 enable )
323 return EnableWindow( WIN_Handle32(hwnd), enable );
327 /**************************************************************************
328 * IsWindowEnabled (USER.35)
330 BOOL16 WINAPI IsWindowEnabled16(HWND16 hwnd)
332 return IsWindowEnabled( WIN_Handle32(hwnd) );
336 /**************************************************************************
337 * GetWindowText (USER.36)
339 INT16 WINAPI GetWindowText16( HWND16 hwnd, SEGPTR lpString, INT16 nMaxCount )
341 return SendMessage16( hwnd, WM_GETTEXT, nMaxCount, lpString );
345 /**************************************************************************
346 * SetWindowText (USER.37)
348 BOOL16 WINAPI SetWindowText16( HWND16 hwnd, SEGPTR lpString )
350 return SendMessage16( hwnd, WM_SETTEXT, 0, lpString );
354 /**************************************************************************
355 * GetWindowTextLength (USER.38)
357 INT16 WINAPI GetWindowTextLength16( HWND16 hwnd )
359 return SendMessage16( hwnd, WM_GETTEXTLENGTH, 0, 0 );
363 /***********************************************************************
364 * BeginPaint (USER.39)
366 HDC16 WINAPI BeginPaint16( HWND16 hwnd, LPPAINTSTRUCT16 lps )
368 PAINTSTRUCT ps;
370 BeginPaint( WIN_Handle32(hwnd), &ps );
371 lps->hdc = HDC_16(ps.hdc);
372 lps->fErase = ps.fErase;
373 lps->rcPaint.top = ps.rcPaint.top;
374 lps->rcPaint.left = ps.rcPaint.left;
375 lps->rcPaint.right = ps.rcPaint.right;
376 lps->rcPaint.bottom = ps.rcPaint.bottom;
377 lps->fRestore = ps.fRestore;
378 lps->fIncUpdate = ps.fIncUpdate;
379 return lps->hdc;
383 /***********************************************************************
384 * EndPaint (USER.40)
386 BOOL16 WINAPI EndPaint16( HWND16 hwnd, const PAINTSTRUCT16* lps )
388 PAINTSTRUCT ps;
390 ps.hdc = HDC_32(lps->hdc);
391 return EndPaint( WIN_Handle32(hwnd), &ps );
395 /***********************************************************************
396 * CreateWindow (USER.41)
398 HWND16 WINAPI CreateWindow16( LPCSTR className, LPCSTR windowName,
399 DWORD style, INT16 x, INT16 y, INT16 width,
400 INT16 height, HWND16 parent, HMENU16 menu,
401 HINSTANCE16 instance, LPVOID data )
403 return CreateWindowEx16( 0, className, windowName, style,
404 x, y, width, height, parent, menu, instance, data );
408 /**************************************************************************
409 * ShowWindow (USER.42)
411 BOOL16 WINAPI ShowWindow16( HWND16 hwnd, INT16 cmd )
413 return ShowWindow( WIN_Handle32(hwnd), cmd );
417 /**************************************************************************
418 * CloseWindow (USER.43)
420 BOOL16 WINAPI CloseWindow16( HWND16 hwnd )
422 return CloseWindow( WIN_Handle32(hwnd) );
426 /**************************************************************************
427 * OpenIcon (USER.44)
429 BOOL16 WINAPI OpenIcon16( HWND16 hwnd )
431 return OpenIcon( WIN_Handle32(hwnd) );
435 /**************************************************************************
436 * BringWindowToTop (USER.45)
438 BOOL16 WINAPI BringWindowToTop16( HWND16 hwnd )
440 return BringWindowToTop( WIN_Handle32(hwnd) );
444 /**************************************************************************
445 * GetParent (USER.46)
447 HWND16 WINAPI GetParent16( HWND16 hwnd )
449 return HWND_16( GetParent( WIN_Handle32(hwnd) ));
453 /**************************************************************************
454 * IsWindow (USER.47)
456 BOOL16 WINAPI IsWindow16( HWND16 hwnd )
458 CURRENT_STACK16->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 /**************************************************************************
465 * IsChild (USER.48)
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;
507 info.proc = func;
508 info.param = lParam;
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;
520 info.proc = func;
521 info.param = lParam;
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 )
540 WNDCLASSEX16 wcex;
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;
553 wcex.hIconSm = 0;
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;
593 if (rect)
595 rect32.left = rect->left;
596 rect32.top = rect->top;
597 rect32.right = rect->right;
598 rect32.bottom = rect->bottom;
600 if (clipRect)
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)
646 INT min, max;
647 BOOL ret = GetScrollRange( WIN_Handle32(hwnd), nBar, &min, &max );
648 if (lpMin) *lpMin = min;
649 if (lpMax) *lpMax = max;
650 return ret;
654 /**************************************************************************
655 * GetDC (USER.66)
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 INT16 ret = (INT16)ReleaseDC( WIN_Handle32(hwnd), HDC_32(hdc) );
678 NtUserEnableDC( HDC_32(hdc) );
679 return ret;
683 /**************************************************************************
684 * FlashWindow (USER.105)
686 BOOL16 WINAPI FlashWindow16( HWND16 hwnd, BOOL16 bInvert )
688 return FlashWindow( WIN_Handle32(hwnd), bInvert );
692 /**************************************************************************
693 * WindowFromDC (USER.117)
695 HWND16 WINAPI WindowFromDC16( HDC16 hDC )
697 return HWND_16( WindowFromDC( HDC_32(hDC) ) );
701 /**************************************************************************
702 * UpdateWindow (USER.124)
704 void WINAPI UpdateWindow16( HWND16 hwnd )
706 RedrawWindow16( hwnd, NULL, 0, RDW_UPDATENOW | RDW_ALLCHILDREN );
710 /**************************************************************************
711 * InvalidateRect (USER.125)
713 void WINAPI InvalidateRect16( HWND16 hwnd, const RECT16 *rect, BOOL16 erase )
715 RedrawWindow16( hwnd, rect, 0, RDW_INVALIDATE | (erase ? RDW_ERASE : 0) );
719 /**************************************************************************
720 * InvalidateRgn (USER.126)
722 void WINAPI InvalidateRgn16( HWND16 hwnd, HRGN16 hrgn, BOOL16 erase )
724 RedrawWindow16( hwnd, NULL, hrgn, RDW_INVALIDATE | (erase ? RDW_ERASE : 0) );
728 /**************************************************************************
729 * ValidateRect (USER.127)
731 void WINAPI ValidateRect16( HWND16 hwnd, const RECT16 *rect )
733 RedrawWindow16( hwnd, rect, 0, RDW_VALIDATE | RDW_NOCHILDREN );
737 /**************************************************************************
738 * ValidateRgn (USER.128)
740 void WINAPI ValidateRgn16( HWND16 hwnd, HRGN16 hrgn )
742 RedrawWindow16( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOCHILDREN );
746 /**************************************************************************
747 * GetClassWord (USER.129)
749 WORD WINAPI GetClassWord16( HWND16 hwnd, INT16 offset )
751 HICON icon;
753 switch (offset)
755 case GCLP_HCURSOR:
756 case GCLP_HICON:
757 case GCLP_HICONSM:
758 icon = (HICON)GetClassLongPtrW( WIN_Handle32(hwnd), offset );
759 return get_icon_16( icon );
761 return GetClassWord( WIN_Handle32(hwnd), offset );
765 /**************************************************************************
766 * SetClassWord (USER.130)
768 WORD WINAPI SetClassWord16( HWND16 hwnd, INT16 offset, WORD newval )
770 HICON icon;
772 switch (offset)
774 case GCLP_HCURSOR:
775 case GCLP_HICON:
776 case GCLP_HICONSM:
777 icon = (HICON)SetClassLongPtrW( WIN_Handle32(hwnd), offset, (ULONG_PTR)get_icon_32(newval) );
778 return get_icon_16( icon );
780 return SetClassWord( WIN_Handle32(hwnd), offset, newval );
784 /***********************************************************************
785 * GetClassLong (USER.131)
787 LONG WINAPI GetClassLong16( HWND16 hwnd16, INT16 offset )
789 LONG_PTR ret = GetClassLongA( WIN_Handle32(hwnd16), offset );
791 switch( offset )
793 case GCLP_WNDPROC:
794 return (LONG_PTR)WINPROC_GetProc16( (WNDPROC)ret, FALSE );
795 case GCLP_MENUNAME:
796 return MapLS( (void *)ret ); /* leak */
797 case GCLP_HCURSOR:
798 case GCLP_HICON:
799 case GCLP_HICONSM:
800 return get_icon_16( (HICON)ret );
801 default:
802 return ret;
807 /***********************************************************************
808 * SetClassLong (USER.132)
810 LONG WINAPI SetClassLong16( HWND16 hwnd16, INT16 offset, LONG newval )
812 HICON icon;
814 switch( offset )
816 case GCLP_HCURSOR:
817 case GCLP_HICON:
818 case GCLP_HICONSM:
819 icon = (HICON)SetClassLongPtrW( WIN_Handle32(hwnd16), offset, (ULONG_PTR)get_icon_32(newval) );
820 return get_icon_16( icon );
821 case GCLP_WNDPROC:
823 WNDPROC new_proc = WINPROC_AllocProc16( (WNDPROC16)newval );
824 WNDPROC old_proc = (WNDPROC)SetClassLongA( WIN_Handle32(hwnd16), offset, (LONG_PTR)new_proc );
825 return (LONG)WINPROC_GetProc16( old_proc, FALSE );
827 case GCLP_MENUNAME:
828 newval = (LONG)MapSL( newval );
829 /* fall through */
830 default:
831 return SetClassLongA( WIN_Handle32(hwnd16), offset, newval );
836 /**************************************************************************
837 * GetWindowWord (USER.133)
839 WORD WINAPI GetWindowWord16( HWND16 hwnd, INT16 offset )
841 switch(offset)
843 case GWLP_ID:
844 case GWLP_HINSTANCE:
845 case GWLP_HWNDPARENT:
846 return GetWindowLongA( WIN_Handle32(hwnd), offset );
847 default:
848 return GetWindowWord( WIN_Handle32(hwnd), offset );
853 /**************************************************************************
854 * SetWindowWord (USER.134)
856 WORD WINAPI SetWindowWord16( HWND16 hwnd, INT16 offset, WORD newval )
858 switch(offset)
860 case GWLP_ID:
861 case GWLP_HINSTANCE:
862 case GWLP_HWNDPARENT:
863 return SetWindowLongA( WIN_Handle32(hwnd), offset, newval );
864 default:
865 return SetWindowWord( WIN_Handle32(hwnd), offset, newval );
870 /**********************************************************************
871 * GetWindowLong (USER.135)
873 LONG WINAPI GetWindowLong16( HWND16 hwnd16, INT16 offset )
875 HWND hwnd = WIN_Handle32( hwnd16 );
876 LONG_PTR retvalue;
877 BOOL is_winproc = (offset == GWLP_WNDPROC);
879 if (offset >= 0)
881 int cbWndExtra = GetClassLongA( hwnd, GCL_CBWNDEXTRA );
883 if (offset > (int)(cbWndExtra - sizeof(LONG)))
886 * Some programs try to access last element from 16 bit
887 * code using illegal offset value. Hopefully this is
888 * what those programs really expect.
890 if (cbWndExtra >= 4 && offset == cbWndExtra - sizeof(WORD))
892 offset = cbWndExtra - sizeof(LONG);
894 else
896 SetLastError( ERROR_INVALID_INDEX );
897 return 0;
900 else if (offset == DWLP_DLGPROC)
901 is_winproc = (wow_handlers32.get_dialog_info( hwnd, FALSE ) != NULL);
903 retvalue = GetWindowLongA( hwnd, offset );
904 if (is_winproc) retvalue = (LONG_PTR)WINPROC_GetProc16( (WNDPROC)retvalue, FALSE );
905 return retvalue;
909 /**********************************************************************
910 * SetWindowLong (USER.136)
912 LONG WINAPI SetWindowLong16( HWND16 hwnd16, INT16 offset, LONG newval )
914 HWND hwnd = WIN_Handle32( hwnd16 );
915 BOOL is_winproc = (offset == GWLP_WNDPROC);
917 if (offset == DWLP_DLGPROC)
918 is_winproc = (wow_handlers32.get_dialog_info( hwnd, FALSE ) != NULL);
920 if (is_winproc)
922 WNDPROC new_proc = WINPROC_AllocProc16( (WNDPROC16)newval );
923 WNDPROC old_proc = (WNDPROC)SetWindowLongPtrA( hwnd, offset, (LONG_PTR)new_proc );
924 return (LONG)WINPROC_GetProc16( old_proc, FALSE );
926 else return SetWindowLongA( hwnd, offset, newval );
930 /**************************************************************************
931 * OpenClipboard (USER.137)
933 BOOL16 WINAPI OpenClipboard16( HWND16 hwnd )
935 return OpenClipboard( WIN_Handle32(hwnd) );
939 /**************************************************************************
940 * GetClipboardOwner (USER.140)
942 HWND16 WINAPI GetClipboardOwner16(void)
944 return HWND_16( GetClipboardOwner() );
948 /**************************************************************************
949 * SetClipboardViewer (USER.147)
951 HWND16 WINAPI SetClipboardViewer16( HWND16 hwnd )
953 return HWND_16( SetClipboardViewer( WIN_Handle32(hwnd) ));
957 /**************************************************************************
958 * GetClipboardViewer (USER.148)
960 HWND16 WINAPI GetClipboardViewer16(void)
962 return HWND_16( GetClipboardViewer() );
966 /**************************************************************************
967 * ChangeClipboardChain (USER.149)
969 BOOL16 WINAPI ChangeClipboardChain16(HWND16 hwnd, HWND16 hwndNext)
971 return ChangeClipboardChain( WIN_Handle32(hwnd), WIN_Handle32(hwndNext) );
975 /**************************************************************************
976 * GetSystemMenu (USER.156)
978 HMENU16 WINAPI GetSystemMenu16( HWND16 hwnd, BOOL16 revert )
980 return HMENU_16(GetSystemMenu( WIN_Handle32(hwnd), revert ));
984 /**************************************************************************
985 * GetMenu (USER.157)
987 HMENU16 WINAPI GetMenu16( HWND16 hwnd )
989 return HMENU_16(GetMenu( WIN_Handle32(hwnd) ));
993 /**************************************************************************
994 * SetMenu (USER.158)
996 BOOL16 WINAPI SetMenu16( HWND16 hwnd, HMENU16 hMenu )
998 return SetMenu( WIN_Handle32(hwnd), HMENU_32(hMenu) );
1002 /**************************************************************************
1003 * DrawMenuBar (USER.160)
1005 void WINAPI DrawMenuBar16( HWND16 hwnd )
1007 DrawMenuBar( WIN_Handle32(hwnd) );
1011 /**************************************************************************
1012 * HiliteMenuItem (USER.162)
1014 BOOL16 WINAPI HiliteMenuItem16( HWND16 hwnd, HMENU16 hMenu, UINT16 id, UINT16 wHilite )
1016 return HiliteMenuItem( WIN_Handle32(hwnd), HMENU_32(hMenu), id, wHilite );
1020 /**************************************************************************
1021 * CreateCaret (USER.163)
1023 void WINAPI CreateCaret16( HWND16 hwnd, HBITMAP16 bitmap, INT16 width, INT16 height )
1025 CreateCaret( WIN_Handle32(hwnd), HBITMAP_32(bitmap), width, height );
1029 /*****************************************************************
1030 * DestroyCaret (USER.164)
1032 void WINAPI DestroyCaret16(void)
1034 DestroyCaret();
1038 /*****************************************************************
1039 * SetCaretPos (USER.165)
1041 void WINAPI SetCaretPos16( INT16 x, INT16 y )
1043 SetCaretPos( x, y );
1047 /**************************************************************************
1048 * HideCaret (USER.166)
1050 void WINAPI HideCaret16( HWND16 hwnd )
1052 HideCaret( WIN_Handle32(hwnd) );
1056 /**************************************************************************
1057 * ShowCaret (USER.167)
1059 void WINAPI ShowCaret16( HWND16 hwnd )
1061 ShowCaret( WIN_Handle32(hwnd) );
1065 /*****************************************************************
1066 * SetCaretBlinkTime (USER.168)
1068 void WINAPI SetCaretBlinkTime16( UINT16 msecs )
1070 SetCaretBlinkTime( msecs );
1074 /*****************************************************************
1075 * GetCaretBlinkTime (USER.169)
1077 UINT16 WINAPI GetCaretBlinkTime16(void)
1079 return GetCaretBlinkTime();
1083 /**************************************************************************
1084 * ArrangeIconicWindows (USER.170)
1086 UINT16 WINAPI ArrangeIconicWindows16( HWND16 parent)
1088 return ArrangeIconicWindows( WIN_Handle32(parent) );
1092 /**************************************************************************
1093 * SwitchToThisWindow (USER.172)
1095 void WINAPI SwitchToThisWindow16( HWND16 hwnd, BOOL16 restore )
1097 SwitchToThisWindow( WIN_Handle32(hwnd), restore );
1101 /**************************************************************************
1102 * KillSystemTimer (USER.182)
1104 BOOL16 WINAPI KillSystemTimer16( HWND16 hwnd, UINT16 id )
1106 return KillTimer( WIN_Handle32(hwnd), (UINT_PTR)id | SYSTEM_TIMER_FLAG );
1110 /*****************************************************************
1111 * GetCaretPos (USER.183)
1113 void WINAPI GetCaretPos16( LPPOINT16 pt16 )
1115 POINT pt;
1116 if (GetCaretPos( &pt ))
1118 pt16->x = pt.x;
1119 pt16->y = pt.y;
1124 /**************************************************************************
1125 * SetSysModalWindow (USER.188)
1127 HWND16 WINAPI SetSysModalWindow16( HWND16 hwnd )
1129 HWND16 old = hwndSysModal;
1130 hwndSysModal = hwnd;
1131 return old;
1135 /**************************************************************************
1136 * GetSysModalWindow (USER.189)
1138 HWND16 WINAPI GetSysModalWindow16(void)
1140 return hwndSysModal;
1144 /**************************************************************************
1145 * GetUpdateRect (USER.190)
1147 BOOL16 WINAPI GetUpdateRect16( HWND16 hwnd, LPRECT16 rect, BOOL16 erase )
1149 RECT r;
1150 BOOL16 ret;
1152 if (!rect) return GetUpdateRect( WIN_Handle32(hwnd), NULL, erase );
1153 ret = GetUpdateRect( WIN_Handle32(hwnd), &r, erase );
1154 rect->left = r.left;
1155 rect->top = r.top;
1156 rect->right = r.right;
1157 rect->bottom = r.bottom;
1158 return ret;
1162 /**************************************************************************
1163 * ChildWindowFromPoint (USER.191)
1165 HWND16 WINAPI ChildWindowFromPoint16( HWND16 hwndParent, POINT16 pt )
1167 POINT pt32;
1169 pt32.x = pt.x;
1170 pt32.y = pt.y;
1171 return HWND_16( ChildWindowFromPoint( WIN_Handle32(hwndParent), pt32 ));
1175 /***********************************************************************
1176 * CascadeChildWindows (USER.198)
1178 void WINAPI CascadeChildWindows16( HWND16 parent, WORD action )
1180 CascadeWindows( WIN_Handle32(parent), action, NULL, 0, NULL );
1184 /***********************************************************************
1185 * TileChildWindows (USER.199)
1187 void WINAPI TileChildWindows16( HWND16 parent, WORD action )
1189 TileWindows( WIN_Handle32(parent), action, NULL, 0, NULL );
1193 /***********************************************************************
1194 * GetWindowTask (USER.224)
1196 HTASK16 WINAPI GetWindowTask16( HWND16 hwnd )
1198 DWORD tid = GetWindowThreadProcessId( HWND_32(hwnd), NULL );
1199 if (!tid) return 0;
1200 return HTASK_16(tid);
1203 /**********************************************************************
1204 * EnumTaskWindows (USER.225)
1206 BOOL16 WINAPI EnumTaskWindows16( HTASK16 hTask, WNDENUMPROC16 func, LPARAM lParam )
1208 struct wnd_enum_info info;
1209 DWORD tid = HTASK_32( hTask );
1211 if (!tid) return FALSE;
1212 info.proc = func;
1213 info.param = lParam;
1214 return EnumThreadWindows( tid, wnd_enum_callback, (LPARAM)&info );
1218 /**************************************************************************
1219 * GetTopWindow (USER.229)
1221 HWND16 WINAPI GetTopWindow16( HWND16 hwnd )
1223 return HWND_16( GetTopWindow( WIN_Handle32(hwnd) ));
1227 /**************************************************************************
1228 * GetNextWindow (USER.230)
1230 HWND16 WINAPI GetNextWindow16( HWND16 hwnd, WORD flag )
1232 if ((flag != GW_HWNDNEXT) && (flag != GW_HWNDPREV)) return 0;
1233 return GetWindow16( hwnd, flag );
1237 /**************************************************************************
1238 * SetWindowPos (USER.232)
1240 BOOL16 WINAPI SetWindowPos16( HWND16 hwnd, HWND16 hwndInsertAfter,
1241 INT16 x, INT16 y, INT16 cx, INT16 cy, WORD flags)
1243 return SetWindowPos( WIN_Handle32(hwnd), full_insert_after_hwnd(hwndInsertAfter),
1244 x, y, cx, cy, flags );
1248 /**************************************************************************
1249 * SetParent (USER.233)
1251 HWND16 WINAPI SetParent16( HWND16 hwndChild, HWND16 hwndNewParent )
1253 return HWND_16( SetParent( WIN_Handle32(hwndChild), WIN_Handle32(hwndNewParent) ));
1257 /**************************************************************************
1258 * GetCapture (USER.236)
1260 HWND16 WINAPI GetCapture16(void)
1262 return HWND_16( GetCapture() );
1266 /**************************************************************************
1267 * GetUpdateRgn (USER.237)
1269 INT16 WINAPI GetUpdateRgn16( HWND16 hwnd, HRGN16 hrgn, BOOL16 erase )
1271 return GetUpdateRgn( WIN_Handle32(hwnd), HRGN_32(hrgn), erase );
1275 /**************************************************************************
1276 * ExcludeUpdateRgn (USER.238)
1278 INT16 WINAPI ExcludeUpdateRgn16( HDC16 hdc, HWND16 hwnd )
1280 return ExcludeUpdateRgn( HDC_32(hdc), WIN_Handle32(hwnd) );
1284 /**************************************************************************
1285 * GetOpenClipboardWindow (USER.248)
1287 HWND16 WINAPI GetOpenClipboardWindow16(void)
1289 return HWND_16( GetOpenClipboardWindow() );
1293 /*******************************************************************
1294 * MapWindowPoints (USER.258)
1296 void WINAPI MapWindowPoints16( HWND16 hwndFrom, HWND16 hwndTo, LPPOINT16 lppt, UINT16 count )
1298 POINT buffer[8], *ppt = buffer;
1299 UINT i;
1301 if (count > 8) ppt = HeapAlloc( GetProcessHeap(), 0, count * sizeof(*ppt) );
1302 for (i = 0; i < count; i++)
1304 ppt[i].x = lppt[i].x;
1305 ppt[i].y = lppt[i].y;
1307 MapWindowPoints( WIN_Handle32(hwndFrom), WIN_Handle32(hwndTo), ppt, count );
1308 for (i = 0; i < count; i++)
1310 lppt[i].x = ppt[i].x;
1311 lppt[i].y = ppt[i].y;
1313 if (ppt != buffer) HeapFree( GetProcessHeap(), 0, ppt );
1317 /**************************************************************************
1318 * BeginDeferWindowPos (USER.259)
1320 HDWP16 WINAPI BeginDeferWindowPos16( INT16 count )
1322 return HDWP_16(BeginDeferWindowPos( count ));
1326 /**************************************************************************
1327 * DeferWindowPos (USER.260)
1329 HDWP16 WINAPI DeferWindowPos16( HDWP16 hdwp, HWND16 hwnd, HWND16 hwndAfter,
1330 INT16 x, INT16 y, INT16 cx, INT16 cy,
1331 UINT16 flags )
1333 return HDWP_16(DeferWindowPos( HDWP_32(hdwp), WIN_Handle32(hwnd),
1334 full_insert_after_hwnd(hwndAfter), x, y, cx, cy, flags ));
1338 /**************************************************************************
1339 * EndDeferWindowPos (USER.261)
1341 BOOL16 WINAPI EndDeferWindowPos16( HDWP16 hdwp )
1343 return EndDeferWindowPos(HDWP_32(hdwp));
1347 /**************************************************************************
1348 * GetWindow (USER.262)
1350 HWND16 WINAPI GetWindow16( HWND16 hwnd, WORD rel )
1352 return HWND_16( GetWindow( WIN_Handle32(hwnd), rel ) );
1356 /**************************************************************************
1357 * ShowOwnedPopups (USER.265)
1359 void WINAPI ShowOwnedPopups16( HWND16 owner, BOOL16 fShow )
1361 ShowOwnedPopups( WIN_Handle32(owner), fShow );
1365 /**************************************************************************
1366 * ShowScrollBar (USER.267)
1368 void WINAPI ShowScrollBar16( HWND16 hwnd, INT16 nBar, BOOL16 fShow )
1370 ShowScrollBar( WIN_Handle32(hwnd), nBar, fShow );
1374 /**************************************************************************
1375 * IsZoomed (USER.272)
1377 BOOL16 WINAPI IsZoomed16(HWND16 hwnd)
1379 return IsZoomed( WIN_Handle32(hwnd) );
1383 /**************************************************************************
1384 * GetDlgCtrlID (USER.277)
1386 INT16 WINAPI GetDlgCtrlID16( HWND16 hwnd )
1388 return GetDlgCtrlID( WIN_Handle32(hwnd) );
1392 /**************************************************************************
1393 * GetDesktopHwnd (USER.278)
1395 * Exactly the same thing as GetDesktopWindow(), but not documented.
1396 * Don't ask me why...
1398 HWND16 WINAPI GetDesktopHwnd16(void)
1400 return GetDesktopWindow16();
1404 /**************************************************************************
1405 * SetSystemMenu (USER.280)
1407 BOOL16 WINAPI SetSystemMenu16( HWND16 hwnd, HMENU16 hMenu )
1409 return SetSystemMenu( WIN_Handle32(hwnd), HMENU_32(hMenu) );
1413 /**************************************************************************
1414 * GetDesktopWindow (USER.286)
1416 HWND16 WINAPI GetDesktopWindow16(void)
1418 return HWND_16( GetDesktopWindow() );
1422 /**************************************************************************
1423 * GetLastActivePopup (USER.287)
1425 HWND16 WINAPI GetLastActivePopup16( HWND16 hwnd )
1427 return HWND_16( GetLastActivePopup( WIN_Handle32(hwnd) ));
1431 /**************************************************************************
1432 * RedrawWindow (USER.290)
1434 BOOL16 WINAPI RedrawWindow16( HWND16 hwnd, const RECT16 *rectUpdate,
1435 HRGN16 hrgnUpdate, UINT16 flags )
1437 if (rectUpdate)
1439 RECT r;
1440 r.left = rectUpdate->left;
1441 r.top = rectUpdate->top;
1442 r.right = rectUpdate->right;
1443 r.bottom = rectUpdate->bottom;
1444 return RedrawWindow(WIN_Handle32(hwnd), &r, HRGN_32(hrgnUpdate), flags);
1446 return RedrawWindow(WIN_Handle32(hwnd), NULL, HRGN_32(hrgnUpdate), flags);
1450 /**************************************************************************
1451 * LockWindowUpdate (USER.294)
1453 BOOL16 WINAPI LockWindowUpdate16( HWND16 hwnd )
1455 return LockWindowUpdate( WIN_Handle32(hwnd) );
1459 /**************************************************************************
1460 * ScrollWindowEx (USER.319)
1462 INT16 WINAPI ScrollWindowEx16( HWND16 hwnd, INT16 dx, INT16 dy,
1463 const RECT16 *rect, const RECT16 *clipRect,
1464 HRGN16 hrgnUpdate, LPRECT16 rcUpdate,
1465 UINT16 flags )
1467 RECT rect32, clipRect32, rcUpdate32;
1468 BOOL16 ret;
1470 if (rect)
1472 rect32.left = rect->left;
1473 rect32.top = rect->top;
1474 rect32.right = rect->right;
1475 rect32.bottom = rect->bottom;
1477 if (clipRect)
1479 clipRect32.left = clipRect->left;
1480 clipRect32.top = clipRect->top;
1481 clipRect32.right = clipRect->right;
1482 clipRect32.bottom = clipRect->bottom;
1484 ret = ScrollWindowEx( WIN_Handle32(hwnd), dx, dy, rect ? &rect32 : NULL,
1485 clipRect ? &clipRect32 : NULL, HRGN_32(hrgnUpdate),
1486 (rcUpdate) ? &rcUpdate32 : NULL, flags );
1487 if (rcUpdate)
1489 rcUpdate->left = rcUpdate32.left;
1490 rcUpdate->top = rcUpdate32.top;
1491 rcUpdate->right = rcUpdate32.right;
1492 rcUpdate->bottom = rcUpdate32.bottom;
1494 return ret;
1498 /**************************************************************************
1499 * FillWindow (USER.324)
1501 void WINAPI FillWindow16( HWND16 hwndParent, HWND16 hwnd, HDC16 hdc, HBRUSH16 hbrush )
1503 RECT rect;
1504 RECT16 rc16;
1505 GetClientRect( WIN_Handle32(hwnd), &rect );
1506 DPtoLP( HDC_32(hdc), (LPPOINT)&rect, 2 );
1507 rc16.left = rect.left;
1508 rc16.top = rect.top;
1509 rc16.right = rect.right;
1510 rc16.bottom = rect.bottom;
1511 PaintRect16( hwndParent, hwnd, hdc, hbrush, &rc16 );
1515 /**************************************************************************
1516 * PaintRect (USER.325)
1518 void WINAPI PaintRect16( HWND16 hwndParent, HWND16 hwnd, HDC16 hdc,
1519 HBRUSH16 hbrush, const RECT16 *rect)
1521 if (hbrush <= CTLCOLOR_STATIC)
1523 HWND parent = WIN_Handle32(hwndParent), hwnd32 = WIN_Handle32(hwnd);
1525 if (!parent) return;
1526 hbrush = SendMessageW( parent, WM_CTLCOLORMSGBOX + hbrush, hdc, (LPARAM)hwnd32 );
1527 if (!hbrush) hbrush = DefWindowProcW( parent, WM_CTLCOLORMSGBOX + hbrush,
1528 hdc, (LPARAM)hwnd32 );
1530 if (hbrush) FillRect16( hdc, rect, hbrush );
1534 /**************************************************************************
1535 * GetControlBrush (USER.326)
1537 HBRUSH16 WINAPI GetControlBrush16( HWND16 hwnd, HDC16 hdc, UINT16 ctlType )
1539 HBRUSH16 ret;
1540 HWND hwnd32 = WIN_Handle32(hwnd);
1541 HWND parent = GetParent( hwnd32 );
1543 if (!parent) parent = hwnd32;
1544 ret = SendMessageW( parent, WM_CTLCOLORMSGBOX + ctlType, hdc, (LPARAM)hwnd32 );
1545 if (!ret) ret = DefWindowProcW( parent, WM_CTLCOLORMSGBOX + ctlType,
1546 hdc, (LPARAM)hwnd32 );
1547 return ret;
1551 /**************************************************************************
1552 * GetDCEx (USER.359)
1554 HDC16 WINAPI GetDCEx16( HWND16 hwnd, HRGN16 hrgnClip, DWORD flags )
1556 return HDC_16(GetDCEx(WIN_Handle32(hwnd), HRGN_32(hrgnClip), flags));
1560 /**************************************************************************
1561 * GetWindowPlacement (USER.370)
1563 BOOL16 WINAPI GetWindowPlacement16( HWND16 hwnd, WINDOWPLACEMENT16 *wp16 )
1565 WINDOWPLACEMENT wpl;
1567 wpl.length = sizeof(wpl);
1568 if (!GetWindowPlacement( WIN_Handle32(hwnd), &wpl )) return FALSE;
1569 wp16->length = sizeof(*wp16);
1570 wp16->flags = wpl.flags;
1571 wp16->showCmd = wpl.showCmd;
1572 wp16->ptMinPosition.x = wpl.ptMinPosition.x;
1573 wp16->ptMinPosition.y = wpl.ptMinPosition.y;
1574 wp16->ptMaxPosition.x = wpl.ptMaxPosition.x;
1575 wp16->ptMaxPosition.y = wpl.ptMaxPosition.y;
1576 wp16->rcNormalPosition.left = wpl.rcNormalPosition.left;
1577 wp16->rcNormalPosition.top = wpl.rcNormalPosition.top;
1578 wp16->rcNormalPosition.right = wpl.rcNormalPosition.right;
1579 wp16->rcNormalPosition.bottom = wpl.rcNormalPosition.bottom;
1580 return TRUE;
1584 /**************************************************************************
1585 * SetWindowPlacement (USER.371)
1587 BOOL16 WINAPI SetWindowPlacement16( HWND16 hwnd, const WINDOWPLACEMENT16 *wp16 )
1589 WINDOWPLACEMENT wpl;
1591 if (!wp16) return FALSE;
1592 wpl.length = sizeof(wpl);
1593 wpl.flags = wp16->flags;
1594 wpl.showCmd = wp16->showCmd;
1595 wpl.ptMinPosition.x = wp16->ptMinPosition.x;
1596 wpl.ptMinPosition.y = wp16->ptMinPosition.y;
1597 wpl.ptMaxPosition.x = wp16->ptMaxPosition.x;
1598 wpl.ptMaxPosition.y = wp16->ptMaxPosition.y;
1599 wpl.rcNormalPosition.left = wp16->rcNormalPosition.left;
1600 wpl.rcNormalPosition.top = wp16->rcNormalPosition.top;
1601 wpl.rcNormalPosition.right = wp16->rcNormalPosition.right;
1602 wpl.rcNormalPosition.bottom = wp16->rcNormalPosition.bottom;
1603 return SetWindowPlacement( WIN_Handle32(hwnd), &wpl );
1607 /***********************************************************************
1608 * RegisterClassEx (USER.397)
1610 ATOM WINAPI RegisterClassEx16( const WNDCLASSEX16 *wc )
1612 struct class_entry *class;
1613 WNDCLASSEXA wc32;
1614 HINSTANCE16 inst;
1615 ATOM atom;
1617 inst = GetExePtr( wc->hInstance );
1618 if (!inst) inst = GetModuleHandle16( NULL );
1620 wc32.cbSize = sizeof(wc32);
1621 wc32.style = wc->style;
1622 wc32.lpfnWndProc = WINPROC_AllocProc16( wc->lpfnWndProc );
1623 wc32.cbClsExtra = wc->cbClsExtra;
1624 wc32.cbWndExtra = wc->cbWndExtra;
1625 wc32.hInstance = HINSTANCE_32(inst);
1626 wc32.hIcon = get_icon_32(wc->hIcon);
1627 wc32.hCursor = get_icon_32( wc->hCursor );
1628 wc32.hbrBackground = HBRUSH_32(wc->hbrBackground);
1629 wc32.lpszMenuName = MapSL(wc->lpszMenuName);
1630 wc32.lpszClassName = MapSL(wc->lpszClassName);
1631 wc32.hIconSm = get_icon_32(wc->hIconSm);
1632 atom = RegisterClassExA( &wc32 );
1633 if ((class = HeapAlloc( GetProcessHeap(), 0, sizeof(*class) )))
1635 class->atom = atom;
1636 class->inst = inst;
1637 list_add_tail( &class_list, &class->entry );
1639 return atom;
1643 /***********************************************************************
1644 * GetClassInfoEx (USER.398)
1646 * FIXME: this is just a guess, I have no idea if GetClassInfoEx() is the
1647 * same in Win16 as in Win32. --AJ
1649 BOOL16 WINAPI GetClassInfoEx16( HINSTANCE16 hInst16, SEGPTR name, WNDCLASSEX16 *wc )
1651 static HMODULE user32_module;
1652 WNDCLASSEXA wc32;
1653 HINSTANCE hInstance;
1654 BOOL ret;
1656 if (!user32_module) user32_module = GetModuleHandleA( "user32.dll" );
1657 if (hInst16 == GetModuleHandle16("user")) hInstance = user32_module;
1658 else hInstance = HINSTANCE_32(GetExePtr( hInst16 ));
1660 ret = GetClassInfoExA( hInstance, MapSL(name), &wc32 );
1662 if (ret)
1664 wc->lpfnWndProc = WINPROC_GetProc16( wc32.lpfnWndProc, FALSE );
1665 wc->style = wc32.style;
1666 wc->cbClsExtra = wc32.cbClsExtra;
1667 wc->cbWndExtra = wc32.cbWndExtra;
1668 wc->hInstance = (wc32.hInstance == user32_module) ? GetModuleHandle16("user") : HINSTANCE_16(wc32.hInstance);
1669 wc->hIcon = get_icon_16( wc32.hIcon );
1670 wc->hIconSm = get_icon_16( wc32.hIconSm );
1671 wc->hCursor = get_icon_16( wc32.hCursor );
1672 wc->hbrBackground = HBRUSH_16(wc32.hbrBackground);
1673 wc->lpszClassName = 0;
1674 wc->lpszMenuName = MapLS((void *)wc32.lpszMenuName); /* FIXME: leak */
1676 return ret;
1680 /**************************************************************************
1681 * ChildWindowFromPointEx (USER.399)
1683 HWND16 WINAPI ChildWindowFromPointEx16( HWND16 hwndParent, POINT16 pt, UINT16 uFlags)
1685 POINT pt32;
1687 pt32.x = pt.x;
1688 pt32.y = pt.y;
1689 return HWND_16( ChildWindowFromPointEx( WIN_Handle32(hwndParent), pt32, uFlags ));
1693 /**************************************************************************
1694 * GetPriorityClipboardFormat (USER.402)
1696 INT16 WINAPI GetPriorityClipboardFormat16( UINT16 *list, INT16 count )
1698 int i;
1700 for (i = 0; i < count; i++)
1701 if (IsClipboardFormatAvailable( list[i] )) return list[i];
1702 return -1;
1706 /***********************************************************************
1707 * UnregisterClass (USER.403)
1709 BOOL16 WINAPI UnregisterClass16( LPCSTR className, HINSTANCE16 hInstance )
1711 ATOM atom;
1713 if (hInstance == GetModuleHandle16("user")) hInstance = 0;
1714 else hInstance = GetExePtr( hInstance );
1716 if ((atom = GlobalFindAtomA( className )))
1718 struct class_entry *class;
1719 LIST_FOR_EACH_ENTRY( class, &class_list, struct class_entry, entry )
1721 if (class->inst != hInstance) continue;
1722 if (class->atom != atom) continue;
1723 list_remove( &class->entry );
1724 HeapFree( GetProcessHeap(), 0, class );
1725 break;
1728 return UnregisterClassA( className, HINSTANCE_32(hInstance) );
1732 /***********************************************************************
1733 * GetClassInfo (USER.404)
1735 BOOL16 WINAPI GetClassInfo16( HINSTANCE16 hInst16, SEGPTR name, WNDCLASS16 *wc )
1737 WNDCLASSEX16 wcex;
1738 UINT16 ret = GetClassInfoEx16( hInst16, name, &wcex );
1740 if (ret)
1742 wc->style = wcex.style;
1743 wc->lpfnWndProc = wcex.lpfnWndProc;
1744 wc->cbClsExtra = wcex.cbClsExtra;
1745 wc->cbWndExtra = wcex.cbWndExtra;
1746 wc->hInstance = wcex.hInstance;
1747 wc->hIcon = wcex.hIcon;
1748 wc->hCursor = wcex.hCursor;
1749 wc->hbrBackground = wcex.hbrBackground;
1750 wc->lpszMenuName = wcex.lpszMenuName;
1751 wc->lpszClassName = wcex.lpszClassName;
1753 return ret;
1757 /**************************************************************************
1758 * TrackPopupMenu (USER.416)
1760 BOOL16 WINAPI TrackPopupMenu16( HMENU16 hMenu, UINT16 wFlags, INT16 x, INT16 y,
1761 INT16 nReserved, HWND16 hwnd, const RECT16 *lpRect )
1763 RECT r;
1764 if (lpRect)
1766 r.left = lpRect->left;
1767 r.top = lpRect->top;
1768 r.right = lpRect->right;
1769 r.bottom = lpRect->bottom;
1771 return TrackPopupMenu( HMENU_32(hMenu), wFlags, x, y, nReserved,
1772 WIN_Handle32(hwnd), lpRect ? &r : NULL );
1776 /**************************************************************************
1777 * FindWindowEx (USER.427)
1779 HWND16 WINAPI FindWindowEx16( HWND16 parent, HWND16 child, LPCSTR className, LPCSTR title )
1781 return HWND_16( FindWindowExA( WIN_Handle32(parent), WIN_Handle32(child),
1782 className, title ));
1786 /***********************************************************************
1787 * DefFrameProc (USER.445)
1789 LRESULT WINAPI DefFrameProc16( HWND16 hwnd, HWND16 hwndMDIClient,
1790 UINT16 message, WPARAM16 wParam, LPARAM lParam )
1792 switch (message)
1794 case WM_SETTEXT:
1795 lParam = (LPARAM)MapSL(lParam);
1796 /* fall through */
1797 case WM_COMMAND:
1798 case WM_NCACTIVATE:
1799 case WM_SETFOCUS:
1800 case WM_SIZE:
1801 return DefFrameProcA( WIN_Handle32(hwnd), WIN_Handle32(hwndMDIClient),
1802 message, wParam, lParam );
1804 case WM_NEXTMENU:
1806 MDINEXTMENU next_menu;
1807 DefFrameProcW( WIN_Handle32(hwnd), WIN_Handle32(hwndMDIClient),
1808 message, wParam, (LPARAM)&next_menu );
1809 return MAKELONG( HMENU_16(next_menu.hmenuNext), HWND_16(next_menu.hwndNext) );
1811 default:
1812 return DefWindowProc16(hwnd, message, wParam, lParam);
1817 /***********************************************************************
1818 * DefMDIChildProc (USER.447)
1820 LRESULT WINAPI DefMDIChildProc16( HWND16 hwnd, UINT16 message,
1821 WPARAM16 wParam, LPARAM lParam )
1823 switch (message)
1825 case WM_SETTEXT:
1826 return DefMDIChildProcA( WIN_Handle32(hwnd), message, wParam, (LPARAM)MapSL(lParam) );
1828 case WM_MENUCHAR:
1829 case WM_CLOSE:
1830 case WM_SETFOCUS:
1831 case WM_CHILDACTIVATE:
1832 case WM_SYSCOMMAND:
1833 case WM_SETVISIBLE:
1834 case WM_SIZE:
1835 case WM_SYSCHAR:
1836 return DefMDIChildProcW( WIN_Handle32(hwnd), message, wParam, lParam );
1838 case WM_GETMINMAXINFO:
1840 MINMAXINFO16 *mmi16 = MapSL(lParam);
1841 MINMAXINFO mmi;
1843 mmi.ptReserved.x = mmi16->ptReserved.x;
1844 mmi.ptReserved.y = mmi16->ptReserved.y;
1845 mmi.ptMaxSize.x = mmi16->ptMaxSize.x;
1846 mmi.ptMaxSize.y = mmi16->ptMaxSize.y;
1847 mmi.ptMaxPosition.x = mmi16->ptMaxPosition.x;
1848 mmi.ptMaxPosition.y = mmi16->ptMaxPosition.y;
1849 mmi.ptMinTrackSize.x = mmi16->ptMinTrackSize.x;
1850 mmi.ptMinTrackSize.y = mmi16->ptMinTrackSize.y;
1851 mmi.ptMaxTrackSize.x = mmi16->ptMaxTrackSize.x;
1852 mmi.ptMaxTrackSize.y = mmi16->ptMaxTrackSize.y;
1854 DefMDIChildProcW( WIN_Handle32(hwnd), message, wParam, (LPARAM)&mmi );
1856 mmi16->ptReserved.x = mmi.ptReserved.x;
1857 mmi16->ptReserved.y = mmi.ptReserved.y;
1858 mmi16->ptMaxSize.x = mmi.ptMaxSize.x;
1859 mmi16->ptMaxSize.y = mmi.ptMaxSize.y;
1860 mmi16->ptMaxPosition.x = mmi.ptMaxPosition.x;
1861 mmi16->ptMaxPosition.y = mmi.ptMaxPosition.y;
1862 mmi16->ptMinTrackSize.x = mmi.ptMinTrackSize.x;
1863 mmi16->ptMinTrackSize.y = mmi.ptMinTrackSize.y;
1864 mmi16->ptMaxTrackSize.x = mmi.ptMaxTrackSize.x;
1865 mmi16->ptMaxTrackSize.y = mmi.ptMaxTrackSize.y;
1866 return 0;
1868 case WM_NEXTMENU:
1870 MDINEXTMENU next_menu;
1871 DefMDIChildProcW( WIN_Handle32(hwnd), message, wParam, (LPARAM)&next_menu );
1872 return MAKELONG( HMENU_16(next_menu.hmenuNext), HWND_16(next_menu.hwndNext) );
1874 default:
1875 return DefWindowProc16(hwnd, message, wParam, lParam);
1880 /**************************************************************************
1881 * DrawAnimatedRects (USER.448)
1883 BOOL16 WINAPI DrawAnimatedRects16( HWND16 hwnd, INT16 idAni,
1884 const RECT16* lprcFrom, const RECT16* lprcTo )
1886 RECT rcFrom32, rcTo32;
1887 rcFrom32.left = lprcFrom->left;
1888 rcFrom32.top = lprcFrom->top;
1889 rcFrom32.right = lprcFrom->right;
1890 rcFrom32.bottom = lprcFrom->bottom;
1891 rcTo32.left = lprcTo->left;
1892 rcTo32.top = lprcTo->top;
1893 rcTo32.right = lprcTo->right;
1894 rcTo32.bottom = lprcTo->bottom;
1895 return DrawAnimatedRects( WIN_Handle32(hwnd), idAni, &rcFrom32, &rcTo32 );
1899 /***********************************************************************
1900 * CreateWindowEx (USER.452)
1902 HWND16 WINAPI CreateWindowEx16( DWORD exStyle, LPCSTR className,
1903 LPCSTR windowName, DWORD style, INT16 x,
1904 INT16 y, INT16 width, INT16 height,
1905 HWND16 parent, HMENU16 menu,
1906 HINSTANCE16 instance, LPVOID data )
1908 CREATESTRUCTA cs;
1909 char buffer[256];
1910 HWND hwnd;
1912 /* Fix the coordinates */
1914 cs.x = (x == CW_USEDEFAULT16) ? CW_USEDEFAULT : (INT)x;
1915 cs.y = (y == CW_USEDEFAULT16) ? CW_USEDEFAULT : (INT)y;
1916 cs.cx = (width == CW_USEDEFAULT16) ? CW_USEDEFAULT : (INT)width;
1917 cs.cy = (height == CW_USEDEFAULT16) ? CW_USEDEFAULT : (INT)height;
1919 /* Create the window */
1921 cs.lpCreateParams = data;
1922 cs.hInstance = HINSTANCE_32(instance);
1923 cs.hMenu = HMENU_32(menu);
1924 cs.hwndParent = WIN_Handle32( parent );
1925 cs.style = style;
1926 cs.lpszName = windowName;
1927 cs.lpszClass = className;
1928 cs.dwExStyle = exStyle;
1930 /* load the menu */
1931 if (!menu && (style & (WS_CHILD | WS_POPUP)) != WS_CHILD)
1933 WNDCLASSA class;
1934 HINSTANCE16 module = GetExePtr( instance );
1936 if (GetClassInfoA( HINSTANCE_32(module), className, &class ))
1937 cs.hMenu = HMENU_32( LoadMenu16( module, class.lpszMenuName ));
1940 if (!IS_INTRESOURCE(className))
1942 WCHAR bufferW[256];
1944 if (!MultiByteToWideChar( CP_ACP, 0, className, -1, bufferW, ARRAY_SIZE(bufferW)))
1945 return 0;
1946 hwnd = create_window16( (CREATESTRUCTW *)&cs, bufferW, HINSTANCE_32(instance), FALSE );
1948 else
1950 if (!GlobalGetAtomNameA( LOWORD(className), buffer, sizeof(buffer) )) return 0;
1951 cs.lpszClass = buffer;
1952 hwnd = create_window16( (CREATESTRUCTW *)&cs, (LPCWSTR)className, HINSTANCE_32(instance), FALSE );
1954 return HWND_16( hwnd );
1958 /***********************************************************************
1959 * GetInternalWindowPos (USER.460)
1961 UINT16 WINAPI GetInternalWindowPos16( HWND16 hwnd, LPRECT16 rectWnd, LPPOINT16 ptIcon )
1963 WINDOWPLACEMENT16 wndpl;
1965 if (!GetWindowPlacement16( hwnd, &wndpl )) return 0;
1966 if (rectWnd) *rectWnd = wndpl.rcNormalPosition;
1967 if (ptIcon) *ptIcon = wndpl.ptMinPosition;
1968 return wndpl.showCmd;
1972 /**************************************************************************
1973 * SetInternalWindowPos (USER.461)
1975 void WINAPI SetInternalWindowPos16( HWND16 hwnd, UINT16 showCmd, LPRECT16 rect, LPPOINT16 pt )
1977 RECT rc32;
1978 POINT pt32;
1980 if (rect)
1982 rc32.left = rect->left;
1983 rc32.top = rect->top;
1984 rc32.right = rect->right;
1985 rc32.bottom = rect->bottom;
1987 if (pt)
1989 pt32.x = pt->x;
1990 pt32.y = pt->y;
1992 SetInternalWindowPos( WIN_Handle32(hwnd), showCmd,
1993 rect ? &rc32 : NULL, pt ? &pt32 : NULL );
1997 /**************************************************************************
1998 * CalcChildScroll (USER.462)
2000 void WINAPI CalcChildScroll16( HWND16 hwnd, WORD scroll )
2002 CalcChildScroll( WIN_Handle32(hwnd), scroll );
2006 /**************************************************************************
2007 * ScrollChildren (USER.463)
2009 void WINAPI ScrollChildren16(HWND16 hwnd, UINT16 uMsg, WPARAM16 wParam, LPARAM lParam)
2011 ScrollChildren( WIN_Handle32(hwnd), uMsg, wParam, lParam );
2015 /**************************************************************************
2016 * DragDetect (USER.465)
2018 BOOL16 WINAPI DragDetect16( HWND16 hwnd, POINT16 pt )
2020 POINT pt32;
2022 pt32.x = pt.x;
2023 pt32.y = pt.y;
2024 return DragDetect( WIN_Handle32(hwnd), pt32 );
2028 /**************************************************************************
2029 * SetScrollInfo (USER.475)
2031 INT16 WINAPI SetScrollInfo16( HWND16 hwnd, INT16 nBar, const SCROLLINFO *info, BOOL16 redraw )
2033 return SetScrollInfo( WIN_Handle32(hwnd), nBar, info, redraw );
2037 /**************************************************************************
2038 * GetScrollInfo (USER.476)
2040 BOOL16 WINAPI GetScrollInfo16( HWND16 hwnd, INT16 nBar, LPSCROLLINFO info )
2042 return GetScrollInfo( WIN_Handle32(hwnd), nBar, info );
2046 /**************************************************************************
2047 * EnableScrollBar (USER.482)
2049 BOOL16 WINAPI EnableScrollBar16( HWND16 hwnd, INT16 nBar, UINT16 flags )
2051 return EnableScrollBar( WIN_Handle32(hwnd), nBar, flags );
2055 /**************************************************************************
2056 * GetShellWindow (USER.600)
2058 HWND16 WINAPI GetShellWindow16(void)
2060 return HWND_16( GetShellWindow() );
2064 /**************************************************************************
2065 * GetForegroundWindow (USER.608)
2067 HWND16 WINAPI GetForegroundWindow16(void)
2069 return HWND_16( GetForegroundWindow() );
2073 /**************************************************************************
2074 * SetForegroundWindow (USER.609)
2076 BOOL16 WINAPI SetForegroundWindow16( HWND16 hwnd )
2078 return SetForegroundWindow( WIN_Handle32(hwnd) );
2082 /**************************************************************************
2083 * DrawCaptionTemp (USER.657)
2085 BOOL16 WINAPI DrawCaptionTemp16( HWND16 hwnd, HDC16 hdc, const RECT16 *rect,
2086 HFONT16 hFont, HICON16 hIcon, LPCSTR str, UINT16 uFlags )
2088 RECT rect32;
2090 if (rect)
2092 rect32.left = rect->left;
2093 rect32.top = rect->top;
2094 rect32.right = rect->right;
2095 rect32.bottom = rect->bottom;
2097 return DrawCaptionTempA( WIN_Handle32(hwnd), HDC_32(hdc),
2098 rect ? &rect32 : NULL, HFONT_32(hFont),
2099 get_icon_32(hIcon), str, uFlags & 0x1f );
2103 /**************************************************************************
2104 * DrawCaption (USER.660)
2106 BOOL16 WINAPI DrawCaption16( HWND16 hwnd, HDC16 hdc, const RECT16 *rect, UINT16 flags )
2108 RECT rect32;
2110 if (rect)
2112 rect32.left = rect->left;
2113 rect32.top = rect->top;
2114 rect32.right = rect->right;
2115 rect32.bottom = rect->bottom;
2117 return DrawCaption(WIN_Handle32(hwnd), HDC_32(hdc), rect ? &rect32 : NULL, flags);
2121 /**************************************************************************
2122 * GetMenuItemRect (USER.665)
2124 BOOL16 WINAPI GetMenuItemRect16( HWND16 hwnd, HMENU16 hMenu, UINT16 uItem,
2125 LPRECT16 rect)
2127 RECT r32;
2128 BOOL res;
2129 if (!rect) return FALSE;
2130 res = GetMenuItemRect( WIN_Handle32(hwnd), HMENU_32(hMenu), uItem, &r32 );
2131 rect->left = r32.left;
2132 rect->top = r32.top;
2133 rect->right = r32.right;
2134 rect->bottom = r32.bottom;
2135 return res;
2139 /**************************************************************************
2140 * SetWindowRgn (USER.668)
2142 INT16 WINAPI SetWindowRgn16( HWND16 hwnd, HRGN16 hrgn, BOOL16 redraw )
2144 return SetWindowRgn( WIN_Handle32(hwnd), HRGN_32(hrgn), redraw );
2148 /**************************************************************************
2149 * MessageBoxIndirect (USER.827)
2151 INT16 WINAPI MessageBoxIndirect16( LPMSGBOXPARAMS16 msgbox )
2153 char caption[256], text[256];
2154 MSGBOXPARAMSA msgbox32;
2156 msgbox32.cbSize = msgbox->cbSize;
2157 msgbox32.hwndOwner = WIN_Handle32( msgbox->hwndOwner );
2158 msgbox32.hInstance = 0;
2159 msgbox32.dwStyle = msgbox->dwStyle;
2160 msgbox32.lpszIcon = NULL;
2161 msgbox32.dwContextHelpId = msgbox->dwContextHelpId;
2162 msgbox32.lpfnMsgBoxCallback = msgbox->lpfnMsgBoxCallback;
2163 msgbox32.dwLanguageId = msgbox->dwLanguageId;
2165 if (!HIWORD(msgbox->lpszCaption))
2167 LoadString16( msgbox->hInstance, LOWORD(msgbox->lpszCaption), caption, sizeof(caption) );
2168 msgbox32.lpszCaption = caption;
2170 else msgbox32.lpszCaption = MapSL(msgbox->lpszCaption);
2172 if (!HIWORD(msgbox->lpszText))
2174 LoadString16( msgbox->hInstance, LOWORD(msgbox->lpszText), text, sizeof(text) );
2175 msgbox32.lpszText = text;
2177 else msgbox32.lpszText = MapSL(msgbox->lpszText);
2179 if ((msgbox->dwStyle & MB_ICONMASK) == MB_USERICON)
2181 FIXME( "user icon %s not supported\n", debugstr_a( MapSL(msgbox->lpszIcon) ));
2182 msgbox32.dwStyle &= ~MB_USERICON;
2185 return MessageBoxIndirectA( &msgbox32 );