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"
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
;
46 static struct list class_list
= LIST_INIT( class_list
);
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
;
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
);
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
;
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 /**************************************************************************
92 INT16 WINAPI
MessageBox16( HWND16 hwnd
, LPCSTR text
, LPCSTR title
, UINT16 type
)
94 return MessageBoxA( WIN_Handle32(hwnd
), text
, title
, type
);
98 /***********************************************************************
101 UINT16 WINAPI
SetTimer16( HWND16 hwnd
, UINT16 id
, UINT16 timeout
, TIMERPROC16 proc
)
103 TIMERPROC proc32
= (TIMERPROC
)WINPROC_AllocProc16( (WNDPROC16
)proc
);
104 return SetTimer( WIN_Handle32(hwnd
), id
, timeout
, proc32
);
108 /***********************************************************************
109 * SetSystemTimer (USER.11)
111 UINT16 WINAPI
SetSystemTimer16( HWND16 hwnd
, UINT16 id
, UINT16 timeout
, TIMERPROC16 proc
)
113 TIMERPROC proc32
= (TIMERPROC
)WINPROC_AllocProc16( (WNDPROC16
)proc
);
114 return SetSystemTimer( WIN_Handle32(hwnd
), id
, timeout
, proc32
);
118 /**************************************************************************
119 * KillTimer (USER.12)
121 BOOL16 WINAPI
KillTimer16( HWND16 hwnd
, UINT16 id
)
123 return KillTimer( WIN_Handle32(hwnd
), id
);
127 /**************************************************************************
128 * SetCapture (USER.18)
130 HWND16 WINAPI
SetCapture16( HWND16 hwnd
)
132 return HWND_16( SetCapture( WIN_Handle32(hwnd
) ));
136 /**************************************************************************
137 * ReleaseCapture (USER.19)
139 BOOL16 WINAPI
ReleaseCapture16(void)
141 return ReleaseCapture();
145 /**************************************************************************
148 HWND16 WINAPI
SetFocus16( HWND16 hwnd
)
150 return HWND_16( SetFocus( WIN_Handle32(hwnd
) ));
154 /**************************************************************************
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 /**************************************************************************
175 HANDLE16 WINAPI
GetProp16( HWND16 hwnd
, LPCSTR str
)
177 return HANDLE_16(GetPropA( WIN_Handle32(hwnd
), str
));
181 /**************************************************************************
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
;
200 if (!(list
= HeapAlloc( GetProcessHeap(), 0, total
* sizeof(*list
) ))) break;
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
;
210 if (count
&& count
<= total
)
212 char string
[ATOM_BUFFER_SIZE
];
213 SEGPTR segptr
= MapLS( string
);
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;
223 args
[2] = SELECTOROF(segptr
);
224 args
[1] = OFFSETOF(segptr
);
225 args
[0] = LOWORD(list
[i
].data
);
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;
238 HeapFree( GetProcessHeap(), 0, list
);
241 HeapFree( GetProcessHeap(), 0, list
);
242 total
= count
; /* restart with larger buffer */
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
)
275 return HWND_16( WindowFromPoint( pt32
) );
279 /**************************************************************************
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
)
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
)
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
)
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
;
383 /***********************************************************************
386 BOOL16 WINAPI
EndPaint16( HWND16 hwnd
, const PAINTSTRUCT16
* lps
)
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 /**************************************************************************
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 /**************************************************************************
456 BOOL16 WINAPI
IsWindow16( HWND16 hwnd
)
458 STACK16FRAME
*frame
= MapSL( (SEGPTR
)NtCurrentTeb()->WOW32Reserved
);
459 frame
->es
= USER_HeapSel
;
460 /* don't use WIN_Handle32 here, we don't care about the full handle */
461 return IsWindow( HWND_32(hwnd
) );
465 /**************************************************************************
468 BOOL16 WINAPI
IsChild16( HWND16 parent
, HWND16 child
)
470 return IsChild( WIN_Handle32(parent
), WIN_Handle32(child
) );
474 /**************************************************************************
475 * IsWindowVisible (USER.49)
477 BOOL16 WINAPI
IsWindowVisible16( HWND16 hwnd
)
479 return IsWindowVisible( WIN_Handle32(hwnd
) );
483 /**************************************************************************
484 * FindWindow (USER.50)
486 HWND16 WINAPI
FindWindow16( LPCSTR className
, LPCSTR title
)
488 return HWND_16( FindWindowA( className
, title
));
492 /**************************************************************************
493 * DestroyWindow (USER.53)
495 BOOL16 WINAPI
DestroyWindow16( HWND16 hwnd
)
497 return DestroyWindow( WIN_Handle32(hwnd
) );
501 /*******************************************************************
502 * EnumWindows (USER.54)
504 BOOL16 WINAPI
EnumWindows16( WNDENUMPROC16 func
, LPARAM lParam
)
506 struct wnd_enum_info info
;
510 return EnumWindows( wnd_enum_callback
, (LPARAM
)&info
);
514 /**********************************************************************
515 * EnumChildWindows (USER.55)
517 BOOL16 WINAPI
EnumChildWindows16( HWND16 parent
, WNDENUMPROC16 func
, LPARAM lParam
)
519 struct wnd_enum_info info
;
523 return EnumChildWindows( WIN_Handle32(parent
), wnd_enum_callback
, (LPARAM
)&info
);
527 /**************************************************************************
528 * MoveWindow (USER.56)
530 BOOL16 WINAPI
MoveWindow16( HWND16 hwnd
, INT16 x
, INT16 y
, INT16 cx
, INT16 cy
, BOOL16 repaint
)
532 return MoveWindow( WIN_Handle32(hwnd
), x
, y
, cx
, cy
, repaint
);
536 /***********************************************************************
537 * RegisterClass (USER.57)
539 ATOM WINAPI
RegisterClass16( const WNDCLASS16
*wc
)
543 wcex
.cbSize
= sizeof(wcex
);
544 wcex
.style
= wc
->style
;
545 wcex
.lpfnWndProc
= wc
->lpfnWndProc
;
546 wcex
.cbClsExtra
= wc
->cbClsExtra
;
547 wcex
.cbWndExtra
= wc
->cbWndExtra
;
548 wcex
.hInstance
= wc
->hInstance
;
549 wcex
.hIcon
= wc
->hIcon
;
550 wcex
.hCursor
= wc
->hCursor
;
551 wcex
.hbrBackground
= wc
->hbrBackground
;
552 wcex
.lpszMenuName
= wc
->lpszMenuName
;
553 wcex
.lpszClassName
= wc
->lpszClassName
;
555 return RegisterClassEx16( &wcex
);
559 /**************************************************************************
560 * GetClassName (USER.58)
562 INT16 WINAPI
GetClassName16( HWND16 hwnd
, LPSTR buffer
, INT16 count
)
564 return GetClassNameA( WIN_Handle32(hwnd
), buffer
, count
);
568 /**************************************************************************
569 * SetActiveWindow (USER.59)
571 HWND16 WINAPI
SetActiveWindow16( HWND16 hwnd
)
573 return HWND_16( SetActiveWindow( WIN_Handle32(hwnd
) ));
577 /**************************************************************************
578 * GetActiveWindow (USER.60)
580 HWND16 WINAPI
GetActiveWindow16(void)
582 return HWND_16( GetActiveWindow() );
586 /**************************************************************************
587 * ScrollWindow (USER.61)
589 void WINAPI
ScrollWindow16( HWND16 hwnd
, INT16 dx
, INT16 dy
, const RECT16
*rect
,
590 const RECT16
*clipRect
)
592 RECT rect32
, clipRect32
;
596 rect32
.left
= rect
->left
;
597 rect32
.top
= rect
->top
;
598 rect32
.right
= rect
->right
;
599 rect32
.bottom
= rect
->bottom
;
603 clipRect32
.left
= clipRect
->left
;
604 clipRect32
.top
= clipRect
->top
;
605 clipRect32
.right
= clipRect
->right
;
606 clipRect32
.bottom
= clipRect
->bottom
;
608 ScrollWindow( WIN_Handle32(hwnd
), dx
, dy
, rect
? &rect32
: NULL
,
609 clipRect
? &clipRect32
: NULL
);
613 /**************************************************************************
614 * SetScrollPos (USER.62)
616 INT16 WINAPI
SetScrollPos16( HWND16 hwnd
, INT16 nBar
, INT16 nPos
, BOOL16 redraw
)
618 return SetScrollPos( WIN_Handle32(hwnd
), nBar
, nPos
, redraw
);
622 /**************************************************************************
623 * GetScrollPos (USER.63)
625 INT16 WINAPI
GetScrollPos16( HWND16 hwnd
, INT16 nBar
)
627 return GetScrollPos( WIN_Handle32(hwnd
), nBar
);
631 /**************************************************************************
632 * SetScrollRange (USER.64)
634 void WINAPI
SetScrollRange16( HWND16 hwnd
, INT16 nBar
, INT16 MinVal
, INT16 MaxVal
, BOOL16 redraw
)
636 /* Invalid range -> range is set to (0,0) */
637 if ((INT
)MaxVal
- (INT
)MinVal
> 0x7fff) MinVal
= MaxVal
= 0;
638 SetScrollRange( WIN_Handle32(hwnd
), nBar
, MinVal
, MaxVal
, redraw
);
642 /**************************************************************************
643 * GetScrollRange (USER.65)
645 BOOL16 WINAPI
GetScrollRange16( HWND16 hwnd
, INT16 nBar
, LPINT16 lpMin
, LPINT16 lpMax
)
648 BOOL ret
= GetScrollRange( WIN_Handle32(hwnd
), nBar
, &min
, &max
);
649 if (lpMin
) *lpMin
= min
;
650 if (lpMax
) *lpMax
= max
;
655 /**************************************************************************
658 HDC16 WINAPI
GetDC16( HWND16 hwnd
)
660 return HDC_16(GetDC( WIN_Handle32(hwnd
) ));
664 /**************************************************************************
665 * GetWindowDC (USER.67)
667 HDC16 WINAPI
GetWindowDC16( HWND16 hwnd
)
669 return GetDCEx16( hwnd
, 0, DCX_USESTYLE
| DCX_WINDOW
);
673 /**************************************************************************
674 * ReleaseDC (USER.68)
676 INT16 WINAPI
ReleaseDC16( HWND16 hwnd
, HDC16 hdc
)
678 return (INT16
)ReleaseDC( WIN_Handle32(hwnd
), HDC_32(hdc
) );
682 /**************************************************************************
683 * FlashWindow (USER.105)
685 BOOL16 WINAPI
FlashWindow16( HWND16 hwnd
, BOOL16 bInvert
)
687 return FlashWindow( WIN_Handle32(hwnd
), bInvert
);
691 /**************************************************************************
692 * WindowFromDC (USER.117)
694 HWND16 WINAPI
WindowFromDC16( HDC16 hDC
)
696 return HWND_16( WindowFromDC( HDC_32(hDC
) ) );
700 /**************************************************************************
701 * UpdateWindow (USER.124)
703 void WINAPI
UpdateWindow16( HWND16 hwnd
)
705 RedrawWindow16( hwnd
, NULL
, 0, RDW_UPDATENOW
| RDW_ALLCHILDREN
);
709 /**************************************************************************
710 * InvalidateRect (USER.125)
712 void WINAPI
InvalidateRect16( HWND16 hwnd
, const RECT16
*rect
, BOOL16 erase
)
714 RedrawWindow16( hwnd
, rect
, 0, RDW_INVALIDATE
| (erase
? RDW_ERASE
: 0) );
718 /**************************************************************************
719 * InvalidateRgn (USER.126)
721 void WINAPI
InvalidateRgn16( HWND16 hwnd
, HRGN16 hrgn
, BOOL16 erase
)
723 RedrawWindow16( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| (erase
? RDW_ERASE
: 0) );
727 /**************************************************************************
728 * ValidateRect (USER.127)
730 void WINAPI
ValidateRect16( HWND16 hwnd
, const RECT16
*rect
)
732 RedrawWindow16( hwnd
, rect
, 0, RDW_VALIDATE
| RDW_NOCHILDREN
);
736 /**************************************************************************
737 * ValidateRgn (USER.128)
739 void WINAPI
ValidateRgn16( HWND16 hwnd
, HRGN16 hrgn
)
741 RedrawWindow16( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_NOCHILDREN
);
745 /**************************************************************************
746 * GetClassWord (USER.129)
748 WORD WINAPI
GetClassWord16( HWND16 hwnd
, INT16 offset
)
750 return GetClassWord( WIN_Handle32(hwnd
), offset
);
754 /**************************************************************************
755 * SetClassWord (USER.130)
757 WORD WINAPI
SetClassWord16( HWND16 hwnd
, INT16 offset
, WORD newval
)
759 return SetClassWord( WIN_Handle32(hwnd
), offset
, newval
);
763 /***********************************************************************
764 * GetClassLong (USER.131)
766 LONG WINAPI
GetClassLong16( HWND16 hwnd16
, INT16 offset
)
768 LONG_PTR ret
= GetClassLongA( WIN_Handle32(hwnd16
), offset
);
773 return (LONG_PTR
)WINPROC_GetProc16( (WNDPROC
)ret
, FALSE
);
775 return MapLS( (void *)ret
); /* leak */
782 /***********************************************************************
783 * SetClassLong (USER.132)
785 LONG WINAPI
SetClassLong16( HWND16 hwnd16
, INT16 offset
, LONG newval
)
791 WNDPROC new_proc
= WINPROC_AllocProc16( (WNDPROC16
)newval
);
792 WNDPROC old_proc
= (WNDPROC
)SetClassLongA( WIN_Handle32(hwnd16
), offset
, (LONG_PTR
)new_proc
);
793 return (LONG
)WINPROC_GetProc16( old_proc
, FALSE
);
796 newval
= (LONG
)MapSL( newval
);
799 return SetClassLongA( WIN_Handle32(hwnd16
), offset
, newval
);
804 /**************************************************************************
805 * GetWindowWord (USER.133)
807 WORD WINAPI
GetWindowWord16( HWND16 hwnd
, INT16 offset
)
809 return GetWindowWord( WIN_Handle32(hwnd
), offset
);
813 /**************************************************************************
814 * SetWindowWord (USER.134)
816 WORD WINAPI
SetWindowWord16( HWND16 hwnd
, INT16 offset
, WORD newval
)
818 return SetWindowWord( WIN_Handle32(hwnd
), offset
, newval
);
822 /**********************************************************************
823 * GetWindowLong (USER.135)
825 LONG WINAPI
GetWindowLong16( HWND16 hwnd16
, INT16 offset
)
827 HWND hwnd
= WIN_Handle32( hwnd16
);
829 BOOL is_winproc
= (offset
== GWLP_WNDPROC
);
833 int cbWndExtra
= GetClassLongA( hwnd
, GCL_CBWNDEXTRA
);
835 if (offset
> (int)(cbWndExtra
- sizeof(LONG
)))
838 * Some programs try to access last element from 16 bit
839 * code using illegal offset value. Hopefully this is
840 * what those programs really expect.
842 if (cbWndExtra
>= 4 && offset
== cbWndExtra
- sizeof(WORD
))
844 offset
= cbWndExtra
- sizeof(LONG
);
848 SetLastError( ERROR_INVALID_INDEX
);
852 else if (offset
== DWLP_DLGPROC
)
853 is_winproc
= (wow_handlers32
.get_dialog_info( hwnd
, FALSE
) != NULL
);
855 retvalue
= GetWindowLongA( hwnd
, offset
);
856 if (is_winproc
) retvalue
= (LONG_PTR
)WINPROC_GetProc16( (WNDPROC
)retvalue
, FALSE
);
861 /**********************************************************************
862 * SetWindowLong (USER.136)
864 LONG WINAPI
SetWindowLong16( HWND16 hwnd16
, INT16 offset
, LONG newval
)
866 HWND hwnd
= WIN_Handle32( hwnd16
);
867 BOOL is_winproc
= (offset
== GWLP_WNDPROC
);
869 if (offset
== DWLP_DLGPROC
)
870 is_winproc
= (wow_handlers32
.get_dialog_info( hwnd
, FALSE
) != NULL
);
874 WNDPROC new_proc
= WINPROC_AllocProc16( (WNDPROC16
)newval
);
875 WNDPROC old_proc
= (WNDPROC
)SetWindowLongPtrA( hwnd
, offset
, (LONG_PTR
)new_proc
);
876 return (LONG
)WINPROC_GetProc16( old_proc
, FALSE
);
878 else return SetWindowLongA( hwnd
, offset
, newval
);
882 /**************************************************************************
883 * OpenClipboard (USER.137)
885 BOOL16 WINAPI
OpenClipboard16( HWND16 hwnd
)
887 return OpenClipboard( WIN_Handle32(hwnd
) );
891 /**************************************************************************
892 * GetClipboardOwner (USER.140)
894 HWND16 WINAPI
GetClipboardOwner16(void)
896 return HWND_16( GetClipboardOwner() );
900 /**************************************************************************
901 * SetClipboardViewer (USER.147)
903 HWND16 WINAPI
SetClipboardViewer16( HWND16 hwnd
)
905 return HWND_16( SetClipboardViewer( WIN_Handle32(hwnd
) ));
909 /**************************************************************************
910 * GetClipboardViewer (USER.148)
912 HWND16 WINAPI
GetClipboardViewer16(void)
914 return HWND_16( GetClipboardViewer() );
918 /**************************************************************************
919 * ChangeClipboardChain (USER.149)
921 BOOL16 WINAPI
ChangeClipboardChain16(HWND16 hwnd
, HWND16 hwndNext
)
923 return ChangeClipboardChain( WIN_Handle32(hwnd
), WIN_Handle32(hwndNext
) );
927 /**************************************************************************
928 * GetSystemMenu (USER.156)
930 HMENU16 WINAPI
GetSystemMenu16( HWND16 hwnd
, BOOL16 revert
)
932 return HMENU_16(GetSystemMenu( WIN_Handle32(hwnd
), revert
));
936 /**************************************************************************
939 HMENU16 WINAPI
GetMenu16( HWND16 hwnd
)
941 return HMENU_16(GetMenu( WIN_Handle32(hwnd
) ));
945 /**************************************************************************
948 BOOL16 WINAPI
SetMenu16( HWND16 hwnd
, HMENU16 hMenu
)
950 return SetMenu( WIN_Handle32(hwnd
), HMENU_32(hMenu
) );
954 /**************************************************************************
955 * DrawMenuBar (USER.160)
957 void WINAPI
DrawMenuBar16( HWND16 hwnd
)
959 DrawMenuBar( WIN_Handle32(hwnd
) );
963 /**************************************************************************
964 * HiliteMenuItem (USER.162)
966 BOOL16 WINAPI
HiliteMenuItem16( HWND16 hwnd
, HMENU16 hMenu
, UINT16 id
, UINT16 wHilite
)
968 return HiliteMenuItem( WIN_Handle32(hwnd
), HMENU_32(hMenu
), id
, wHilite
);
972 /**************************************************************************
973 * CreateCaret (USER.163)
975 void WINAPI
CreateCaret16( HWND16 hwnd
, HBITMAP16 bitmap
, INT16 width
, INT16 height
)
977 CreateCaret( WIN_Handle32(hwnd
), HBITMAP_32(bitmap
), width
, height
);
981 /*****************************************************************
982 * DestroyCaret (USER.164)
984 void WINAPI
DestroyCaret16(void)
990 /*****************************************************************
991 * SetCaretPos (USER.165)
993 void WINAPI
SetCaretPos16( INT16 x
, INT16 y
)
999 /**************************************************************************
1000 * HideCaret (USER.166)
1002 void WINAPI
HideCaret16( HWND16 hwnd
)
1004 HideCaret( WIN_Handle32(hwnd
) );
1008 /**************************************************************************
1009 * ShowCaret (USER.167)
1011 void WINAPI
ShowCaret16( HWND16 hwnd
)
1013 ShowCaret( WIN_Handle32(hwnd
) );
1017 /*****************************************************************
1018 * SetCaretBlinkTime (USER.168)
1020 void WINAPI
SetCaretBlinkTime16( UINT16 msecs
)
1022 SetCaretBlinkTime( msecs
);
1026 /*****************************************************************
1027 * GetCaretBlinkTime (USER.169)
1029 UINT16 WINAPI
GetCaretBlinkTime16(void)
1031 return GetCaretBlinkTime();
1035 /**************************************************************************
1036 * ArrangeIconicWindows (USER.170)
1038 UINT16 WINAPI
ArrangeIconicWindows16( HWND16 parent
)
1040 return ArrangeIconicWindows( WIN_Handle32(parent
) );
1044 /**************************************************************************
1045 * SwitchToThisWindow (USER.172)
1047 void WINAPI
SwitchToThisWindow16( HWND16 hwnd
, BOOL16 restore
)
1049 SwitchToThisWindow( WIN_Handle32(hwnd
), restore
);
1053 /**************************************************************************
1054 * KillSystemTimer (USER.182)
1056 BOOL16 WINAPI
KillSystemTimer16( HWND16 hwnd
, UINT16 id
)
1058 return KillSystemTimer( WIN_Handle32(hwnd
), id
);
1062 /*****************************************************************
1063 * GetCaretPos (USER.183)
1065 void WINAPI
GetCaretPos16( LPPOINT16 pt16
)
1068 if (GetCaretPos( &pt
))
1076 /**************************************************************************
1077 * SetSysModalWindow (USER.188)
1079 HWND16 WINAPI
SetSysModalWindow16( HWND16 hwnd
)
1081 HWND16 old
= hwndSysModal
;
1082 hwndSysModal
= hwnd
;
1087 /**************************************************************************
1088 * GetSysModalWindow (USER.189)
1090 HWND16 WINAPI
GetSysModalWindow16(void)
1092 return hwndSysModal
;
1096 /**************************************************************************
1097 * GetUpdateRect (USER.190)
1099 BOOL16 WINAPI
GetUpdateRect16( HWND16 hwnd
, LPRECT16 rect
, BOOL16 erase
)
1104 if (!rect
) return GetUpdateRect( WIN_Handle32(hwnd
), NULL
, erase
);
1105 ret
= GetUpdateRect( WIN_Handle32(hwnd
), &r
, erase
);
1106 rect
->left
= r
.left
;
1108 rect
->right
= r
.right
;
1109 rect
->bottom
= r
.bottom
;
1114 /**************************************************************************
1115 * ChildWindowFromPoint (USER.191)
1117 HWND16 WINAPI
ChildWindowFromPoint16( HWND16 hwndParent
, POINT16 pt
)
1123 return HWND_16( ChildWindowFromPoint( WIN_Handle32(hwndParent
), pt32
));
1127 /***********************************************************************
1128 * CascadeChildWindows (USER.198)
1130 void WINAPI
CascadeChildWindows16( HWND16 parent
, WORD action
)
1132 CascadeWindows( WIN_Handle32(parent
), action
, NULL
, 0, NULL
);
1136 /***********************************************************************
1137 * TileChildWindows (USER.199)
1139 void WINAPI
TileChildWindows16( HWND16 parent
, WORD action
)
1141 TileWindows( WIN_Handle32(parent
), action
, NULL
, 0, NULL
);
1145 /***********************************************************************
1146 * GetWindowTask (USER.224)
1148 HTASK16 WINAPI
GetWindowTask16( HWND16 hwnd
)
1150 DWORD tid
= GetWindowThreadProcessId( HWND_32(hwnd
), NULL
);
1152 return HTASK_16(tid
);
1155 /**********************************************************************
1156 * EnumTaskWindows (USER.225)
1158 BOOL16 WINAPI
EnumTaskWindows16( HTASK16 hTask
, WNDENUMPROC16 func
, LPARAM lParam
)
1160 struct wnd_enum_info info
;
1161 DWORD tid
= HTASK_32( hTask
);
1163 if (!tid
) return FALSE
;
1165 info
.param
= lParam
;
1166 return EnumThreadWindows( tid
, wnd_enum_callback
, (LPARAM
)&info
);
1170 /**************************************************************************
1171 * GetTopWindow (USER.229)
1173 HWND16 WINAPI
GetTopWindow16( HWND16 hwnd
)
1175 return HWND_16( GetTopWindow( WIN_Handle32(hwnd
) ));
1179 /**************************************************************************
1180 * GetNextWindow (USER.230)
1182 HWND16 WINAPI
GetNextWindow16( HWND16 hwnd
, WORD flag
)
1184 if ((flag
!= GW_HWNDNEXT
) && (flag
!= GW_HWNDPREV
)) return 0;
1185 return GetWindow16( hwnd
, flag
);
1189 /**************************************************************************
1190 * SetWindowPos (USER.232)
1192 BOOL16 WINAPI
SetWindowPos16( HWND16 hwnd
, HWND16 hwndInsertAfter
,
1193 INT16 x
, INT16 y
, INT16 cx
, INT16 cy
, WORD flags
)
1195 return SetWindowPos( WIN_Handle32(hwnd
), full_insert_after_hwnd(hwndInsertAfter
),
1196 x
, y
, cx
, cy
, flags
);
1200 /**************************************************************************
1201 * SetParent (USER.233)
1203 HWND16 WINAPI
SetParent16( HWND16 hwndChild
, HWND16 hwndNewParent
)
1205 return HWND_16( SetParent( WIN_Handle32(hwndChild
), WIN_Handle32(hwndNewParent
) ));
1209 /**************************************************************************
1210 * GetCapture (USER.236)
1212 HWND16 WINAPI
GetCapture16(void)
1214 return HWND_16( GetCapture() );
1218 /**************************************************************************
1219 * GetUpdateRgn (USER.237)
1221 INT16 WINAPI
GetUpdateRgn16( HWND16 hwnd
, HRGN16 hrgn
, BOOL16 erase
)
1223 return GetUpdateRgn( WIN_Handle32(hwnd
), HRGN_32(hrgn
), erase
);
1227 /**************************************************************************
1228 * ExcludeUpdateRgn (USER.238)
1230 INT16 WINAPI
ExcludeUpdateRgn16( HDC16 hdc
, HWND16 hwnd
)
1232 return ExcludeUpdateRgn( HDC_32(hdc
), WIN_Handle32(hwnd
) );
1236 /**************************************************************************
1237 * GetOpenClipboardWindow (USER.248)
1239 HWND16 WINAPI
GetOpenClipboardWindow16(void)
1241 return HWND_16( GetOpenClipboardWindow() );
1245 /*******************************************************************
1246 * MapWindowPoints (USER.258)
1248 void WINAPI
MapWindowPoints16( HWND16 hwndFrom
, HWND16 hwndTo
, LPPOINT16 lppt
, UINT16 count
)
1250 POINT buffer
[8], *ppt
= buffer
;
1253 if (count
> 8) ppt
= HeapAlloc( GetProcessHeap(), 0, count
* sizeof(*ppt
) );
1254 for (i
= 0; i
< count
; i
++)
1256 ppt
[i
].x
= lppt
[i
].x
;
1257 ppt
[i
].y
= lppt
[i
].y
;
1259 MapWindowPoints( WIN_Handle32(hwndFrom
), WIN_Handle32(hwndTo
), ppt
, count
);
1260 for (i
= 0; i
< count
; i
++)
1262 lppt
[i
].x
= ppt
[i
].x
;
1263 lppt
[i
].y
= ppt
[i
].y
;
1265 if (ppt
!= buffer
) HeapFree( GetProcessHeap(), 0, ppt
);
1269 /**************************************************************************
1270 * BeginDeferWindowPos (USER.259)
1272 HDWP16 WINAPI
BeginDeferWindowPos16( INT16 count
)
1274 return HDWP_16(BeginDeferWindowPos( count
));
1278 /**************************************************************************
1279 * DeferWindowPos (USER.260)
1281 HDWP16 WINAPI
DeferWindowPos16( HDWP16 hdwp
, HWND16 hwnd
, HWND16 hwndAfter
,
1282 INT16 x
, INT16 y
, INT16 cx
, INT16 cy
,
1285 return HDWP_16(DeferWindowPos( HDWP_32(hdwp
), WIN_Handle32(hwnd
),
1286 full_insert_after_hwnd(hwndAfter
), x
, y
, cx
, cy
, flags
));
1290 /**************************************************************************
1291 * EndDeferWindowPos (USER.261)
1293 BOOL16 WINAPI
EndDeferWindowPos16( HDWP16 hdwp
)
1295 return EndDeferWindowPos(HDWP_32(hdwp
));
1299 /**************************************************************************
1300 * GetWindow (USER.262)
1302 HWND16 WINAPI
GetWindow16( HWND16 hwnd
, WORD rel
)
1304 return HWND_16( GetWindow( WIN_Handle32(hwnd
), rel
) );
1308 /**************************************************************************
1309 * ShowOwnedPopups (USER.265)
1311 void WINAPI
ShowOwnedPopups16( HWND16 owner
, BOOL16 fShow
)
1313 ShowOwnedPopups( WIN_Handle32(owner
), fShow
);
1317 /**************************************************************************
1318 * ShowScrollBar (USER.267)
1320 void WINAPI
ShowScrollBar16( HWND16 hwnd
, INT16 nBar
, BOOL16 fShow
)
1322 ShowScrollBar( WIN_Handle32(hwnd
), nBar
, fShow
);
1326 /**************************************************************************
1327 * IsZoomed (USER.272)
1329 BOOL16 WINAPI
IsZoomed16(HWND16 hwnd
)
1331 return IsZoomed( WIN_Handle32(hwnd
) );
1335 /**************************************************************************
1336 * GetDlgCtrlID (USER.277)
1338 INT16 WINAPI
GetDlgCtrlID16( HWND16 hwnd
)
1340 return GetDlgCtrlID( WIN_Handle32(hwnd
) );
1344 /**************************************************************************
1345 * GetDesktopHwnd (USER.278)
1347 * Exactly the same thing as GetDesktopWindow(), but not documented.
1348 * Don't ask me why...
1350 HWND16 WINAPI
GetDesktopHwnd16(void)
1352 return GetDesktopWindow16();
1356 /**************************************************************************
1357 * SetSystemMenu (USER.280)
1359 BOOL16 WINAPI
SetSystemMenu16( HWND16 hwnd
, HMENU16 hMenu
)
1361 return SetSystemMenu( WIN_Handle32(hwnd
), HMENU_32(hMenu
) );
1365 /**************************************************************************
1366 * GetDesktopWindow (USER.286)
1368 HWND16 WINAPI
GetDesktopWindow16(void)
1370 return HWND_16( GetDesktopWindow() );
1374 /**************************************************************************
1375 * GetLastActivePopup (USER.287)
1377 HWND16 WINAPI
GetLastActivePopup16( HWND16 hwnd
)
1379 return HWND_16( GetLastActivePopup( WIN_Handle32(hwnd
) ));
1383 /**************************************************************************
1384 * RedrawWindow (USER.290)
1386 BOOL16 WINAPI
RedrawWindow16( HWND16 hwnd
, const RECT16
*rectUpdate
,
1387 HRGN16 hrgnUpdate
, UINT16 flags
)
1392 r
.left
= rectUpdate
->left
;
1393 r
.top
= rectUpdate
->top
;
1394 r
.right
= rectUpdate
->right
;
1395 r
.bottom
= rectUpdate
->bottom
;
1396 return RedrawWindow(WIN_Handle32(hwnd
), &r
, HRGN_32(hrgnUpdate
), flags
);
1398 return RedrawWindow(WIN_Handle32(hwnd
), NULL
, HRGN_32(hrgnUpdate
), flags
);
1402 /**************************************************************************
1403 * LockWindowUpdate (USER.294)
1405 BOOL16 WINAPI
LockWindowUpdate16( HWND16 hwnd
)
1407 return LockWindowUpdate( WIN_Handle32(hwnd
) );
1411 /**************************************************************************
1412 * ScrollWindowEx (USER.319)
1414 INT16 WINAPI
ScrollWindowEx16( HWND16 hwnd
, INT16 dx
, INT16 dy
,
1415 const RECT16
*rect
, const RECT16
*clipRect
,
1416 HRGN16 hrgnUpdate
, LPRECT16 rcUpdate
,
1419 RECT rect32
, clipRect32
, rcUpdate32
;
1424 rect32
.left
= rect
->left
;
1425 rect32
.top
= rect
->top
;
1426 rect32
.right
= rect
->right
;
1427 rect32
.bottom
= rect
->bottom
;
1431 clipRect32
.left
= clipRect
->left
;
1432 clipRect32
.top
= clipRect
->top
;
1433 clipRect32
.right
= clipRect
->right
;
1434 clipRect32
.bottom
= clipRect
->bottom
;
1436 ret
= ScrollWindowEx( WIN_Handle32(hwnd
), dx
, dy
, rect
? &rect32
: NULL
,
1437 clipRect
? &clipRect32
: NULL
, HRGN_32(hrgnUpdate
),
1438 (rcUpdate
) ? &rcUpdate32
: NULL
, flags
);
1441 rcUpdate
->left
= rcUpdate32
.left
;
1442 rcUpdate
->top
= rcUpdate32
.top
;
1443 rcUpdate
->right
= rcUpdate32
.right
;
1444 rcUpdate
->bottom
= rcUpdate32
.bottom
;
1450 /**************************************************************************
1451 * FillWindow (USER.324)
1453 void WINAPI
FillWindow16( HWND16 hwndParent
, HWND16 hwnd
, HDC16 hdc
, HBRUSH16 hbrush
)
1457 GetClientRect( WIN_Handle32(hwnd
), &rect
);
1458 DPtoLP( HDC_32(hdc
), (LPPOINT
)&rect
, 2 );
1459 rc16
.left
= rect
.left
;
1460 rc16
.top
= rect
.top
;
1461 rc16
.right
= rect
.right
;
1462 rc16
.bottom
= rect
.bottom
;
1463 PaintRect16( hwndParent
, hwnd
, hdc
, hbrush
, &rc16
);
1467 /**************************************************************************
1468 * PaintRect (USER.325)
1470 void WINAPI
PaintRect16( HWND16 hwndParent
, HWND16 hwnd
, HDC16 hdc
,
1471 HBRUSH16 hbrush
, const RECT16
*rect
)
1473 if (hbrush
<= CTLCOLOR_STATIC
)
1475 HWND parent
= WIN_Handle32(hwndParent
), hwnd32
= WIN_Handle32(hwnd
);
1477 if (!parent
) return;
1478 hbrush
= SendMessageW( parent
, WM_CTLCOLORMSGBOX
+ hbrush
, hdc
, (LPARAM
)hwnd32
);
1479 if (!hbrush
) hbrush
= DefWindowProcW( parent
, WM_CTLCOLORMSGBOX
+ hbrush
,
1480 hdc
, (LPARAM
)hwnd32
);
1482 if (hbrush
) FillRect16( hdc
, rect
, hbrush
);
1486 /**************************************************************************
1487 * GetControlBrush (USER.326)
1489 HBRUSH16 WINAPI
GetControlBrush16( HWND16 hwnd
, HDC16 hdc
, UINT16 ctlType
)
1492 HWND hwnd32
= WIN_Handle32(hwnd
);
1493 HWND parent
= GetParent( hwnd32
);
1495 if (!parent
) parent
= hwnd32
;
1496 ret
= SendMessageW( parent
, WM_CTLCOLORMSGBOX
+ ctlType
, hdc
, (LPARAM
)hwnd32
);
1497 if (!ret
) ret
= DefWindowProcW( parent
, WM_CTLCOLORMSGBOX
+ ctlType
,
1498 hdc
, (LPARAM
)hwnd32
);
1503 /**************************************************************************
1504 * GetDCEx (USER.359)
1506 HDC16 WINAPI
GetDCEx16( HWND16 hwnd
, HRGN16 hrgnClip
, DWORD flags
)
1508 return HDC_16(GetDCEx(WIN_Handle32(hwnd
), HRGN_32(hrgnClip
), flags
));
1512 /**************************************************************************
1513 * GetWindowPlacement (USER.370)
1515 BOOL16 WINAPI
GetWindowPlacement16( HWND16 hwnd
, WINDOWPLACEMENT16
*wp16
)
1517 WINDOWPLACEMENT wpl
;
1519 wpl
.length
= sizeof(wpl
);
1520 if (!GetWindowPlacement( WIN_Handle32(hwnd
), &wpl
)) return FALSE
;
1521 wp16
->length
= sizeof(*wp16
);
1522 wp16
->flags
= wpl
.flags
;
1523 wp16
->showCmd
= wpl
.showCmd
;
1524 wp16
->ptMinPosition
.x
= wpl
.ptMinPosition
.x
;
1525 wp16
->ptMinPosition
.y
= wpl
.ptMinPosition
.y
;
1526 wp16
->ptMaxPosition
.x
= wpl
.ptMaxPosition
.x
;
1527 wp16
->ptMaxPosition
.y
= wpl
.ptMaxPosition
.y
;
1528 wp16
->rcNormalPosition
.left
= wpl
.rcNormalPosition
.left
;
1529 wp16
->rcNormalPosition
.top
= wpl
.rcNormalPosition
.top
;
1530 wp16
->rcNormalPosition
.right
= wpl
.rcNormalPosition
.right
;
1531 wp16
->rcNormalPosition
.bottom
= wpl
.rcNormalPosition
.bottom
;
1536 /**************************************************************************
1537 * SetWindowPlacement (USER.371)
1539 BOOL16 WINAPI
SetWindowPlacement16( HWND16 hwnd
, const WINDOWPLACEMENT16
*wp16
)
1541 WINDOWPLACEMENT wpl
;
1543 if (!wp16
) return FALSE
;
1544 wpl
.length
= sizeof(wpl
);
1545 wpl
.flags
= wp16
->flags
;
1546 wpl
.showCmd
= wp16
->showCmd
;
1547 wpl
.ptMinPosition
.x
= wp16
->ptMinPosition
.x
;
1548 wpl
.ptMinPosition
.y
= wp16
->ptMinPosition
.y
;
1549 wpl
.ptMaxPosition
.x
= wp16
->ptMaxPosition
.x
;
1550 wpl
.ptMaxPosition
.y
= wp16
->ptMaxPosition
.y
;
1551 wpl
.rcNormalPosition
.left
= wp16
->rcNormalPosition
.left
;
1552 wpl
.rcNormalPosition
.top
= wp16
->rcNormalPosition
.top
;
1553 wpl
.rcNormalPosition
.right
= wp16
->rcNormalPosition
.right
;
1554 wpl
.rcNormalPosition
.bottom
= wp16
->rcNormalPosition
.bottom
;
1555 return SetWindowPlacement( WIN_Handle32(hwnd
), &wpl
);
1559 /***********************************************************************
1560 * RegisterClassEx (USER.397)
1562 ATOM WINAPI
RegisterClassEx16( const WNDCLASSEX16
*wc
)
1564 struct class_entry
*class;
1569 inst
= GetExePtr( wc
->hInstance
);
1570 if (!inst
) inst
= GetModuleHandle16( NULL
);
1572 wc32
.cbSize
= sizeof(wc32
);
1573 wc32
.style
= wc
->style
;
1574 wc32
.lpfnWndProc
= WINPROC_AllocProc16( wc
->lpfnWndProc
);
1575 wc32
.cbClsExtra
= wc
->cbClsExtra
;
1576 wc32
.cbWndExtra
= wc
->cbWndExtra
;
1577 wc32
.hInstance
= HINSTANCE_32(inst
);
1578 wc32
.hIcon
= HICON_32(wc
->hIcon
);
1579 wc32
.hCursor
= HCURSOR_32(wc
->hCursor
);
1580 wc32
.hbrBackground
= HBRUSH_32(wc
->hbrBackground
);
1581 wc32
.lpszMenuName
= MapSL(wc
->lpszMenuName
);
1582 wc32
.lpszClassName
= MapSL(wc
->lpszClassName
);
1583 wc32
.hIconSm
= HICON_32(wc
->hIconSm
);
1584 atom
= RegisterClassExA( &wc32
);
1585 if ((class = HeapAlloc( GetProcessHeap(), 0, sizeof(*class) )))
1589 list_add_tail( &class_list
, &class->entry
);
1595 /***********************************************************************
1596 * GetClassInfoEx (USER.398)
1598 * FIXME: this is just a guess, I have no idea if GetClassInfoEx() is the
1599 * same in Win16 as in Win32. --AJ
1601 BOOL16 WINAPI
GetClassInfoEx16( HINSTANCE16 hInst16
, SEGPTR name
, WNDCLASSEX16
*wc
)
1603 static HMODULE user32_module
;
1605 HINSTANCE hInstance
;
1608 if (!user32_module
) user32_module
= GetModuleHandleA( "user32.dll" );
1609 if (hInst16
== GetModuleHandle16("user")) hInstance
= user32_module
;
1610 else hInstance
= HINSTANCE_32(GetExePtr( hInst16
));
1612 ret
= GetClassInfoExA( hInstance
, MapSL(name
), &wc32
);
1616 wc
->lpfnWndProc
= WINPROC_GetProc16( wc32
.lpfnWndProc
, FALSE
);
1617 wc
->style
= wc32
.style
;
1618 wc
->cbClsExtra
= wc32
.cbClsExtra
;
1619 wc
->cbWndExtra
= wc32
.cbWndExtra
;
1620 wc
->hInstance
= (wc32
.hInstance
== user32_module
) ? GetModuleHandle16("user") : HINSTANCE_16(wc32
.hInstance
);
1621 wc
->hIcon
= HICON_16(wc32
.hIcon
);
1622 wc
->hIconSm
= HICON_16(wc32
.hIconSm
);
1623 wc
->hCursor
= HCURSOR_16(wc32
.hCursor
);
1624 wc
->hbrBackground
= HBRUSH_16(wc32
.hbrBackground
);
1625 wc
->lpszClassName
= 0;
1626 wc
->lpszMenuName
= MapLS(wc32
.lpszMenuName
); /* FIXME: leak */
1632 /**************************************************************************
1633 * ChildWindowFromPointEx (USER.399)
1635 HWND16 WINAPI
ChildWindowFromPointEx16( HWND16 hwndParent
, POINT16 pt
, UINT16 uFlags
)
1641 return HWND_16( ChildWindowFromPointEx( WIN_Handle32(hwndParent
), pt32
, uFlags
));
1645 /**************************************************************************
1646 * GetPriorityClipboardFormat (USER.402)
1648 INT16 WINAPI
GetPriorityClipboardFormat16( UINT16
*list
, INT16 count
)
1652 for (i
= 0; i
< count
; i
++)
1653 if (IsClipboardFormatAvailable( list
[i
] )) return list
[i
];
1658 /***********************************************************************
1659 * UnregisterClass (USER.403)
1661 BOOL16 WINAPI
UnregisterClass16( LPCSTR className
, HINSTANCE16 hInstance
)
1665 if (hInstance
== GetModuleHandle16("user")) hInstance
= 0;
1666 else hInstance
= GetExePtr( hInstance
);
1668 if ((atom
= GlobalFindAtomA( className
)))
1670 struct class_entry
*class;
1671 LIST_FOR_EACH_ENTRY( class, &class_list
, struct class_entry
, entry
)
1673 if (class->inst
!= hInstance
) continue;
1674 if (class->atom
!= atom
) continue;
1675 list_remove( &class->entry
);
1676 HeapFree( GetProcessHeap(), 0, class );
1680 return UnregisterClassA( className
, HINSTANCE_32(hInstance
) );
1684 /***********************************************************************
1685 * GetClassInfo (USER.404)
1687 BOOL16 WINAPI
GetClassInfo16( HINSTANCE16 hInst16
, SEGPTR name
, WNDCLASS16
*wc
)
1690 UINT16 ret
= GetClassInfoEx16( hInst16
, name
, &wcex
);
1694 wc
->style
= wcex
.style
;
1695 wc
->lpfnWndProc
= wcex
.lpfnWndProc
;
1696 wc
->cbClsExtra
= wcex
.cbClsExtra
;
1697 wc
->cbWndExtra
= wcex
.cbWndExtra
;
1698 wc
->hInstance
= wcex
.hInstance
;
1699 wc
->hIcon
= wcex
.hIcon
;
1700 wc
->hCursor
= wcex
.hCursor
;
1701 wc
->hbrBackground
= wcex
.hbrBackground
;
1702 wc
->lpszMenuName
= wcex
.lpszMenuName
;
1703 wc
->lpszClassName
= wcex
.lpszClassName
;
1709 /**************************************************************************
1710 * TrackPopupMenu (USER.416)
1712 BOOL16 WINAPI
TrackPopupMenu16( HMENU16 hMenu
, UINT16 wFlags
, INT16 x
, INT16 y
,
1713 INT16 nReserved
, HWND16 hwnd
, const RECT16
*lpRect
)
1718 r
.left
= lpRect
->left
;
1719 r
.top
= lpRect
->top
;
1720 r
.right
= lpRect
->right
;
1721 r
.bottom
= lpRect
->bottom
;
1723 return TrackPopupMenu( HMENU_32(hMenu
), wFlags
, x
, y
, nReserved
,
1724 WIN_Handle32(hwnd
), lpRect
? &r
: NULL
);
1728 /**************************************************************************
1729 * FindWindowEx (USER.427)
1731 HWND16 WINAPI
FindWindowEx16( HWND16 parent
, HWND16 child
, LPCSTR className
, LPCSTR title
)
1733 return HWND_16( FindWindowExA( WIN_Handle32(parent
), WIN_Handle32(child
),
1734 className
, title
));
1738 /***********************************************************************
1739 * DefFrameProc (USER.445)
1741 LRESULT WINAPI
DefFrameProc16( HWND16 hwnd
, HWND16 hwndMDIClient
,
1742 UINT16 message
, WPARAM16 wParam
, LPARAM lParam
)
1747 lParam
= (LPARAM
)MapSL(lParam
);
1753 return DefFrameProcA( WIN_Handle32(hwnd
), WIN_Handle32(hwndMDIClient
),
1754 message
, wParam
, lParam
);
1758 MDINEXTMENU next_menu
;
1759 DefFrameProcW( WIN_Handle32(hwnd
), WIN_Handle32(hwndMDIClient
),
1760 message
, wParam
, (LPARAM
)&next_menu
);
1761 return MAKELONG( HMENU_16(next_menu
.hmenuNext
), HWND_16(next_menu
.hwndNext
) );
1764 return DefWindowProc16(hwnd
, message
, wParam
, lParam
);
1769 /***********************************************************************
1770 * DefMDIChildProc (USER.447)
1772 LRESULT WINAPI
DefMDIChildProc16( HWND16 hwnd
, UINT16 message
,
1773 WPARAM16 wParam
, LPARAM lParam
)
1778 return DefMDIChildProcA( WIN_Handle32(hwnd
), message
, wParam
, (LPARAM
)MapSL(lParam
) );
1783 case WM_CHILDACTIVATE
:
1788 return DefMDIChildProcW( WIN_Handle32(hwnd
), message
, wParam
, lParam
);
1790 case WM_GETMINMAXINFO
:
1792 MINMAXINFO16
*mmi16
= MapSL(lParam
);
1795 mmi
.ptReserved
.x
= mmi16
->ptReserved
.x
;
1796 mmi
.ptReserved
.y
= mmi16
->ptReserved
.y
;
1797 mmi
.ptMaxSize
.x
= mmi16
->ptMaxSize
.x
;
1798 mmi
.ptMaxSize
.y
= mmi16
->ptMaxSize
.y
;
1799 mmi
.ptMaxPosition
.x
= mmi16
->ptMaxPosition
.x
;
1800 mmi
.ptMaxPosition
.y
= mmi16
->ptMaxPosition
.y
;
1801 mmi
.ptMinTrackSize
.x
= mmi16
->ptMinTrackSize
.x
;
1802 mmi
.ptMinTrackSize
.y
= mmi16
->ptMinTrackSize
.y
;
1803 mmi
.ptMaxTrackSize
.x
= mmi16
->ptMaxTrackSize
.x
;
1804 mmi
.ptMaxTrackSize
.y
= mmi16
->ptMaxTrackSize
.y
;
1806 DefMDIChildProcW( WIN_Handle32(hwnd
), message
, wParam
, (LPARAM
)&mmi
);
1808 mmi16
->ptReserved
.x
= mmi
.ptReserved
.x
;
1809 mmi16
->ptReserved
.y
= mmi
.ptReserved
.y
;
1810 mmi16
->ptMaxSize
.x
= mmi
.ptMaxSize
.x
;
1811 mmi16
->ptMaxSize
.y
= mmi
.ptMaxSize
.y
;
1812 mmi16
->ptMaxPosition
.x
= mmi
.ptMaxPosition
.x
;
1813 mmi16
->ptMaxPosition
.y
= mmi
.ptMaxPosition
.y
;
1814 mmi16
->ptMinTrackSize
.x
= mmi
.ptMinTrackSize
.x
;
1815 mmi16
->ptMinTrackSize
.y
= mmi
.ptMinTrackSize
.y
;
1816 mmi16
->ptMaxTrackSize
.x
= mmi
.ptMaxTrackSize
.x
;
1817 mmi16
->ptMaxTrackSize
.y
= mmi
.ptMaxTrackSize
.y
;
1822 MDINEXTMENU next_menu
;
1823 DefMDIChildProcW( WIN_Handle32(hwnd
), message
, wParam
, (LPARAM
)&next_menu
);
1824 return MAKELONG( HMENU_16(next_menu
.hmenuNext
), HWND_16(next_menu
.hwndNext
) );
1827 return DefWindowProc16(hwnd
, message
, wParam
, lParam
);
1832 /**************************************************************************
1833 * DrawAnimatedRects (USER.448)
1835 BOOL16 WINAPI
DrawAnimatedRects16( HWND16 hwnd
, INT16 idAni
,
1836 const RECT16
* lprcFrom
, const RECT16
* lprcTo
)
1838 RECT rcFrom32
, rcTo32
;
1839 rcFrom32
.left
= lprcFrom
->left
;
1840 rcFrom32
.top
= lprcFrom
->top
;
1841 rcFrom32
.right
= lprcFrom
->right
;
1842 rcFrom32
.bottom
= lprcFrom
->bottom
;
1843 rcTo32
.left
= lprcTo
->left
;
1844 rcTo32
.top
= lprcTo
->top
;
1845 rcTo32
.right
= lprcTo
->right
;
1846 rcTo32
.bottom
= lprcTo
->bottom
;
1847 return DrawAnimatedRects( WIN_Handle32(hwnd
), idAni
, &rcFrom32
, &rcTo32
);
1851 /***********************************************************************
1852 * CreateWindowEx (USER.452)
1854 HWND16 WINAPI
CreateWindowEx16( DWORD exStyle
, LPCSTR className
,
1855 LPCSTR windowName
, DWORD style
, INT16 x
,
1856 INT16 y
, INT16 width
, INT16 height
,
1857 HWND16 parent
, HMENU16 menu
,
1858 HINSTANCE16 instance
, LPVOID data
)
1864 /* Fix the coordinates */
1866 cs
.x
= (x
== CW_USEDEFAULT16
) ? CW_USEDEFAULT
: (INT
)x
;
1867 cs
.y
= (y
== CW_USEDEFAULT16
) ? CW_USEDEFAULT
: (INT
)y
;
1868 cs
.cx
= (width
== CW_USEDEFAULT16
) ? CW_USEDEFAULT
: (INT
)width
;
1869 cs
.cy
= (height
== CW_USEDEFAULT16
) ? CW_USEDEFAULT
: (INT
)height
;
1871 /* Create the window */
1873 cs
.lpCreateParams
= data
;
1874 cs
.hInstance
= HINSTANCE_32(instance
);
1875 cs
.hMenu
= HMENU_32(menu
);
1876 cs
.hwndParent
= WIN_Handle32( parent
);
1878 cs
.lpszName
= windowName
;
1879 cs
.lpszClass
= className
;
1880 cs
.dwExStyle
= exStyle
;
1883 if (!menu
&& (style
& (WS_CHILD
| WS_POPUP
)) != WS_CHILD
)
1886 HINSTANCE16 module
= GetExePtr( instance
);
1888 if (GetClassInfoA( HINSTANCE_32(module
), className
, &class ))
1889 cs
.hMenu
= HMENU_32( LoadMenu16( module
, class.lpszMenuName
));
1892 if (!IS_INTRESOURCE(className
))
1896 if (!MultiByteToWideChar( CP_ACP
, 0, className
, -1, bufferW
, sizeof(bufferW
)/sizeof(WCHAR
) ))
1898 hwnd
= create_window16( (CREATESTRUCTW
*)&cs
, bufferW
, HINSTANCE_32(instance
), FALSE
);
1902 if (!GlobalGetAtomNameA( LOWORD(className
), buffer
, sizeof(buffer
) )) return 0;
1903 cs
.lpszClass
= buffer
;
1904 hwnd
= create_window16( (CREATESTRUCTW
*)&cs
, (LPCWSTR
)className
, HINSTANCE_32(instance
), FALSE
);
1906 return HWND_16( hwnd
);
1910 /***********************************************************************
1911 * GetInternalWindowPos (USER.460)
1913 UINT16 WINAPI
GetInternalWindowPos16( HWND16 hwnd
, LPRECT16 rectWnd
, LPPOINT16 ptIcon
)
1915 WINDOWPLACEMENT16 wndpl
;
1917 if (!GetWindowPlacement16( hwnd
, &wndpl
)) return 0;
1918 if (rectWnd
) *rectWnd
= wndpl
.rcNormalPosition
;
1919 if (ptIcon
) *ptIcon
= wndpl
.ptMinPosition
;
1920 return wndpl
.showCmd
;
1924 /**************************************************************************
1925 * SetInternalWindowPos (USER.461)
1927 void WINAPI
SetInternalWindowPos16( HWND16 hwnd
, UINT16 showCmd
, LPRECT16 rect
, LPPOINT16 pt
)
1934 rc32
.left
= rect
->left
;
1935 rc32
.top
= rect
->top
;
1936 rc32
.right
= rect
->right
;
1937 rc32
.bottom
= rect
->bottom
;
1944 SetInternalWindowPos( WIN_Handle32(hwnd
), showCmd
,
1945 rect
? &rc32
: NULL
, pt
? &pt32
: NULL
);
1949 /**************************************************************************
1950 * CalcChildScroll (USER.462)
1952 void WINAPI
CalcChildScroll16( HWND16 hwnd
, WORD scroll
)
1954 CalcChildScroll( WIN_Handle32(hwnd
), scroll
);
1958 /**************************************************************************
1959 * ScrollChildren (USER.463)
1961 void WINAPI
ScrollChildren16(HWND16 hwnd
, UINT16 uMsg
, WPARAM16 wParam
, LPARAM lParam
)
1963 ScrollChildren( WIN_Handle32(hwnd
), uMsg
, wParam
, lParam
);
1967 /**************************************************************************
1968 * DragDetect (USER.465)
1970 BOOL16 WINAPI
DragDetect16( HWND16 hwnd
, POINT16 pt
)
1976 return DragDetect( WIN_Handle32(hwnd
), pt32
);
1980 /**************************************************************************
1981 * SetScrollInfo (USER.475)
1983 INT16 WINAPI
SetScrollInfo16( HWND16 hwnd
, INT16 nBar
, const SCROLLINFO
*info
, BOOL16 redraw
)
1985 return SetScrollInfo( WIN_Handle32(hwnd
), nBar
, info
, redraw
);
1989 /**************************************************************************
1990 * GetScrollInfo (USER.476)
1992 BOOL16 WINAPI
GetScrollInfo16( HWND16 hwnd
, INT16 nBar
, LPSCROLLINFO info
)
1994 return GetScrollInfo( WIN_Handle32(hwnd
), nBar
, info
);
1998 /**************************************************************************
1999 * EnableScrollBar (USER.482)
2001 BOOL16 WINAPI
EnableScrollBar16( HWND16 hwnd
, INT16 nBar
, UINT16 flags
)
2003 return EnableScrollBar( WIN_Handle32(hwnd
), nBar
, flags
);
2007 /**************************************************************************
2008 * GetShellWindow (USER.600)
2010 HWND16 WINAPI
GetShellWindow16(void)
2012 return HWND_16( GetShellWindow() );
2016 /**************************************************************************
2017 * GetForegroundWindow (USER.608)
2019 HWND16 WINAPI
GetForegroundWindow16(void)
2021 return HWND_16( GetForegroundWindow() );
2025 /**************************************************************************
2026 * SetForegroundWindow (USER.609)
2028 BOOL16 WINAPI
SetForegroundWindow16( HWND16 hwnd
)
2030 return SetForegroundWindow( WIN_Handle32(hwnd
) );
2034 /**************************************************************************
2035 * DrawCaptionTemp (USER.657)
2037 BOOL16 WINAPI
DrawCaptionTemp16( HWND16 hwnd
, HDC16 hdc
, const RECT16
*rect
,
2038 HFONT16 hFont
, HICON16 hIcon
, LPCSTR str
, UINT16 uFlags
)
2044 rect32
.left
= rect
->left
;
2045 rect32
.top
= rect
->top
;
2046 rect32
.right
= rect
->right
;
2047 rect32
.bottom
= rect
->bottom
;
2049 return DrawCaptionTempA( WIN_Handle32(hwnd
), HDC_32(hdc
),
2050 rect
? &rect32
: NULL
, HFONT_32(hFont
),
2051 HICON_32(hIcon
), str
, uFlags
& 0x1f );
2055 /**************************************************************************
2056 * DrawCaption (USER.660)
2058 BOOL16 WINAPI
DrawCaption16( HWND16 hwnd
, HDC16 hdc
, const RECT16
*rect
, UINT16 flags
)
2064 rect32
.left
= rect
->left
;
2065 rect32
.top
= rect
->top
;
2066 rect32
.right
= rect
->right
;
2067 rect32
.bottom
= rect
->bottom
;
2069 return DrawCaption(WIN_Handle32(hwnd
), HDC_32(hdc
), rect
? &rect32
: NULL
, flags
);
2073 /**************************************************************************
2074 * GetMenuItemRect (USER.665)
2076 BOOL16 WINAPI
GetMenuItemRect16( HWND16 hwnd
, HMENU16 hMenu
, UINT16 uItem
,
2081 if (!rect
) return FALSE
;
2082 res
= GetMenuItemRect( WIN_Handle32(hwnd
), HMENU_32(hMenu
), uItem
, &r32
);
2083 rect
->left
= r32
.left
;
2084 rect
->top
= r32
.top
;
2085 rect
->right
= r32
.right
;
2086 rect
->bottom
= r32
.bottom
;
2091 /**************************************************************************
2092 * SetWindowRgn (USER.668)
2094 INT16 WINAPI
SetWindowRgn16( HWND16 hwnd
, HRGN16 hrgn
, BOOL16 redraw
)
2096 return SetWindowRgn( WIN_Handle32(hwnd
), HRGN_32(hrgn
), redraw
);
2100 /**************************************************************************
2101 * MessageBoxIndirect (USER.827)
2103 INT16 WINAPI
MessageBoxIndirect16( LPMSGBOXPARAMS16 msgbox
)
2105 char caption
[256], text
[256];
2106 MSGBOXPARAMSA msgbox32
;
2108 msgbox32
.cbSize
= msgbox
->cbSize
;
2109 msgbox32
.hwndOwner
= WIN_Handle32( msgbox
->hwndOwner
);
2110 msgbox32
.hInstance
= 0;
2111 msgbox32
.dwStyle
= msgbox
->dwStyle
;
2112 msgbox32
.lpszIcon
= NULL
;
2113 msgbox32
.dwContextHelpId
= msgbox
->dwContextHelpId
;
2114 msgbox32
.lpfnMsgBoxCallback
= msgbox
->lpfnMsgBoxCallback
;
2115 msgbox32
.dwLanguageId
= msgbox
->dwLanguageId
;
2117 if (!HIWORD(msgbox
->lpszCaption
))
2119 LoadString16( msgbox
->hInstance
, LOWORD(msgbox
->lpszCaption
), caption
, sizeof(caption
) );
2120 msgbox32
.lpszCaption
= caption
;
2122 else msgbox32
.lpszCaption
= MapSL(msgbox
->lpszCaption
);
2124 if (!HIWORD(msgbox
->lpszText
))
2126 LoadString16( msgbox
->hInstance
, LOWORD(msgbox
->lpszText
), text
, sizeof(text
) );
2127 msgbox32
.lpszText
= text
;
2129 else msgbox32
.lpszText
= MapSL(msgbox
->lpszText
);
2131 if ((msgbox
->dwStyle
& MB_ICONMASK
) == MB_USERICON
)
2133 FIXME( "user icon %s not supported\n", debugstr_a( MapSL(msgbox
->lpszIcon
) ));
2134 msgbox32
.dwStyle
&= ~MB_USERICON
;
2137 return MessageBoxIndirectA( &msgbox32
);