dbghelp: Use local declarations of r_debug and link_map structs.
[wine.git] / dlls / user.exe16 / window.c
blobbf86719325b89bfb357cff7c0f02b6d72742f19c
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/gdi_driver.h"
27 #include "wine/debug.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(win);
31 /* size of buffer needed to store an atom string */
32 #define ATOM_BUFFER_SIZE 256
34 /* handle <--> handle16 conversions */
35 #define HANDLE_16(h32) (LOWORD(h32))
36 #define HANDLE_32(h16) ((HANDLE)(ULONG_PTR)(h16))
38 static HWND16 hwndSysModal;
40 struct class_entry
42 struct list entry;
43 ATOM atom;
44 HINSTANCE16 inst;
47 static struct list class_list = LIST_INIT( class_list );
49 struct wnd_enum_info
51 WNDENUMPROC16 proc;
52 LPARAM param;
55 /* callback for 16-bit window enumeration functions */
56 static BOOL CALLBACK wnd_enum_callback( HWND hwnd, LPARAM param )
58 const struct wnd_enum_info *info = (struct wnd_enum_info *)param;
59 WORD args[3];
60 DWORD ret;
62 args[2] = HWND_16(hwnd);
63 args[1] = HIWORD(info->param);
64 args[0] = LOWORD(info->param);
65 WOWCallback16Ex( (DWORD)info->proc, WCB16_PASCAL, sizeof(args), args, &ret );
66 return LOWORD(ret);
69 /* convert insert after window handle to 32-bit */
70 static inline HWND full_insert_after_hwnd( HWND16 hwnd )
72 HWND ret = WIN_Handle32( hwnd );
73 if (ret == (HWND)0xffff) ret = HWND_TOPMOST;
74 return ret;
77 void free_module_classes( HINSTANCE16 inst )
79 struct class_entry *class, *next;
81 LIST_FOR_EACH_ENTRY_SAFE( class, next, &class_list, struct class_entry, entry )
83 if (class->inst != inst) continue;
84 list_remove( &class->entry );
85 UnregisterClassA( (LPCSTR)MAKEINTATOM(class->atom), HINSTANCE_32(class->inst) );
86 HeapFree( GetProcessHeap(), 0, class );
90 /**************************************************************************
91 * MessageBox (USER.1)
93 INT16 WINAPI MessageBox16( HWND16 hwnd, LPCSTR text, LPCSTR title, UINT16 type )
95 return MessageBoxA( WIN_Handle32(hwnd), text, title, type );
99 /***********************************************************************
100 * SetTimer (USER.10)
102 UINT16 WINAPI SetTimer16( HWND16 hwnd, UINT16 id, UINT16 timeout, TIMERPROC16 proc )
104 TIMERPROC proc32 = (TIMERPROC)WINPROC_AllocProc16( (WNDPROC16)proc );
105 return SetTimer( WIN_Handle32(hwnd), id, timeout, proc32 );
109 /***********************************************************************
110 * SetSystemTimer (USER.11)
112 UINT16 WINAPI SetSystemTimer16( HWND16 hwnd, UINT16 id, UINT16 timeout, TIMERPROC16 proc )
114 TIMERPROC proc32 = (TIMERPROC)WINPROC_AllocProc16( (WNDPROC16)proc );
115 return SetSystemTimer( WIN_Handle32(hwnd), id, timeout, proc32 );
119 /**************************************************************************
120 * KillTimer (USER.12)
122 BOOL16 WINAPI KillTimer16( HWND16 hwnd, UINT16 id )
124 return KillTimer( WIN_Handle32(hwnd), id );
128 /**************************************************************************
129 * SetCapture (USER.18)
131 HWND16 WINAPI SetCapture16( HWND16 hwnd )
133 return HWND_16( SetCapture( WIN_Handle32(hwnd) ));
137 /**************************************************************************
138 * ReleaseCapture (USER.19)
140 BOOL16 WINAPI ReleaseCapture16(void)
142 return ReleaseCapture();
146 /**************************************************************************
147 * SetFocus (USER.22)
149 HWND16 WINAPI SetFocus16( HWND16 hwnd )
151 return HWND_16( SetFocus( WIN_Handle32(hwnd) ));
155 /**************************************************************************
156 * GetFocus (USER.23)
158 HWND16 WINAPI GetFocus16(void)
160 return HWND_16( GetFocus() );
164 /**************************************************************************
165 * RemoveProp (USER.24)
167 HANDLE16 WINAPI RemoveProp16( HWND16 hwnd, LPCSTR str )
169 return HANDLE_16(RemovePropA( WIN_Handle32(hwnd), str ));
173 /**************************************************************************
174 * GetProp (USER.25)
176 HANDLE16 WINAPI GetProp16( HWND16 hwnd, LPCSTR str )
178 return HANDLE_16(GetPropA( WIN_Handle32(hwnd), str ));
182 /**************************************************************************
183 * SetProp (USER.26)
185 BOOL16 WINAPI SetProp16( HWND16 hwnd, LPCSTR str, HANDLE16 handle )
187 return SetPropA( WIN_Handle32(hwnd), str, HANDLE_32(handle) );
191 /***********************************************************************
192 * EnumProps (USER.27)
194 INT16 WINAPI EnumProps16( HWND16 hwnd, PROPENUMPROC16 func )
196 int ret = -1, i, count, total = 32;
197 property_data_t *list;
199 while (total)
201 if (!(list = HeapAlloc( GetProcessHeap(), 0, total * sizeof(*list) ))) break;
202 count = 0;
203 SERVER_START_REQ( get_window_properties )
205 req->window = wine_server_user_handle( HWND_32(hwnd) );
206 wine_server_set_reply( req, list, total * sizeof(*list) );
207 if (!wine_server_call( req )) count = reply->total;
209 SERVER_END_REQ;
211 if (count && count <= total)
213 char string[ATOM_BUFFER_SIZE];
214 SEGPTR segptr = MapLS( string );
215 WORD args[4];
216 DWORD result;
218 for (i = 0; i < count; i++)
220 if (list[i].string) /* it was a string originally */
222 if (!GlobalGetAtomNameA( list[i].atom, string, ATOM_BUFFER_SIZE )) continue;
223 args[3] = hwnd;
224 args[2] = SELECTOROF(segptr);
225 args[1] = OFFSETOF(segptr);
226 args[0] = LOWORD(list[i].data);
228 else
230 args[3] = hwnd;
231 args[2] = 0;
232 args[1] = list[i].atom;
233 args[0] = LOWORD(list[i].data);
235 WOWCallback16Ex( (DWORD)func, WCB16_PASCAL, sizeof(args), args, &result );
236 if (!(ret = LOWORD(result))) break;
238 UnMapLS( segptr );
239 HeapFree( GetProcessHeap(), 0, list );
240 break;
242 HeapFree( GetProcessHeap(), 0, list );
243 total = count; /* restart with larger buffer */
245 return ret;
249 /**************************************************************************
250 * ClientToScreen (USER.28)
252 void WINAPI ClientToScreen16( HWND16 hwnd, LPPOINT16 lppnt )
254 MapWindowPoints16( hwnd, 0, lppnt, 1 );
258 /**************************************************************************
259 * ScreenToClient (USER.29)
261 void WINAPI ScreenToClient16( HWND16 hwnd, LPPOINT16 lppnt )
263 MapWindowPoints16( 0, hwnd, lppnt, 1 );
267 /**************************************************************************
268 * WindowFromPoint (USER.30)
270 HWND16 WINAPI WindowFromPoint16( POINT16 pt )
272 POINT pt32;
274 pt32.x = pt.x;
275 pt32.y = pt.y;
276 return HWND_16( WindowFromPoint( pt32 ) );
280 /**************************************************************************
281 * IsIconic (USER.31)
283 BOOL16 WINAPI IsIconic16(HWND16 hwnd)
285 return IsIconic( WIN_Handle32(hwnd) );
289 /**************************************************************************
290 * GetWindowRect (USER.32)
292 void WINAPI GetWindowRect16( HWND16 hwnd, LPRECT16 rect )
294 RECT rect32;
296 GetWindowRect( WIN_Handle32(hwnd), &rect32 );
297 rect->left = rect32.left;
298 rect->top = rect32.top;
299 rect->right = rect32.right;
300 rect->bottom = rect32.bottom;
304 /**************************************************************************
305 * GetClientRect (USER.33)
307 void WINAPI GetClientRect16( HWND16 hwnd, LPRECT16 rect )
309 RECT rect32;
311 GetClientRect( WIN_Handle32(hwnd), &rect32 );
312 rect->left = rect32.left;
313 rect->top = rect32.top;
314 rect->right = rect32.right;
315 rect->bottom = rect32.bottom;
319 /**************************************************************************
320 * EnableWindow (USER.34)
322 BOOL16 WINAPI EnableWindow16( HWND16 hwnd, BOOL16 enable )
324 return EnableWindow( WIN_Handle32(hwnd), enable );
328 /**************************************************************************
329 * IsWindowEnabled (USER.35)
331 BOOL16 WINAPI IsWindowEnabled16(HWND16 hwnd)
333 return IsWindowEnabled( WIN_Handle32(hwnd) );
337 /**************************************************************************
338 * GetWindowText (USER.36)
340 INT16 WINAPI GetWindowText16( HWND16 hwnd, SEGPTR lpString, INT16 nMaxCount )
342 return SendMessage16( hwnd, WM_GETTEXT, nMaxCount, lpString );
346 /**************************************************************************
347 * SetWindowText (USER.37)
349 BOOL16 WINAPI SetWindowText16( HWND16 hwnd, SEGPTR lpString )
351 return SendMessage16( hwnd, WM_SETTEXT, 0, lpString );
355 /**************************************************************************
356 * GetWindowTextLength (USER.38)
358 INT16 WINAPI GetWindowTextLength16( HWND16 hwnd )
360 return SendMessage16( hwnd, WM_GETTEXTLENGTH, 0, 0 );
364 /***********************************************************************
365 * BeginPaint (USER.39)
367 HDC16 WINAPI BeginPaint16( HWND16 hwnd, LPPAINTSTRUCT16 lps )
369 PAINTSTRUCT ps;
371 BeginPaint( WIN_Handle32(hwnd), &ps );
372 lps->hdc = HDC_16(ps.hdc);
373 lps->fErase = ps.fErase;
374 lps->rcPaint.top = ps.rcPaint.top;
375 lps->rcPaint.left = ps.rcPaint.left;
376 lps->rcPaint.right = ps.rcPaint.right;
377 lps->rcPaint.bottom = ps.rcPaint.bottom;
378 lps->fRestore = ps.fRestore;
379 lps->fIncUpdate = ps.fIncUpdate;
380 return lps->hdc;
384 /***********************************************************************
385 * EndPaint (USER.40)
387 BOOL16 WINAPI EndPaint16( HWND16 hwnd, const PAINTSTRUCT16* lps )
389 PAINTSTRUCT ps;
391 ps.hdc = HDC_32(lps->hdc);
392 return EndPaint( WIN_Handle32(hwnd), &ps );
396 /***********************************************************************
397 * CreateWindow (USER.41)
399 HWND16 WINAPI CreateWindow16( LPCSTR className, LPCSTR windowName,
400 DWORD style, INT16 x, INT16 y, INT16 width,
401 INT16 height, HWND16 parent, HMENU16 menu,
402 HINSTANCE16 instance, LPVOID data )
404 return CreateWindowEx16( 0, className, windowName, style,
405 x, y, width, height, parent, menu, instance, data );
409 /**************************************************************************
410 * ShowWindow (USER.42)
412 BOOL16 WINAPI ShowWindow16( HWND16 hwnd, INT16 cmd )
414 return ShowWindow( WIN_Handle32(hwnd), cmd );
418 /**************************************************************************
419 * CloseWindow (USER.43)
421 BOOL16 WINAPI CloseWindow16( HWND16 hwnd )
423 return CloseWindow( WIN_Handle32(hwnd) );
427 /**************************************************************************
428 * OpenIcon (USER.44)
430 BOOL16 WINAPI OpenIcon16( HWND16 hwnd )
432 return OpenIcon( WIN_Handle32(hwnd) );
436 /**************************************************************************
437 * BringWindowToTop (USER.45)
439 BOOL16 WINAPI BringWindowToTop16( HWND16 hwnd )
441 return BringWindowToTop( WIN_Handle32(hwnd) );
445 /**************************************************************************
446 * GetParent (USER.46)
448 HWND16 WINAPI GetParent16( HWND16 hwnd )
450 return HWND_16( GetParent( WIN_Handle32(hwnd) ));
454 /**************************************************************************
455 * IsWindow (USER.47)
457 BOOL16 WINAPI IsWindow16( HWND16 hwnd )
459 STACK16FRAME *frame = MapSL( (SEGPTR)NtCurrentTeb()->WOW32Reserved );
460 frame->es = USER_HeapSel;
461 /* don't use WIN_Handle32 here, we don't care about the full handle */
462 return IsWindow( HWND_32(hwnd) );
466 /**************************************************************************
467 * IsChild (USER.48)
469 BOOL16 WINAPI IsChild16( HWND16 parent, HWND16 child )
471 return IsChild( WIN_Handle32(parent), WIN_Handle32(child) );
475 /**************************************************************************
476 * IsWindowVisible (USER.49)
478 BOOL16 WINAPI IsWindowVisible16( HWND16 hwnd )
480 return IsWindowVisible( WIN_Handle32(hwnd) );
484 /**************************************************************************
485 * FindWindow (USER.50)
487 HWND16 WINAPI FindWindow16( LPCSTR className, LPCSTR title )
489 return HWND_16( FindWindowA( className, title ));
493 /**************************************************************************
494 * DestroyWindow (USER.53)
496 BOOL16 WINAPI DestroyWindow16( HWND16 hwnd )
498 return DestroyWindow( WIN_Handle32(hwnd) );
502 /*******************************************************************
503 * EnumWindows (USER.54)
505 BOOL16 WINAPI EnumWindows16( WNDENUMPROC16 func, LPARAM lParam )
507 struct wnd_enum_info info;
509 info.proc = func;
510 info.param = lParam;
511 return EnumWindows( wnd_enum_callback, (LPARAM)&info );
515 /**********************************************************************
516 * EnumChildWindows (USER.55)
518 BOOL16 WINAPI EnumChildWindows16( HWND16 parent, WNDENUMPROC16 func, LPARAM lParam )
520 struct wnd_enum_info info;
522 info.proc = func;
523 info.param = lParam;
524 return EnumChildWindows( WIN_Handle32(parent), wnd_enum_callback, (LPARAM)&info );
528 /**************************************************************************
529 * MoveWindow (USER.56)
531 BOOL16 WINAPI MoveWindow16( HWND16 hwnd, INT16 x, INT16 y, INT16 cx, INT16 cy, BOOL16 repaint )
533 return MoveWindow( WIN_Handle32(hwnd), x, y, cx, cy, repaint );
537 /***********************************************************************
538 * RegisterClass (USER.57)
540 ATOM WINAPI RegisterClass16( const WNDCLASS16 *wc )
542 WNDCLASSEX16 wcex;
544 wcex.cbSize = sizeof(wcex);
545 wcex.style = wc->style;
546 wcex.lpfnWndProc = wc->lpfnWndProc;
547 wcex.cbClsExtra = wc->cbClsExtra;
548 wcex.cbWndExtra = wc->cbWndExtra;
549 wcex.hInstance = wc->hInstance;
550 wcex.hIcon = wc->hIcon;
551 wcex.hCursor = wc->hCursor;
552 wcex.hbrBackground = wc->hbrBackground;
553 wcex.lpszMenuName = wc->lpszMenuName;
554 wcex.lpszClassName = wc->lpszClassName;
555 wcex.hIconSm = 0;
556 return RegisterClassEx16( &wcex );
560 /**************************************************************************
561 * GetClassName (USER.58)
563 INT16 WINAPI GetClassName16( HWND16 hwnd, LPSTR buffer, INT16 count )
565 return GetClassNameA( WIN_Handle32(hwnd), buffer, count );
569 /**************************************************************************
570 * SetActiveWindow (USER.59)
572 HWND16 WINAPI SetActiveWindow16( HWND16 hwnd )
574 return HWND_16( SetActiveWindow( WIN_Handle32(hwnd) ));
578 /**************************************************************************
579 * GetActiveWindow (USER.60)
581 HWND16 WINAPI GetActiveWindow16(void)
583 return HWND_16( GetActiveWindow() );
587 /**************************************************************************
588 * ScrollWindow (USER.61)
590 void WINAPI ScrollWindow16( HWND16 hwnd, INT16 dx, INT16 dy, const RECT16 *rect,
591 const RECT16 *clipRect )
593 RECT rect32, clipRect32;
595 if (rect)
597 rect32.left = rect->left;
598 rect32.top = rect->top;
599 rect32.right = rect->right;
600 rect32.bottom = rect->bottom;
602 if (clipRect)
604 clipRect32.left = clipRect->left;
605 clipRect32.top = clipRect->top;
606 clipRect32.right = clipRect->right;
607 clipRect32.bottom = clipRect->bottom;
609 ScrollWindow( WIN_Handle32(hwnd), dx, dy, rect ? &rect32 : NULL,
610 clipRect ? &clipRect32 : NULL );
614 /**************************************************************************
615 * SetScrollPos (USER.62)
617 INT16 WINAPI SetScrollPos16( HWND16 hwnd, INT16 nBar, INT16 nPos, BOOL16 redraw )
619 return SetScrollPos( WIN_Handle32(hwnd), nBar, nPos, redraw );
623 /**************************************************************************
624 * GetScrollPos (USER.63)
626 INT16 WINAPI GetScrollPos16( HWND16 hwnd, INT16 nBar )
628 return GetScrollPos( WIN_Handle32(hwnd), nBar );
632 /**************************************************************************
633 * SetScrollRange (USER.64)
635 void WINAPI SetScrollRange16( HWND16 hwnd, INT16 nBar, INT16 MinVal, INT16 MaxVal, BOOL16 redraw )
637 /* Invalid range -> range is set to (0,0) */
638 if ((INT)MaxVal - (INT)MinVal > 0x7fff) MinVal = MaxVal = 0;
639 SetScrollRange( WIN_Handle32(hwnd), nBar, MinVal, MaxVal, redraw );
643 /**************************************************************************
644 * GetScrollRange (USER.65)
646 BOOL16 WINAPI GetScrollRange16( HWND16 hwnd, INT16 nBar, LPINT16 lpMin, LPINT16 lpMax)
648 INT min, max;
649 BOOL ret = GetScrollRange( WIN_Handle32(hwnd), nBar, &min, &max );
650 if (lpMin) *lpMin = min;
651 if (lpMax) *lpMax = max;
652 return ret;
656 /**************************************************************************
657 * GetDC (USER.66)
659 HDC16 WINAPI GetDC16( HWND16 hwnd )
661 return HDC_16(GetDC( WIN_Handle32(hwnd) ));
665 /**************************************************************************
666 * GetWindowDC (USER.67)
668 HDC16 WINAPI GetWindowDC16( HWND16 hwnd )
670 return GetDCEx16( hwnd, 0, DCX_USESTYLE | DCX_WINDOW );
674 /**************************************************************************
675 * ReleaseDC (USER.68)
677 INT16 WINAPI ReleaseDC16( HWND16 hwnd, HDC16 hdc )
679 INT16 ret = (INT16)ReleaseDC( WIN_Handle32(hwnd), HDC_32(hdc) );
680 SetHookFlags( HDC_32(hdc), DCHF_ENABLEDC );
681 return ret;
685 /**************************************************************************
686 * FlashWindow (USER.105)
688 BOOL16 WINAPI FlashWindow16( HWND16 hwnd, BOOL16 bInvert )
690 return FlashWindow( WIN_Handle32(hwnd), bInvert );
694 /**************************************************************************
695 * WindowFromDC (USER.117)
697 HWND16 WINAPI WindowFromDC16( HDC16 hDC )
699 return HWND_16( WindowFromDC( HDC_32(hDC) ) );
703 /**************************************************************************
704 * UpdateWindow (USER.124)
706 void WINAPI UpdateWindow16( HWND16 hwnd )
708 RedrawWindow16( hwnd, NULL, 0, RDW_UPDATENOW | RDW_ALLCHILDREN );
712 /**************************************************************************
713 * InvalidateRect (USER.125)
715 void WINAPI InvalidateRect16( HWND16 hwnd, const RECT16 *rect, BOOL16 erase )
717 RedrawWindow16( hwnd, rect, 0, RDW_INVALIDATE | (erase ? RDW_ERASE : 0) );
721 /**************************************************************************
722 * InvalidateRgn (USER.126)
724 void WINAPI InvalidateRgn16( HWND16 hwnd, HRGN16 hrgn, BOOL16 erase )
726 RedrawWindow16( hwnd, NULL, hrgn, RDW_INVALIDATE | (erase ? RDW_ERASE : 0) );
730 /**************************************************************************
731 * ValidateRect (USER.127)
733 void WINAPI ValidateRect16( HWND16 hwnd, const RECT16 *rect )
735 RedrawWindow16( hwnd, rect, 0, RDW_VALIDATE | RDW_NOCHILDREN );
739 /**************************************************************************
740 * ValidateRgn (USER.128)
742 void WINAPI ValidateRgn16( HWND16 hwnd, HRGN16 hrgn )
744 RedrawWindow16( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOCHILDREN );
748 /**************************************************************************
749 * GetClassWord (USER.129)
751 WORD WINAPI GetClassWord16( HWND16 hwnd, INT16 offset )
753 HICON icon;
755 switch (offset)
757 case GCLP_HCURSOR:
758 case GCLP_HICON:
759 case GCLP_HICONSM:
760 icon = (HICON)GetClassLongPtrW( WIN_Handle32(hwnd), offset );
761 return get_icon_16( icon );
763 return GetClassWord( WIN_Handle32(hwnd), offset );
767 /**************************************************************************
768 * SetClassWord (USER.130)
770 WORD WINAPI SetClassWord16( HWND16 hwnd, INT16 offset, WORD newval )
772 HICON icon;
774 switch (offset)
776 case GCLP_HCURSOR:
777 case GCLP_HICON:
778 case GCLP_HICONSM:
779 icon = (HICON)SetClassLongPtrW( WIN_Handle32(hwnd), offset, (ULONG_PTR)get_icon_32(newval) );
780 return get_icon_16( icon );
782 return SetClassWord( WIN_Handle32(hwnd), offset, newval );
786 /***********************************************************************
787 * GetClassLong (USER.131)
789 LONG WINAPI GetClassLong16( HWND16 hwnd16, INT16 offset )
791 LONG_PTR ret = GetClassLongA( WIN_Handle32(hwnd16), offset );
793 switch( offset )
795 case GCLP_WNDPROC:
796 return (LONG_PTR)WINPROC_GetProc16( (WNDPROC)ret, FALSE );
797 case GCLP_MENUNAME:
798 return MapLS( (void *)ret ); /* leak */
799 case GCLP_HCURSOR:
800 case GCLP_HICON:
801 case GCLP_HICONSM:
802 return get_icon_16( (HICON)ret );
803 default:
804 return ret;
809 /***********************************************************************
810 * SetClassLong (USER.132)
812 LONG WINAPI SetClassLong16( HWND16 hwnd16, INT16 offset, LONG newval )
814 HICON icon;
816 switch( offset )
818 case GCLP_HCURSOR:
819 case GCLP_HICON:
820 case GCLP_HICONSM:
821 icon = (HICON)SetClassLongPtrW( WIN_Handle32(hwnd16), offset, (ULONG_PTR)get_icon_32(newval) );
822 return get_icon_16( icon );
823 case GCLP_WNDPROC:
825 WNDPROC new_proc = WINPROC_AllocProc16( (WNDPROC16)newval );
826 WNDPROC old_proc = (WNDPROC)SetClassLongA( WIN_Handle32(hwnd16), offset, (LONG_PTR)new_proc );
827 return (LONG)WINPROC_GetProc16( old_proc, FALSE );
829 case GCLP_MENUNAME:
830 newval = (LONG)MapSL( newval );
831 /* fall through */
832 default:
833 return SetClassLongA( WIN_Handle32(hwnd16), offset, newval );
838 /**************************************************************************
839 * GetWindowWord (USER.133)
841 WORD WINAPI GetWindowWord16( HWND16 hwnd, INT16 offset )
843 return GetWindowWord( WIN_Handle32(hwnd), offset );
847 /**************************************************************************
848 * SetWindowWord (USER.134)
850 WORD WINAPI SetWindowWord16( HWND16 hwnd, INT16 offset, WORD newval )
852 return SetWindowWord( WIN_Handle32(hwnd), offset, newval );
856 /**********************************************************************
857 * GetWindowLong (USER.135)
859 LONG WINAPI GetWindowLong16( HWND16 hwnd16, INT16 offset )
861 HWND hwnd = WIN_Handle32( hwnd16 );
862 LONG_PTR retvalue;
863 BOOL is_winproc = (offset == GWLP_WNDPROC);
865 if (offset >= 0)
867 int cbWndExtra = GetClassLongA( hwnd, GCL_CBWNDEXTRA );
869 if (offset > (int)(cbWndExtra - sizeof(LONG)))
872 * Some programs try to access last element from 16 bit
873 * code using illegal offset value. Hopefully this is
874 * what those programs really expect.
876 if (cbWndExtra >= 4 && offset == cbWndExtra - sizeof(WORD))
878 offset = cbWndExtra - sizeof(LONG);
880 else
882 SetLastError( ERROR_INVALID_INDEX );
883 return 0;
886 else if (offset == DWLP_DLGPROC)
887 is_winproc = (wow_handlers32.get_dialog_info( hwnd, FALSE ) != NULL);
889 retvalue = GetWindowLongA( hwnd, offset );
890 if (is_winproc) retvalue = (LONG_PTR)WINPROC_GetProc16( (WNDPROC)retvalue, FALSE );
891 return retvalue;
895 /**********************************************************************
896 * SetWindowLong (USER.136)
898 LONG WINAPI SetWindowLong16( HWND16 hwnd16, INT16 offset, LONG newval )
900 HWND hwnd = WIN_Handle32( hwnd16 );
901 BOOL is_winproc = (offset == GWLP_WNDPROC);
903 if (offset == DWLP_DLGPROC)
904 is_winproc = (wow_handlers32.get_dialog_info( hwnd, FALSE ) != NULL);
906 if (is_winproc)
908 WNDPROC new_proc = WINPROC_AllocProc16( (WNDPROC16)newval );
909 WNDPROC old_proc = (WNDPROC)SetWindowLongPtrA( hwnd, offset, (LONG_PTR)new_proc );
910 return (LONG)WINPROC_GetProc16( old_proc, FALSE );
912 else return SetWindowLongA( hwnd, offset, newval );
916 /**************************************************************************
917 * OpenClipboard (USER.137)
919 BOOL16 WINAPI OpenClipboard16( HWND16 hwnd )
921 return OpenClipboard( WIN_Handle32(hwnd) );
925 /**************************************************************************
926 * GetClipboardOwner (USER.140)
928 HWND16 WINAPI GetClipboardOwner16(void)
930 return HWND_16( GetClipboardOwner() );
934 /**************************************************************************
935 * SetClipboardViewer (USER.147)
937 HWND16 WINAPI SetClipboardViewer16( HWND16 hwnd )
939 return HWND_16( SetClipboardViewer( WIN_Handle32(hwnd) ));
943 /**************************************************************************
944 * GetClipboardViewer (USER.148)
946 HWND16 WINAPI GetClipboardViewer16(void)
948 return HWND_16( GetClipboardViewer() );
952 /**************************************************************************
953 * ChangeClipboardChain (USER.149)
955 BOOL16 WINAPI ChangeClipboardChain16(HWND16 hwnd, HWND16 hwndNext)
957 return ChangeClipboardChain( WIN_Handle32(hwnd), WIN_Handle32(hwndNext) );
961 /**************************************************************************
962 * GetSystemMenu (USER.156)
964 HMENU16 WINAPI GetSystemMenu16( HWND16 hwnd, BOOL16 revert )
966 return HMENU_16(GetSystemMenu( WIN_Handle32(hwnd), revert ));
970 /**************************************************************************
971 * GetMenu (USER.157)
973 HMENU16 WINAPI GetMenu16( HWND16 hwnd )
975 return HMENU_16(GetMenu( WIN_Handle32(hwnd) ));
979 /**************************************************************************
980 * SetMenu (USER.158)
982 BOOL16 WINAPI SetMenu16( HWND16 hwnd, HMENU16 hMenu )
984 return SetMenu( WIN_Handle32(hwnd), HMENU_32(hMenu) );
988 /**************************************************************************
989 * DrawMenuBar (USER.160)
991 void WINAPI DrawMenuBar16( HWND16 hwnd )
993 DrawMenuBar( WIN_Handle32(hwnd) );
997 /**************************************************************************
998 * HiliteMenuItem (USER.162)
1000 BOOL16 WINAPI HiliteMenuItem16( HWND16 hwnd, HMENU16 hMenu, UINT16 id, UINT16 wHilite )
1002 return HiliteMenuItem( WIN_Handle32(hwnd), HMENU_32(hMenu), id, wHilite );
1006 /**************************************************************************
1007 * CreateCaret (USER.163)
1009 void WINAPI CreateCaret16( HWND16 hwnd, HBITMAP16 bitmap, INT16 width, INT16 height )
1011 CreateCaret( WIN_Handle32(hwnd), HBITMAP_32(bitmap), width, height );
1015 /*****************************************************************
1016 * DestroyCaret (USER.164)
1018 void WINAPI DestroyCaret16(void)
1020 DestroyCaret();
1024 /*****************************************************************
1025 * SetCaretPos (USER.165)
1027 void WINAPI SetCaretPos16( INT16 x, INT16 y )
1029 SetCaretPos( x, y );
1033 /**************************************************************************
1034 * HideCaret (USER.166)
1036 void WINAPI HideCaret16( HWND16 hwnd )
1038 HideCaret( WIN_Handle32(hwnd) );
1042 /**************************************************************************
1043 * ShowCaret (USER.167)
1045 void WINAPI ShowCaret16( HWND16 hwnd )
1047 ShowCaret( WIN_Handle32(hwnd) );
1051 /*****************************************************************
1052 * SetCaretBlinkTime (USER.168)
1054 void WINAPI SetCaretBlinkTime16( UINT16 msecs )
1056 SetCaretBlinkTime( msecs );
1060 /*****************************************************************
1061 * GetCaretBlinkTime (USER.169)
1063 UINT16 WINAPI GetCaretBlinkTime16(void)
1065 return GetCaretBlinkTime();
1069 /**************************************************************************
1070 * ArrangeIconicWindows (USER.170)
1072 UINT16 WINAPI ArrangeIconicWindows16( HWND16 parent)
1074 return ArrangeIconicWindows( WIN_Handle32(parent) );
1078 /**************************************************************************
1079 * SwitchToThisWindow (USER.172)
1081 void WINAPI SwitchToThisWindow16( HWND16 hwnd, BOOL16 restore )
1083 SwitchToThisWindow( WIN_Handle32(hwnd), restore );
1087 /**************************************************************************
1088 * KillSystemTimer (USER.182)
1090 BOOL16 WINAPI KillSystemTimer16( HWND16 hwnd, UINT16 id )
1092 return KillSystemTimer( WIN_Handle32(hwnd), id );
1096 /*****************************************************************
1097 * GetCaretPos (USER.183)
1099 void WINAPI GetCaretPos16( LPPOINT16 pt16 )
1101 POINT pt;
1102 if (GetCaretPos( &pt ))
1104 pt16->x = pt.x;
1105 pt16->y = pt.y;
1110 /**************************************************************************
1111 * SetSysModalWindow (USER.188)
1113 HWND16 WINAPI SetSysModalWindow16( HWND16 hwnd )
1115 HWND16 old = hwndSysModal;
1116 hwndSysModal = hwnd;
1117 return old;
1121 /**************************************************************************
1122 * GetSysModalWindow (USER.189)
1124 HWND16 WINAPI GetSysModalWindow16(void)
1126 return hwndSysModal;
1130 /**************************************************************************
1131 * GetUpdateRect (USER.190)
1133 BOOL16 WINAPI GetUpdateRect16( HWND16 hwnd, LPRECT16 rect, BOOL16 erase )
1135 RECT r;
1136 BOOL16 ret;
1138 if (!rect) return GetUpdateRect( WIN_Handle32(hwnd), NULL, erase );
1139 ret = GetUpdateRect( WIN_Handle32(hwnd), &r, erase );
1140 rect->left = r.left;
1141 rect->top = r.top;
1142 rect->right = r.right;
1143 rect->bottom = r.bottom;
1144 return ret;
1148 /**************************************************************************
1149 * ChildWindowFromPoint (USER.191)
1151 HWND16 WINAPI ChildWindowFromPoint16( HWND16 hwndParent, POINT16 pt )
1153 POINT pt32;
1155 pt32.x = pt.x;
1156 pt32.y = pt.y;
1157 return HWND_16( ChildWindowFromPoint( WIN_Handle32(hwndParent), pt32 ));
1161 /***********************************************************************
1162 * CascadeChildWindows (USER.198)
1164 void WINAPI CascadeChildWindows16( HWND16 parent, WORD action )
1166 CascadeWindows( WIN_Handle32(parent), action, NULL, 0, NULL );
1170 /***********************************************************************
1171 * TileChildWindows (USER.199)
1173 void WINAPI TileChildWindows16( HWND16 parent, WORD action )
1175 TileWindows( WIN_Handle32(parent), action, NULL, 0, NULL );
1179 /***********************************************************************
1180 * GetWindowTask (USER.224)
1182 HTASK16 WINAPI GetWindowTask16( HWND16 hwnd )
1184 DWORD tid = GetWindowThreadProcessId( HWND_32(hwnd), NULL );
1185 if (!tid) return 0;
1186 return HTASK_16(tid);
1189 /**********************************************************************
1190 * EnumTaskWindows (USER.225)
1192 BOOL16 WINAPI EnumTaskWindows16( HTASK16 hTask, WNDENUMPROC16 func, LPARAM lParam )
1194 struct wnd_enum_info info;
1195 DWORD tid = HTASK_32( hTask );
1197 if (!tid) return FALSE;
1198 info.proc = func;
1199 info.param = lParam;
1200 return EnumThreadWindows( tid, wnd_enum_callback, (LPARAM)&info );
1204 /**************************************************************************
1205 * GetTopWindow (USER.229)
1207 HWND16 WINAPI GetTopWindow16( HWND16 hwnd )
1209 return HWND_16( GetTopWindow( WIN_Handle32(hwnd) ));
1213 /**************************************************************************
1214 * GetNextWindow (USER.230)
1216 HWND16 WINAPI GetNextWindow16( HWND16 hwnd, WORD flag )
1218 if ((flag != GW_HWNDNEXT) && (flag != GW_HWNDPREV)) return 0;
1219 return GetWindow16( hwnd, flag );
1223 /**************************************************************************
1224 * SetWindowPos (USER.232)
1226 BOOL16 WINAPI SetWindowPos16( HWND16 hwnd, HWND16 hwndInsertAfter,
1227 INT16 x, INT16 y, INT16 cx, INT16 cy, WORD flags)
1229 return SetWindowPos( WIN_Handle32(hwnd), full_insert_after_hwnd(hwndInsertAfter),
1230 x, y, cx, cy, flags );
1234 /**************************************************************************
1235 * SetParent (USER.233)
1237 HWND16 WINAPI SetParent16( HWND16 hwndChild, HWND16 hwndNewParent )
1239 return HWND_16( SetParent( WIN_Handle32(hwndChild), WIN_Handle32(hwndNewParent) ));
1243 /**************************************************************************
1244 * GetCapture (USER.236)
1246 HWND16 WINAPI GetCapture16(void)
1248 return HWND_16( GetCapture() );
1252 /**************************************************************************
1253 * GetUpdateRgn (USER.237)
1255 INT16 WINAPI GetUpdateRgn16( HWND16 hwnd, HRGN16 hrgn, BOOL16 erase )
1257 return GetUpdateRgn( WIN_Handle32(hwnd), HRGN_32(hrgn), erase );
1261 /**************************************************************************
1262 * ExcludeUpdateRgn (USER.238)
1264 INT16 WINAPI ExcludeUpdateRgn16( HDC16 hdc, HWND16 hwnd )
1266 return ExcludeUpdateRgn( HDC_32(hdc), WIN_Handle32(hwnd) );
1270 /**************************************************************************
1271 * GetOpenClipboardWindow (USER.248)
1273 HWND16 WINAPI GetOpenClipboardWindow16(void)
1275 return HWND_16( GetOpenClipboardWindow() );
1279 /*******************************************************************
1280 * MapWindowPoints (USER.258)
1282 void WINAPI MapWindowPoints16( HWND16 hwndFrom, HWND16 hwndTo, LPPOINT16 lppt, UINT16 count )
1284 POINT buffer[8], *ppt = buffer;
1285 UINT i;
1287 if (count > 8) ppt = HeapAlloc( GetProcessHeap(), 0, count * sizeof(*ppt) );
1288 for (i = 0; i < count; i++)
1290 ppt[i].x = lppt[i].x;
1291 ppt[i].y = lppt[i].y;
1293 MapWindowPoints( WIN_Handle32(hwndFrom), WIN_Handle32(hwndTo), ppt, count );
1294 for (i = 0; i < count; i++)
1296 lppt[i].x = ppt[i].x;
1297 lppt[i].y = ppt[i].y;
1299 if (ppt != buffer) HeapFree( GetProcessHeap(), 0, ppt );
1303 /**************************************************************************
1304 * BeginDeferWindowPos (USER.259)
1306 HDWP16 WINAPI BeginDeferWindowPos16( INT16 count )
1308 return HDWP_16(BeginDeferWindowPos( count ));
1312 /**************************************************************************
1313 * DeferWindowPos (USER.260)
1315 HDWP16 WINAPI DeferWindowPos16( HDWP16 hdwp, HWND16 hwnd, HWND16 hwndAfter,
1316 INT16 x, INT16 y, INT16 cx, INT16 cy,
1317 UINT16 flags )
1319 return HDWP_16(DeferWindowPos( HDWP_32(hdwp), WIN_Handle32(hwnd),
1320 full_insert_after_hwnd(hwndAfter), x, y, cx, cy, flags ));
1324 /**************************************************************************
1325 * EndDeferWindowPos (USER.261)
1327 BOOL16 WINAPI EndDeferWindowPos16( HDWP16 hdwp )
1329 return EndDeferWindowPos(HDWP_32(hdwp));
1333 /**************************************************************************
1334 * GetWindow (USER.262)
1336 HWND16 WINAPI GetWindow16( HWND16 hwnd, WORD rel )
1338 return HWND_16( GetWindow( WIN_Handle32(hwnd), rel ) );
1342 /**************************************************************************
1343 * ShowOwnedPopups (USER.265)
1345 void WINAPI ShowOwnedPopups16( HWND16 owner, BOOL16 fShow )
1347 ShowOwnedPopups( WIN_Handle32(owner), fShow );
1351 /**************************************************************************
1352 * ShowScrollBar (USER.267)
1354 void WINAPI ShowScrollBar16( HWND16 hwnd, INT16 nBar, BOOL16 fShow )
1356 ShowScrollBar( WIN_Handle32(hwnd), nBar, fShow );
1360 /**************************************************************************
1361 * IsZoomed (USER.272)
1363 BOOL16 WINAPI IsZoomed16(HWND16 hwnd)
1365 return IsZoomed( WIN_Handle32(hwnd) );
1369 /**************************************************************************
1370 * GetDlgCtrlID (USER.277)
1372 INT16 WINAPI GetDlgCtrlID16( HWND16 hwnd )
1374 return GetDlgCtrlID( WIN_Handle32(hwnd) );
1378 /**************************************************************************
1379 * GetDesktopHwnd (USER.278)
1381 * Exactly the same thing as GetDesktopWindow(), but not documented.
1382 * Don't ask me why...
1384 HWND16 WINAPI GetDesktopHwnd16(void)
1386 return GetDesktopWindow16();
1390 /**************************************************************************
1391 * SetSystemMenu (USER.280)
1393 BOOL16 WINAPI SetSystemMenu16( HWND16 hwnd, HMENU16 hMenu )
1395 return SetSystemMenu( WIN_Handle32(hwnd), HMENU_32(hMenu) );
1399 /**************************************************************************
1400 * GetDesktopWindow (USER.286)
1402 HWND16 WINAPI GetDesktopWindow16(void)
1404 return HWND_16( GetDesktopWindow() );
1408 /**************************************************************************
1409 * GetLastActivePopup (USER.287)
1411 HWND16 WINAPI GetLastActivePopup16( HWND16 hwnd )
1413 return HWND_16( GetLastActivePopup( WIN_Handle32(hwnd) ));
1417 /**************************************************************************
1418 * RedrawWindow (USER.290)
1420 BOOL16 WINAPI RedrawWindow16( HWND16 hwnd, const RECT16 *rectUpdate,
1421 HRGN16 hrgnUpdate, UINT16 flags )
1423 if (rectUpdate)
1425 RECT r;
1426 r.left = rectUpdate->left;
1427 r.top = rectUpdate->top;
1428 r.right = rectUpdate->right;
1429 r.bottom = rectUpdate->bottom;
1430 return RedrawWindow(WIN_Handle32(hwnd), &r, HRGN_32(hrgnUpdate), flags);
1432 return RedrawWindow(WIN_Handle32(hwnd), NULL, HRGN_32(hrgnUpdate), flags);
1436 /**************************************************************************
1437 * LockWindowUpdate (USER.294)
1439 BOOL16 WINAPI LockWindowUpdate16( HWND16 hwnd )
1441 return LockWindowUpdate( WIN_Handle32(hwnd) );
1445 /**************************************************************************
1446 * ScrollWindowEx (USER.319)
1448 INT16 WINAPI ScrollWindowEx16( HWND16 hwnd, INT16 dx, INT16 dy,
1449 const RECT16 *rect, const RECT16 *clipRect,
1450 HRGN16 hrgnUpdate, LPRECT16 rcUpdate,
1451 UINT16 flags )
1453 RECT rect32, clipRect32, rcUpdate32;
1454 BOOL16 ret;
1456 if (rect)
1458 rect32.left = rect->left;
1459 rect32.top = rect->top;
1460 rect32.right = rect->right;
1461 rect32.bottom = rect->bottom;
1463 if (clipRect)
1465 clipRect32.left = clipRect->left;
1466 clipRect32.top = clipRect->top;
1467 clipRect32.right = clipRect->right;
1468 clipRect32.bottom = clipRect->bottom;
1470 ret = ScrollWindowEx( WIN_Handle32(hwnd), dx, dy, rect ? &rect32 : NULL,
1471 clipRect ? &clipRect32 : NULL, HRGN_32(hrgnUpdate),
1472 (rcUpdate) ? &rcUpdate32 : NULL, flags );
1473 if (rcUpdate)
1475 rcUpdate->left = rcUpdate32.left;
1476 rcUpdate->top = rcUpdate32.top;
1477 rcUpdate->right = rcUpdate32.right;
1478 rcUpdate->bottom = rcUpdate32.bottom;
1480 return ret;
1484 /**************************************************************************
1485 * FillWindow (USER.324)
1487 void WINAPI FillWindow16( HWND16 hwndParent, HWND16 hwnd, HDC16 hdc, HBRUSH16 hbrush )
1489 RECT rect;
1490 RECT16 rc16;
1491 GetClientRect( WIN_Handle32(hwnd), &rect );
1492 DPtoLP( HDC_32(hdc), (LPPOINT)&rect, 2 );
1493 rc16.left = rect.left;
1494 rc16.top = rect.top;
1495 rc16.right = rect.right;
1496 rc16.bottom = rect.bottom;
1497 PaintRect16( hwndParent, hwnd, hdc, hbrush, &rc16 );
1501 /**************************************************************************
1502 * PaintRect (USER.325)
1504 void WINAPI PaintRect16( HWND16 hwndParent, HWND16 hwnd, HDC16 hdc,
1505 HBRUSH16 hbrush, const RECT16 *rect)
1507 if (hbrush <= CTLCOLOR_STATIC)
1509 HWND parent = WIN_Handle32(hwndParent), hwnd32 = WIN_Handle32(hwnd);
1511 if (!parent) return;
1512 hbrush = SendMessageW( parent, WM_CTLCOLORMSGBOX + hbrush, hdc, (LPARAM)hwnd32 );
1513 if (!hbrush) hbrush = DefWindowProcW( parent, WM_CTLCOLORMSGBOX + hbrush,
1514 hdc, (LPARAM)hwnd32 );
1516 if (hbrush) FillRect16( hdc, rect, hbrush );
1520 /**************************************************************************
1521 * GetControlBrush (USER.326)
1523 HBRUSH16 WINAPI GetControlBrush16( HWND16 hwnd, HDC16 hdc, UINT16 ctlType )
1525 HBRUSH16 ret;
1526 HWND hwnd32 = WIN_Handle32(hwnd);
1527 HWND parent = GetParent( hwnd32 );
1529 if (!parent) parent = hwnd32;
1530 ret = SendMessageW( parent, WM_CTLCOLORMSGBOX + ctlType, hdc, (LPARAM)hwnd32 );
1531 if (!ret) ret = DefWindowProcW( parent, WM_CTLCOLORMSGBOX + ctlType,
1532 hdc, (LPARAM)hwnd32 );
1533 return ret;
1537 /**************************************************************************
1538 * GetDCEx (USER.359)
1540 HDC16 WINAPI GetDCEx16( HWND16 hwnd, HRGN16 hrgnClip, DWORD flags )
1542 return HDC_16(GetDCEx(WIN_Handle32(hwnd), HRGN_32(hrgnClip), flags));
1546 /**************************************************************************
1547 * GetWindowPlacement (USER.370)
1549 BOOL16 WINAPI GetWindowPlacement16( HWND16 hwnd, WINDOWPLACEMENT16 *wp16 )
1551 WINDOWPLACEMENT wpl;
1553 wpl.length = sizeof(wpl);
1554 if (!GetWindowPlacement( WIN_Handle32(hwnd), &wpl )) return FALSE;
1555 wp16->length = sizeof(*wp16);
1556 wp16->flags = wpl.flags;
1557 wp16->showCmd = wpl.showCmd;
1558 wp16->ptMinPosition.x = wpl.ptMinPosition.x;
1559 wp16->ptMinPosition.y = wpl.ptMinPosition.y;
1560 wp16->ptMaxPosition.x = wpl.ptMaxPosition.x;
1561 wp16->ptMaxPosition.y = wpl.ptMaxPosition.y;
1562 wp16->rcNormalPosition.left = wpl.rcNormalPosition.left;
1563 wp16->rcNormalPosition.top = wpl.rcNormalPosition.top;
1564 wp16->rcNormalPosition.right = wpl.rcNormalPosition.right;
1565 wp16->rcNormalPosition.bottom = wpl.rcNormalPosition.bottom;
1566 return TRUE;
1570 /**************************************************************************
1571 * SetWindowPlacement (USER.371)
1573 BOOL16 WINAPI SetWindowPlacement16( HWND16 hwnd, const WINDOWPLACEMENT16 *wp16 )
1575 WINDOWPLACEMENT wpl;
1577 if (!wp16) return FALSE;
1578 wpl.length = sizeof(wpl);
1579 wpl.flags = wp16->flags;
1580 wpl.showCmd = wp16->showCmd;
1581 wpl.ptMinPosition.x = wp16->ptMinPosition.x;
1582 wpl.ptMinPosition.y = wp16->ptMinPosition.y;
1583 wpl.ptMaxPosition.x = wp16->ptMaxPosition.x;
1584 wpl.ptMaxPosition.y = wp16->ptMaxPosition.y;
1585 wpl.rcNormalPosition.left = wp16->rcNormalPosition.left;
1586 wpl.rcNormalPosition.top = wp16->rcNormalPosition.top;
1587 wpl.rcNormalPosition.right = wp16->rcNormalPosition.right;
1588 wpl.rcNormalPosition.bottom = wp16->rcNormalPosition.bottom;
1589 return SetWindowPlacement( WIN_Handle32(hwnd), &wpl );
1593 /***********************************************************************
1594 * RegisterClassEx (USER.397)
1596 ATOM WINAPI RegisterClassEx16( const WNDCLASSEX16 *wc )
1598 struct class_entry *class;
1599 WNDCLASSEXA wc32;
1600 HINSTANCE16 inst;
1601 ATOM atom;
1603 inst = GetExePtr( wc->hInstance );
1604 if (!inst) inst = GetModuleHandle16( NULL );
1606 wc32.cbSize = sizeof(wc32);
1607 wc32.style = wc->style;
1608 wc32.lpfnWndProc = WINPROC_AllocProc16( wc->lpfnWndProc );
1609 wc32.cbClsExtra = wc->cbClsExtra;
1610 wc32.cbWndExtra = wc->cbWndExtra;
1611 wc32.hInstance = HINSTANCE_32(inst);
1612 wc32.hIcon = get_icon_32(wc->hIcon);
1613 wc32.hCursor = get_icon_32( wc->hCursor );
1614 wc32.hbrBackground = HBRUSH_32(wc->hbrBackground);
1615 wc32.lpszMenuName = MapSL(wc->lpszMenuName);
1616 wc32.lpszClassName = MapSL(wc->lpszClassName);
1617 wc32.hIconSm = get_icon_32(wc->hIconSm);
1618 atom = RegisterClassExA( &wc32 );
1619 if ((class = HeapAlloc( GetProcessHeap(), 0, sizeof(*class) )))
1621 class->atom = atom;
1622 class->inst = inst;
1623 list_add_tail( &class_list, &class->entry );
1625 return atom;
1629 /***********************************************************************
1630 * GetClassInfoEx (USER.398)
1632 * FIXME: this is just a guess, I have no idea if GetClassInfoEx() is the
1633 * same in Win16 as in Win32. --AJ
1635 BOOL16 WINAPI GetClassInfoEx16( HINSTANCE16 hInst16, SEGPTR name, WNDCLASSEX16 *wc )
1637 static HMODULE user32_module;
1638 WNDCLASSEXA wc32;
1639 HINSTANCE hInstance;
1640 BOOL ret;
1642 if (!user32_module) user32_module = GetModuleHandleA( "user32.dll" );
1643 if (hInst16 == GetModuleHandle16("user")) hInstance = user32_module;
1644 else hInstance = HINSTANCE_32(GetExePtr( hInst16 ));
1646 ret = GetClassInfoExA( hInstance, MapSL(name), &wc32 );
1648 if (ret)
1650 wc->lpfnWndProc = WINPROC_GetProc16( wc32.lpfnWndProc, FALSE );
1651 wc->style = wc32.style;
1652 wc->cbClsExtra = wc32.cbClsExtra;
1653 wc->cbWndExtra = wc32.cbWndExtra;
1654 wc->hInstance = (wc32.hInstance == user32_module) ? GetModuleHandle16("user") : HINSTANCE_16(wc32.hInstance);
1655 wc->hIcon = get_icon_16( wc32.hIcon );
1656 wc->hIconSm = get_icon_16( wc32.hIconSm );
1657 wc->hCursor = get_icon_16( wc32.hCursor );
1658 wc->hbrBackground = HBRUSH_16(wc32.hbrBackground);
1659 wc->lpszClassName = 0;
1660 wc->lpszMenuName = MapLS(wc32.lpszMenuName); /* FIXME: leak */
1662 return ret;
1666 /**************************************************************************
1667 * ChildWindowFromPointEx (USER.399)
1669 HWND16 WINAPI ChildWindowFromPointEx16( HWND16 hwndParent, POINT16 pt, UINT16 uFlags)
1671 POINT pt32;
1673 pt32.x = pt.x;
1674 pt32.y = pt.y;
1675 return HWND_16( ChildWindowFromPointEx( WIN_Handle32(hwndParent), pt32, uFlags ));
1679 /**************************************************************************
1680 * GetPriorityClipboardFormat (USER.402)
1682 INT16 WINAPI GetPriorityClipboardFormat16( UINT16 *list, INT16 count )
1684 int i;
1686 for (i = 0; i < count; i++)
1687 if (IsClipboardFormatAvailable( list[i] )) return list[i];
1688 return -1;
1692 /***********************************************************************
1693 * UnregisterClass (USER.403)
1695 BOOL16 WINAPI UnregisterClass16( LPCSTR className, HINSTANCE16 hInstance )
1697 ATOM atom;
1699 if (hInstance == GetModuleHandle16("user")) hInstance = 0;
1700 else hInstance = GetExePtr( hInstance );
1702 if ((atom = GlobalFindAtomA( className )))
1704 struct class_entry *class;
1705 LIST_FOR_EACH_ENTRY( class, &class_list, struct class_entry, entry )
1707 if (class->inst != hInstance) continue;
1708 if (class->atom != atom) continue;
1709 list_remove( &class->entry );
1710 HeapFree( GetProcessHeap(), 0, class );
1711 break;
1714 return UnregisterClassA( className, HINSTANCE_32(hInstance) );
1718 /***********************************************************************
1719 * GetClassInfo (USER.404)
1721 BOOL16 WINAPI GetClassInfo16( HINSTANCE16 hInst16, SEGPTR name, WNDCLASS16 *wc )
1723 WNDCLASSEX16 wcex;
1724 UINT16 ret = GetClassInfoEx16( hInst16, name, &wcex );
1726 if (ret)
1728 wc->style = wcex.style;
1729 wc->lpfnWndProc = wcex.lpfnWndProc;
1730 wc->cbClsExtra = wcex.cbClsExtra;
1731 wc->cbWndExtra = wcex.cbWndExtra;
1732 wc->hInstance = wcex.hInstance;
1733 wc->hIcon = wcex.hIcon;
1734 wc->hCursor = wcex.hCursor;
1735 wc->hbrBackground = wcex.hbrBackground;
1736 wc->lpszMenuName = wcex.lpszMenuName;
1737 wc->lpszClassName = wcex.lpszClassName;
1739 return ret;
1743 /**************************************************************************
1744 * TrackPopupMenu (USER.416)
1746 BOOL16 WINAPI TrackPopupMenu16( HMENU16 hMenu, UINT16 wFlags, INT16 x, INT16 y,
1747 INT16 nReserved, HWND16 hwnd, const RECT16 *lpRect )
1749 RECT r;
1750 if (lpRect)
1752 r.left = lpRect->left;
1753 r.top = lpRect->top;
1754 r.right = lpRect->right;
1755 r.bottom = lpRect->bottom;
1757 return TrackPopupMenu( HMENU_32(hMenu), wFlags, x, y, nReserved,
1758 WIN_Handle32(hwnd), lpRect ? &r : NULL );
1762 /**************************************************************************
1763 * FindWindowEx (USER.427)
1765 HWND16 WINAPI FindWindowEx16( HWND16 parent, HWND16 child, LPCSTR className, LPCSTR title )
1767 return HWND_16( FindWindowExA( WIN_Handle32(parent), WIN_Handle32(child),
1768 className, title ));
1772 /***********************************************************************
1773 * DefFrameProc (USER.445)
1775 LRESULT WINAPI DefFrameProc16( HWND16 hwnd, HWND16 hwndMDIClient,
1776 UINT16 message, WPARAM16 wParam, LPARAM lParam )
1778 switch (message)
1780 case WM_SETTEXT:
1781 lParam = (LPARAM)MapSL(lParam);
1782 /* fall through */
1783 case WM_COMMAND:
1784 case WM_NCACTIVATE:
1785 case WM_SETFOCUS:
1786 case WM_SIZE:
1787 return DefFrameProcA( WIN_Handle32(hwnd), WIN_Handle32(hwndMDIClient),
1788 message, wParam, lParam );
1790 case WM_NEXTMENU:
1792 MDINEXTMENU next_menu;
1793 DefFrameProcW( WIN_Handle32(hwnd), WIN_Handle32(hwndMDIClient),
1794 message, wParam, (LPARAM)&next_menu );
1795 return MAKELONG( HMENU_16(next_menu.hmenuNext), HWND_16(next_menu.hwndNext) );
1797 default:
1798 return DefWindowProc16(hwnd, message, wParam, lParam);
1803 /***********************************************************************
1804 * DefMDIChildProc (USER.447)
1806 LRESULT WINAPI DefMDIChildProc16( HWND16 hwnd, UINT16 message,
1807 WPARAM16 wParam, LPARAM lParam )
1809 switch (message)
1811 case WM_SETTEXT:
1812 return DefMDIChildProcA( WIN_Handle32(hwnd), message, wParam, (LPARAM)MapSL(lParam) );
1814 case WM_MENUCHAR:
1815 case WM_CLOSE:
1816 case WM_SETFOCUS:
1817 case WM_CHILDACTIVATE:
1818 case WM_SYSCOMMAND:
1819 case WM_SETVISIBLE:
1820 case WM_SIZE:
1821 case WM_SYSCHAR:
1822 return DefMDIChildProcW( WIN_Handle32(hwnd), message, wParam, lParam );
1824 case WM_GETMINMAXINFO:
1826 MINMAXINFO16 *mmi16 = MapSL(lParam);
1827 MINMAXINFO mmi;
1829 mmi.ptReserved.x = mmi16->ptReserved.x;
1830 mmi.ptReserved.y = mmi16->ptReserved.y;
1831 mmi.ptMaxSize.x = mmi16->ptMaxSize.x;
1832 mmi.ptMaxSize.y = mmi16->ptMaxSize.y;
1833 mmi.ptMaxPosition.x = mmi16->ptMaxPosition.x;
1834 mmi.ptMaxPosition.y = mmi16->ptMaxPosition.y;
1835 mmi.ptMinTrackSize.x = mmi16->ptMinTrackSize.x;
1836 mmi.ptMinTrackSize.y = mmi16->ptMinTrackSize.y;
1837 mmi.ptMaxTrackSize.x = mmi16->ptMaxTrackSize.x;
1838 mmi.ptMaxTrackSize.y = mmi16->ptMaxTrackSize.y;
1840 DefMDIChildProcW( WIN_Handle32(hwnd), message, wParam, (LPARAM)&mmi );
1842 mmi16->ptReserved.x = mmi.ptReserved.x;
1843 mmi16->ptReserved.y = mmi.ptReserved.y;
1844 mmi16->ptMaxSize.x = mmi.ptMaxSize.x;
1845 mmi16->ptMaxSize.y = mmi.ptMaxSize.y;
1846 mmi16->ptMaxPosition.x = mmi.ptMaxPosition.x;
1847 mmi16->ptMaxPosition.y = mmi.ptMaxPosition.y;
1848 mmi16->ptMinTrackSize.x = mmi.ptMinTrackSize.x;
1849 mmi16->ptMinTrackSize.y = mmi.ptMinTrackSize.y;
1850 mmi16->ptMaxTrackSize.x = mmi.ptMaxTrackSize.x;
1851 mmi16->ptMaxTrackSize.y = mmi.ptMaxTrackSize.y;
1852 return 0;
1854 case WM_NEXTMENU:
1856 MDINEXTMENU next_menu;
1857 DefMDIChildProcW( WIN_Handle32(hwnd), message, wParam, (LPARAM)&next_menu );
1858 return MAKELONG( HMENU_16(next_menu.hmenuNext), HWND_16(next_menu.hwndNext) );
1860 default:
1861 return DefWindowProc16(hwnd, message, wParam, lParam);
1866 /**************************************************************************
1867 * DrawAnimatedRects (USER.448)
1869 BOOL16 WINAPI DrawAnimatedRects16( HWND16 hwnd, INT16 idAni,
1870 const RECT16* lprcFrom, const RECT16* lprcTo )
1872 RECT rcFrom32, rcTo32;
1873 rcFrom32.left = lprcFrom->left;
1874 rcFrom32.top = lprcFrom->top;
1875 rcFrom32.right = lprcFrom->right;
1876 rcFrom32.bottom = lprcFrom->bottom;
1877 rcTo32.left = lprcTo->left;
1878 rcTo32.top = lprcTo->top;
1879 rcTo32.right = lprcTo->right;
1880 rcTo32.bottom = lprcTo->bottom;
1881 return DrawAnimatedRects( WIN_Handle32(hwnd), idAni, &rcFrom32, &rcTo32 );
1885 /***********************************************************************
1886 * CreateWindowEx (USER.452)
1888 HWND16 WINAPI CreateWindowEx16( DWORD exStyle, LPCSTR className,
1889 LPCSTR windowName, DWORD style, INT16 x,
1890 INT16 y, INT16 width, INT16 height,
1891 HWND16 parent, HMENU16 menu,
1892 HINSTANCE16 instance, LPVOID data )
1894 CREATESTRUCTA cs;
1895 char buffer[256];
1896 HWND hwnd;
1898 /* Fix the coordinates */
1900 cs.x = (x == CW_USEDEFAULT16) ? CW_USEDEFAULT : (INT)x;
1901 cs.y = (y == CW_USEDEFAULT16) ? CW_USEDEFAULT : (INT)y;
1902 cs.cx = (width == CW_USEDEFAULT16) ? CW_USEDEFAULT : (INT)width;
1903 cs.cy = (height == CW_USEDEFAULT16) ? CW_USEDEFAULT : (INT)height;
1905 /* Create the window */
1907 cs.lpCreateParams = data;
1908 cs.hInstance = HINSTANCE_32(instance);
1909 cs.hMenu = HMENU_32(menu);
1910 cs.hwndParent = WIN_Handle32( parent );
1911 cs.style = style;
1912 cs.lpszName = windowName;
1913 cs.lpszClass = className;
1914 cs.dwExStyle = exStyle;
1916 /* load the menu */
1917 if (!menu && (style & (WS_CHILD | WS_POPUP)) != WS_CHILD)
1919 WNDCLASSA class;
1920 HINSTANCE16 module = GetExePtr( instance );
1922 if (GetClassInfoA( HINSTANCE_32(module), className, &class ))
1923 cs.hMenu = HMENU_32( LoadMenu16( module, class.lpszMenuName ));
1926 if (!IS_INTRESOURCE(className))
1928 WCHAR bufferW[256];
1930 if (!MultiByteToWideChar( CP_ACP, 0, className, -1, bufferW, ARRAY_SIZE(bufferW)))
1931 return 0;
1932 hwnd = create_window16( (CREATESTRUCTW *)&cs, bufferW, HINSTANCE_32(instance), FALSE );
1934 else
1936 if (!GlobalGetAtomNameA( LOWORD(className), buffer, sizeof(buffer) )) return 0;
1937 cs.lpszClass = buffer;
1938 hwnd = create_window16( (CREATESTRUCTW *)&cs, (LPCWSTR)className, HINSTANCE_32(instance), FALSE );
1940 return HWND_16( hwnd );
1944 /***********************************************************************
1945 * GetInternalWindowPos (USER.460)
1947 UINT16 WINAPI GetInternalWindowPos16( HWND16 hwnd, LPRECT16 rectWnd, LPPOINT16 ptIcon )
1949 WINDOWPLACEMENT16 wndpl;
1951 if (!GetWindowPlacement16( hwnd, &wndpl )) return 0;
1952 if (rectWnd) *rectWnd = wndpl.rcNormalPosition;
1953 if (ptIcon) *ptIcon = wndpl.ptMinPosition;
1954 return wndpl.showCmd;
1958 /**************************************************************************
1959 * SetInternalWindowPos (USER.461)
1961 void WINAPI SetInternalWindowPos16( HWND16 hwnd, UINT16 showCmd, LPRECT16 rect, LPPOINT16 pt )
1963 RECT rc32;
1964 POINT pt32;
1966 if (rect)
1968 rc32.left = rect->left;
1969 rc32.top = rect->top;
1970 rc32.right = rect->right;
1971 rc32.bottom = rect->bottom;
1973 if (pt)
1975 pt32.x = pt->x;
1976 pt32.y = pt->y;
1978 SetInternalWindowPos( WIN_Handle32(hwnd), showCmd,
1979 rect ? &rc32 : NULL, pt ? &pt32 : NULL );
1983 /**************************************************************************
1984 * CalcChildScroll (USER.462)
1986 void WINAPI CalcChildScroll16( HWND16 hwnd, WORD scroll )
1988 CalcChildScroll( WIN_Handle32(hwnd), scroll );
1992 /**************************************************************************
1993 * ScrollChildren (USER.463)
1995 void WINAPI ScrollChildren16(HWND16 hwnd, UINT16 uMsg, WPARAM16 wParam, LPARAM lParam)
1997 ScrollChildren( WIN_Handle32(hwnd), uMsg, wParam, lParam );
2001 /**************************************************************************
2002 * DragDetect (USER.465)
2004 BOOL16 WINAPI DragDetect16( HWND16 hwnd, POINT16 pt )
2006 POINT pt32;
2008 pt32.x = pt.x;
2009 pt32.y = pt.y;
2010 return DragDetect( WIN_Handle32(hwnd), pt32 );
2014 /**************************************************************************
2015 * SetScrollInfo (USER.475)
2017 INT16 WINAPI SetScrollInfo16( HWND16 hwnd, INT16 nBar, const SCROLLINFO *info, BOOL16 redraw )
2019 return SetScrollInfo( WIN_Handle32(hwnd), nBar, info, redraw );
2023 /**************************************************************************
2024 * GetScrollInfo (USER.476)
2026 BOOL16 WINAPI GetScrollInfo16( HWND16 hwnd, INT16 nBar, LPSCROLLINFO info )
2028 return GetScrollInfo( WIN_Handle32(hwnd), nBar, info );
2032 /**************************************************************************
2033 * EnableScrollBar (USER.482)
2035 BOOL16 WINAPI EnableScrollBar16( HWND16 hwnd, INT16 nBar, UINT16 flags )
2037 return EnableScrollBar( WIN_Handle32(hwnd), nBar, flags );
2041 /**************************************************************************
2042 * GetShellWindow (USER.600)
2044 HWND16 WINAPI GetShellWindow16(void)
2046 return HWND_16( GetShellWindow() );
2050 /**************************************************************************
2051 * GetForegroundWindow (USER.608)
2053 HWND16 WINAPI GetForegroundWindow16(void)
2055 return HWND_16( GetForegroundWindow() );
2059 /**************************************************************************
2060 * SetForegroundWindow (USER.609)
2062 BOOL16 WINAPI SetForegroundWindow16( HWND16 hwnd )
2064 return SetForegroundWindow( WIN_Handle32(hwnd) );
2068 /**************************************************************************
2069 * DrawCaptionTemp (USER.657)
2071 BOOL16 WINAPI DrawCaptionTemp16( HWND16 hwnd, HDC16 hdc, const RECT16 *rect,
2072 HFONT16 hFont, HICON16 hIcon, LPCSTR str, UINT16 uFlags )
2074 RECT rect32;
2076 if (rect)
2078 rect32.left = rect->left;
2079 rect32.top = rect->top;
2080 rect32.right = rect->right;
2081 rect32.bottom = rect->bottom;
2083 return DrawCaptionTempA( WIN_Handle32(hwnd), HDC_32(hdc),
2084 rect ? &rect32 : NULL, HFONT_32(hFont),
2085 get_icon_32(hIcon), str, uFlags & 0x1f );
2089 /**************************************************************************
2090 * DrawCaption (USER.660)
2092 BOOL16 WINAPI DrawCaption16( HWND16 hwnd, HDC16 hdc, const RECT16 *rect, UINT16 flags )
2094 RECT rect32;
2096 if (rect)
2098 rect32.left = rect->left;
2099 rect32.top = rect->top;
2100 rect32.right = rect->right;
2101 rect32.bottom = rect->bottom;
2103 return DrawCaption(WIN_Handle32(hwnd), HDC_32(hdc), rect ? &rect32 : NULL, flags);
2107 /**************************************************************************
2108 * GetMenuItemRect (USER.665)
2110 BOOL16 WINAPI GetMenuItemRect16( HWND16 hwnd, HMENU16 hMenu, UINT16 uItem,
2111 LPRECT16 rect)
2113 RECT r32;
2114 BOOL res;
2115 if (!rect) return FALSE;
2116 res = GetMenuItemRect( WIN_Handle32(hwnd), HMENU_32(hMenu), uItem, &r32 );
2117 rect->left = r32.left;
2118 rect->top = r32.top;
2119 rect->right = r32.right;
2120 rect->bottom = r32.bottom;
2121 return res;
2125 /**************************************************************************
2126 * SetWindowRgn (USER.668)
2128 INT16 WINAPI SetWindowRgn16( HWND16 hwnd, HRGN16 hrgn, BOOL16 redraw )
2130 return SetWindowRgn( WIN_Handle32(hwnd), HRGN_32(hrgn), redraw );
2134 /**************************************************************************
2135 * MessageBoxIndirect (USER.827)
2137 INT16 WINAPI MessageBoxIndirect16( LPMSGBOXPARAMS16 msgbox )
2139 char caption[256], text[256];
2140 MSGBOXPARAMSA msgbox32;
2142 msgbox32.cbSize = msgbox->cbSize;
2143 msgbox32.hwndOwner = WIN_Handle32( msgbox->hwndOwner );
2144 msgbox32.hInstance = 0;
2145 msgbox32.dwStyle = msgbox->dwStyle;
2146 msgbox32.lpszIcon = NULL;
2147 msgbox32.dwContextHelpId = msgbox->dwContextHelpId;
2148 msgbox32.lpfnMsgBoxCallback = msgbox->lpfnMsgBoxCallback;
2149 msgbox32.dwLanguageId = msgbox->dwLanguageId;
2151 if (!HIWORD(msgbox->lpszCaption))
2153 LoadString16( msgbox->hInstance, LOWORD(msgbox->lpszCaption), caption, sizeof(caption) );
2154 msgbox32.lpszCaption = caption;
2156 else msgbox32.lpszCaption = MapSL(msgbox->lpszCaption);
2158 if (!HIWORD(msgbox->lpszText))
2160 LoadString16( msgbox->hInstance, LOWORD(msgbox->lpszText), text, sizeof(text) );
2161 msgbox32.lpszText = text;
2163 else msgbox32.lpszText = MapSL(msgbox->lpszText);
2165 if ((msgbox->dwStyle & MB_ICONMASK) == MB_USERICON)
2167 FIXME( "user icon %s not supported\n", debugstr_a( MapSL(msgbox->lpszIcon) ));
2168 msgbox32.dwStyle &= ~MB_USERICON;
2171 return MessageBoxIndirectA( &msgbox32 );