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/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
;
47 static struct list class_list
= LIST_INIT( class_list
);
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
;
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
);
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
;
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 /**************************************************************************
93 INT16 WINAPI
MessageBox16( HWND16 hwnd
, LPCSTR text
, LPCSTR title
, UINT16 type
)
95 return MessageBoxA( WIN_Handle32(hwnd
), text
, title
, type
);
99 /***********************************************************************
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 /**************************************************************************
149 HWND16 WINAPI
SetFocus16( HWND16 hwnd
)
151 return HWND_16( SetFocus( WIN_Handle32(hwnd
) ));
155 /**************************************************************************
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 /**************************************************************************
176 HANDLE16 WINAPI
GetProp16( HWND16 hwnd
, LPCSTR str
)
178 return HANDLE_16(GetPropA( WIN_Handle32(hwnd
), str
));
182 /**************************************************************************
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
;
201 if (!(list
= HeapAlloc( GetProcessHeap(), 0, total
* sizeof(*list
) ))) break;
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
;
211 if (count
&& count
<= total
)
213 char string
[ATOM_BUFFER_SIZE
];
214 SEGPTR segptr
= MapLS( string
);
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;
224 args
[2] = SELECTOROF(segptr
);
225 args
[1] = OFFSETOF(segptr
);
226 args
[0] = LOWORD(list
[i
].data
);
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;
239 HeapFree( GetProcessHeap(), 0, list
);
242 HeapFree( GetProcessHeap(), 0, list
);
243 total
= count
; /* restart with larger buffer */
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
)
276 return HWND_16( WindowFromPoint( pt32
) );
280 /**************************************************************************
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
)
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
)
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
)
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
;
384 /***********************************************************************
387 BOOL16 WINAPI
EndPaint16( HWND16 hwnd
, const PAINTSTRUCT16
* lps
)
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 /**************************************************************************
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 /**************************************************************************
457 BOOL16 WINAPI
IsWindow16( HWND16 hwnd
)
459 CURRENT_STACK16
->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 INT16 ret
= (INT16
)ReleaseDC( WIN_Handle32(hwnd
), HDC_32(hdc
) );
679 SetHookFlags( HDC_32(hdc
), DCHF_ENABLEDC
);
684 /**************************************************************************
685 * FlashWindow (USER.105)
687 BOOL16 WINAPI
FlashWindow16( HWND16 hwnd
, BOOL16 bInvert
)
689 return FlashWindow( WIN_Handle32(hwnd
), bInvert
);
693 /**************************************************************************
694 * WindowFromDC (USER.117)
696 HWND16 WINAPI
WindowFromDC16( HDC16 hDC
)
698 return HWND_16( WindowFromDC( HDC_32(hDC
) ) );
702 /**************************************************************************
703 * UpdateWindow (USER.124)
705 void WINAPI
UpdateWindow16( HWND16 hwnd
)
707 RedrawWindow16( hwnd
, NULL
, 0, RDW_UPDATENOW
| RDW_ALLCHILDREN
);
711 /**************************************************************************
712 * InvalidateRect (USER.125)
714 void WINAPI
InvalidateRect16( HWND16 hwnd
, const RECT16
*rect
, BOOL16 erase
)
716 RedrawWindow16( hwnd
, rect
, 0, RDW_INVALIDATE
| (erase
? RDW_ERASE
: 0) );
720 /**************************************************************************
721 * InvalidateRgn (USER.126)
723 void WINAPI
InvalidateRgn16( HWND16 hwnd
, HRGN16 hrgn
, BOOL16 erase
)
725 RedrawWindow16( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| (erase
? RDW_ERASE
: 0) );
729 /**************************************************************************
730 * ValidateRect (USER.127)
732 void WINAPI
ValidateRect16( HWND16 hwnd
, const RECT16
*rect
)
734 RedrawWindow16( hwnd
, rect
, 0, RDW_VALIDATE
| RDW_NOCHILDREN
);
738 /**************************************************************************
739 * ValidateRgn (USER.128)
741 void WINAPI
ValidateRgn16( HWND16 hwnd
, HRGN16 hrgn
)
743 RedrawWindow16( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_NOCHILDREN
);
747 /**************************************************************************
748 * GetClassWord (USER.129)
750 WORD WINAPI
GetClassWord16( HWND16 hwnd
, INT16 offset
)
759 icon
= (HICON
)GetClassLongPtrW( WIN_Handle32(hwnd
), offset
);
760 return get_icon_16( icon
);
762 return GetClassWord( WIN_Handle32(hwnd
), offset
);
766 /**************************************************************************
767 * SetClassWord (USER.130)
769 WORD WINAPI
SetClassWord16( HWND16 hwnd
, INT16 offset
, WORD newval
)
778 icon
= (HICON
)SetClassLongPtrW( WIN_Handle32(hwnd
), offset
, (ULONG_PTR
)get_icon_32(newval
) );
779 return get_icon_16( icon
);
781 return SetClassWord( WIN_Handle32(hwnd
), offset
, newval
);
785 /***********************************************************************
786 * GetClassLong (USER.131)
788 LONG WINAPI
GetClassLong16( HWND16 hwnd16
, INT16 offset
)
790 LONG_PTR ret
= GetClassLongA( WIN_Handle32(hwnd16
), offset
);
795 return (LONG_PTR
)WINPROC_GetProc16( (WNDPROC
)ret
, FALSE
);
797 return MapLS( (void *)ret
); /* leak */
801 return get_icon_16( (HICON
)ret
);
808 /***********************************************************************
809 * SetClassLong (USER.132)
811 LONG WINAPI
SetClassLong16( HWND16 hwnd16
, INT16 offset
, LONG newval
)
820 icon
= (HICON
)SetClassLongPtrW( WIN_Handle32(hwnd16
), offset
, (ULONG_PTR
)get_icon_32(newval
) );
821 return get_icon_16( icon
);
824 WNDPROC new_proc
= WINPROC_AllocProc16( (WNDPROC16
)newval
);
825 WNDPROC old_proc
= (WNDPROC
)SetClassLongA( WIN_Handle32(hwnd16
), offset
, (LONG_PTR
)new_proc
);
826 return (LONG
)WINPROC_GetProc16( old_proc
, FALSE
);
829 newval
= (LONG
)MapSL( newval
);
832 return SetClassLongA( WIN_Handle32(hwnd16
), offset
, newval
);
837 /**************************************************************************
838 * GetWindowWord (USER.133)
840 WORD WINAPI
GetWindowWord16( HWND16 hwnd
, INT16 offset
)
842 return GetWindowWord( WIN_Handle32(hwnd
), offset
);
846 /**************************************************************************
847 * SetWindowWord (USER.134)
849 WORD WINAPI
SetWindowWord16( HWND16 hwnd
, INT16 offset
, WORD newval
)
851 return SetWindowWord( WIN_Handle32(hwnd
), offset
, newval
);
855 /**********************************************************************
856 * GetWindowLong (USER.135)
858 LONG WINAPI
GetWindowLong16( HWND16 hwnd16
, INT16 offset
)
860 HWND hwnd
= WIN_Handle32( hwnd16
);
862 BOOL is_winproc
= (offset
== GWLP_WNDPROC
);
866 int cbWndExtra
= GetClassLongA( hwnd
, GCL_CBWNDEXTRA
);
868 if (offset
> (int)(cbWndExtra
- sizeof(LONG
)))
871 * Some programs try to access last element from 16 bit
872 * code using illegal offset value. Hopefully this is
873 * what those programs really expect.
875 if (cbWndExtra
>= 4 && offset
== cbWndExtra
- sizeof(WORD
))
877 offset
= cbWndExtra
- sizeof(LONG
);
881 SetLastError( ERROR_INVALID_INDEX
);
885 else if (offset
== DWLP_DLGPROC
)
886 is_winproc
= (wow_handlers32
.get_dialog_info( hwnd
, FALSE
) != NULL
);
888 retvalue
= GetWindowLongA( hwnd
, offset
);
889 if (is_winproc
) retvalue
= (LONG_PTR
)WINPROC_GetProc16( (WNDPROC
)retvalue
, FALSE
);
894 /**********************************************************************
895 * SetWindowLong (USER.136)
897 LONG WINAPI
SetWindowLong16( HWND16 hwnd16
, INT16 offset
, LONG newval
)
899 HWND hwnd
= WIN_Handle32( hwnd16
);
900 BOOL is_winproc
= (offset
== GWLP_WNDPROC
);
902 if (offset
== DWLP_DLGPROC
)
903 is_winproc
= (wow_handlers32
.get_dialog_info( hwnd
, FALSE
) != NULL
);
907 WNDPROC new_proc
= WINPROC_AllocProc16( (WNDPROC16
)newval
);
908 WNDPROC old_proc
= (WNDPROC
)SetWindowLongPtrA( hwnd
, offset
, (LONG_PTR
)new_proc
);
909 return (LONG
)WINPROC_GetProc16( old_proc
, FALSE
);
911 else return SetWindowLongA( hwnd
, offset
, newval
);
915 /**************************************************************************
916 * OpenClipboard (USER.137)
918 BOOL16 WINAPI
OpenClipboard16( HWND16 hwnd
)
920 return OpenClipboard( WIN_Handle32(hwnd
) );
924 /**************************************************************************
925 * GetClipboardOwner (USER.140)
927 HWND16 WINAPI
GetClipboardOwner16(void)
929 return HWND_16( GetClipboardOwner() );
933 /**************************************************************************
934 * SetClipboardViewer (USER.147)
936 HWND16 WINAPI
SetClipboardViewer16( HWND16 hwnd
)
938 return HWND_16( SetClipboardViewer( WIN_Handle32(hwnd
) ));
942 /**************************************************************************
943 * GetClipboardViewer (USER.148)
945 HWND16 WINAPI
GetClipboardViewer16(void)
947 return HWND_16( GetClipboardViewer() );
951 /**************************************************************************
952 * ChangeClipboardChain (USER.149)
954 BOOL16 WINAPI
ChangeClipboardChain16(HWND16 hwnd
, HWND16 hwndNext
)
956 return ChangeClipboardChain( WIN_Handle32(hwnd
), WIN_Handle32(hwndNext
) );
960 /**************************************************************************
961 * GetSystemMenu (USER.156)
963 HMENU16 WINAPI
GetSystemMenu16( HWND16 hwnd
, BOOL16 revert
)
965 return HMENU_16(GetSystemMenu( WIN_Handle32(hwnd
), revert
));
969 /**************************************************************************
972 HMENU16 WINAPI
GetMenu16( HWND16 hwnd
)
974 return HMENU_16(GetMenu( WIN_Handle32(hwnd
) ));
978 /**************************************************************************
981 BOOL16 WINAPI
SetMenu16( HWND16 hwnd
, HMENU16 hMenu
)
983 return SetMenu( WIN_Handle32(hwnd
), HMENU_32(hMenu
) );
987 /**************************************************************************
988 * DrawMenuBar (USER.160)
990 void WINAPI
DrawMenuBar16( HWND16 hwnd
)
992 DrawMenuBar( WIN_Handle32(hwnd
) );
996 /**************************************************************************
997 * HiliteMenuItem (USER.162)
999 BOOL16 WINAPI
HiliteMenuItem16( HWND16 hwnd
, HMENU16 hMenu
, UINT16 id
, UINT16 wHilite
)
1001 return HiliteMenuItem( WIN_Handle32(hwnd
), HMENU_32(hMenu
), id
, wHilite
);
1005 /**************************************************************************
1006 * CreateCaret (USER.163)
1008 void WINAPI
CreateCaret16( HWND16 hwnd
, HBITMAP16 bitmap
, INT16 width
, INT16 height
)
1010 CreateCaret( WIN_Handle32(hwnd
), HBITMAP_32(bitmap
), width
, height
);
1014 /*****************************************************************
1015 * DestroyCaret (USER.164)
1017 void WINAPI
DestroyCaret16(void)
1023 /*****************************************************************
1024 * SetCaretPos (USER.165)
1026 void WINAPI
SetCaretPos16( INT16 x
, INT16 y
)
1028 SetCaretPos( x
, y
);
1032 /**************************************************************************
1033 * HideCaret (USER.166)
1035 void WINAPI
HideCaret16( HWND16 hwnd
)
1037 HideCaret( WIN_Handle32(hwnd
) );
1041 /**************************************************************************
1042 * ShowCaret (USER.167)
1044 void WINAPI
ShowCaret16( HWND16 hwnd
)
1046 ShowCaret( WIN_Handle32(hwnd
) );
1050 /*****************************************************************
1051 * SetCaretBlinkTime (USER.168)
1053 void WINAPI
SetCaretBlinkTime16( UINT16 msecs
)
1055 SetCaretBlinkTime( msecs
);
1059 /*****************************************************************
1060 * GetCaretBlinkTime (USER.169)
1062 UINT16 WINAPI
GetCaretBlinkTime16(void)
1064 return GetCaretBlinkTime();
1068 /**************************************************************************
1069 * ArrangeIconicWindows (USER.170)
1071 UINT16 WINAPI
ArrangeIconicWindows16( HWND16 parent
)
1073 return ArrangeIconicWindows( WIN_Handle32(parent
) );
1077 /**************************************************************************
1078 * SwitchToThisWindow (USER.172)
1080 void WINAPI
SwitchToThisWindow16( HWND16 hwnd
, BOOL16 restore
)
1082 SwitchToThisWindow( WIN_Handle32(hwnd
), restore
);
1086 /**************************************************************************
1087 * KillSystemTimer (USER.182)
1089 BOOL16 WINAPI
KillSystemTimer16( HWND16 hwnd
, UINT16 id
)
1091 return KillSystemTimer( WIN_Handle32(hwnd
), id
);
1095 /*****************************************************************
1096 * GetCaretPos (USER.183)
1098 void WINAPI
GetCaretPos16( LPPOINT16 pt16
)
1101 if (GetCaretPos( &pt
))
1109 /**************************************************************************
1110 * SetSysModalWindow (USER.188)
1112 HWND16 WINAPI
SetSysModalWindow16( HWND16 hwnd
)
1114 HWND16 old
= hwndSysModal
;
1115 hwndSysModal
= hwnd
;
1120 /**************************************************************************
1121 * GetSysModalWindow (USER.189)
1123 HWND16 WINAPI
GetSysModalWindow16(void)
1125 return hwndSysModal
;
1129 /**************************************************************************
1130 * GetUpdateRect (USER.190)
1132 BOOL16 WINAPI
GetUpdateRect16( HWND16 hwnd
, LPRECT16 rect
, BOOL16 erase
)
1137 if (!rect
) return GetUpdateRect( WIN_Handle32(hwnd
), NULL
, erase
);
1138 ret
= GetUpdateRect( WIN_Handle32(hwnd
), &r
, erase
);
1139 rect
->left
= r
.left
;
1141 rect
->right
= r
.right
;
1142 rect
->bottom
= r
.bottom
;
1147 /**************************************************************************
1148 * ChildWindowFromPoint (USER.191)
1150 HWND16 WINAPI
ChildWindowFromPoint16( HWND16 hwndParent
, POINT16 pt
)
1156 return HWND_16( ChildWindowFromPoint( WIN_Handle32(hwndParent
), pt32
));
1160 /***********************************************************************
1161 * CascadeChildWindows (USER.198)
1163 void WINAPI
CascadeChildWindows16( HWND16 parent
, WORD action
)
1165 CascadeWindows( WIN_Handle32(parent
), action
, NULL
, 0, NULL
);
1169 /***********************************************************************
1170 * TileChildWindows (USER.199)
1172 void WINAPI
TileChildWindows16( HWND16 parent
, WORD action
)
1174 TileWindows( WIN_Handle32(parent
), action
, NULL
, 0, NULL
);
1178 /***********************************************************************
1179 * GetWindowTask (USER.224)
1181 HTASK16 WINAPI
GetWindowTask16( HWND16 hwnd
)
1183 DWORD tid
= GetWindowThreadProcessId( HWND_32(hwnd
), NULL
);
1185 return HTASK_16(tid
);
1188 /**********************************************************************
1189 * EnumTaskWindows (USER.225)
1191 BOOL16 WINAPI
EnumTaskWindows16( HTASK16 hTask
, WNDENUMPROC16 func
, LPARAM lParam
)
1193 struct wnd_enum_info info
;
1194 DWORD tid
= HTASK_32( hTask
);
1196 if (!tid
) return FALSE
;
1198 info
.param
= lParam
;
1199 return EnumThreadWindows( tid
, wnd_enum_callback
, (LPARAM
)&info
);
1203 /**************************************************************************
1204 * GetTopWindow (USER.229)
1206 HWND16 WINAPI
GetTopWindow16( HWND16 hwnd
)
1208 return HWND_16( GetTopWindow( WIN_Handle32(hwnd
) ));
1212 /**************************************************************************
1213 * GetNextWindow (USER.230)
1215 HWND16 WINAPI
GetNextWindow16( HWND16 hwnd
, WORD flag
)
1217 if ((flag
!= GW_HWNDNEXT
) && (flag
!= GW_HWNDPREV
)) return 0;
1218 return GetWindow16( hwnd
, flag
);
1222 /**************************************************************************
1223 * SetWindowPos (USER.232)
1225 BOOL16 WINAPI
SetWindowPos16( HWND16 hwnd
, HWND16 hwndInsertAfter
,
1226 INT16 x
, INT16 y
, INT16 cx
, INT16 cy
, WORD flags
)
1228 return SetWindowPos( WIN_Handle32(hwnd
), full_insert_after_hwnd(hwndInsertAfter
),
1229 x
, y
, cx
, cy
, flags
);
1233 /**************************************************************************
1234 * SetParent (USER.233)
1236 HWND16 WINAPI
SetParent16( HWND16 hwndChild
, HWND16 hwndNewParent
)
1238 return HWND_16( SetParent( WIN_Handle32(hwndChild
), WIN_Handle32(hwndNewParent
) ));
1242 /**************************************************************************
1243 * GetCapture (USER.236)
1245 HWND16 WINAPI
GetCapture16(void)
1247 return HWND_16( GetCapture() );
1251 /**************************************************************************
1252 * GetUpdateRgn (USER.237)
1254 INT16 WINAPI
GetUpdateRgn16( HWND16 hwnd
, HRGN16 hrgn
, BOOL16 erase
)
1256 return GetUpdateRgn( WIN_Handle32(hwnd
), HRGN_32(hrgn
), erase
);
1260 /**************************************************************************
1261 * ExcludeUpdateRgn (USER.238)
1263 INT16 WINAPI
ExcludeUpdateRgn16( HDC16 hdc
, HWND16 hwnd
)
1265 return ExcludeUpdateRgn( HDC_32(hdc
), WIN_Handle32(hwnd
) );
1269 /**************************************************************************
1270 * GetOpenClipboardWindow (USER.248)
1272 HWND16 WINAPI
GetOpenClipboardWindow16(void)
1274 return HWND_16( GetOpenClipboardWindow() );
1278 /*******************************************************************
1279 * MapWindowPoints (USER.258)
1281 void WINAPI
MapWindowPoints16( HWND16 hwndFrom
, HWND16 hwndTo
, LPPOINT16 lppt
, UINT16 count
)
1283 POINT buffer
[8], *ppt
= buffer
;
1286 if (count
> 8) ppt
= HeapAlloc( GetProcessHeap(), 0, count
* sizeof(*ppt
) );
1287 for (i
= 0; i
< count
; i
++)
1289 ppt
[i
].x
= lppt
[i
].x
;
1290 ppt
[i
].y
= lppt
[i
].y
;
1292 MapWindowPoints( WIN_Handle32(hwndFrom
), WIN_Handle32(hwndTo
), ppt
, count
);
1293 for (i
= 0; i
< count
; i
++)
1295 lppt
[i
].x
= ppt
[i
].x
;
1296 lppt
[i
].y
= ppt
[i
].y
;
1298 if (ppt
!= buffer
) HeapFree( GetProcessHeap(), 0, ppt
);
1302 /**************************************************************************
1303 * BeginDeferWindowPos (USER.259)
1305 HDWP16 WINAPI
BeginDeferWindowPos16( INT16 count
)
1307 return HDWP_16(BeginDeferWindowPos( count
));
1311 /**************************************************************************
1312 * DeferWindowPos (USER.260)
1314 HDWP16 WINAPI
DeferWindowPos16( HDWP16 hdwp
, HWND16 hwnd
, HWND16 hwndAfter
,
1315 INT16 x
, INT16 y
, INT16 cx
, INT16 cy
,
1318 return HDWP_16(DeferWindowPos( HDWP_32(hdwp
), WIN_Handle32(hwnd
),
1319 full_insert_after_hwnd(hwndAfter
), x
, y
, cx
, cy
, flags
));
1323 /**************************************************************************
1324 * EndDeferWindowPos (USER.261)
1326 BOOL16 WINAPI
EndDeferWindowPos16( HDWP16 hdwp
)
1328 return EndDeferWindowPos(HDWP_32(hdwp
));
1332 /**************************************************************************
1333 * GetWindow (USER.262)
1335 HWND16 WINAPI
GetWindow16( HWND16 hwnd
, WORD rel
)
1337 return HWND_16( GetWindow( WIN_Handle32(hwnd
), rel
) );
1341 /**************************************************************************
1342 * ShowOwnedPopups (USER.265)
1344 void WINAPI
ShowOwnedPopups16( HWND16 owner
, BOOL16 fShow
)
1346 ShowOwnedPopups( WIN_Handle32(owner
), fShow
);
1350 /**************************************************************************
1351 * ShowScrollBar (USER.267)
1353 void WINAPI
ShowScrollBar16( HWND16 hwnd
, INT16 nBar
, BOOL16 fShow
)
1355 ShowScrollBar( WIN_Handle32(hwnd
), nBar
, fShow
);
1359 /**************************************************************************
1360 * IsZoomed (USER.272)
1362 BOOL16 WINAPI
IsZoomed16(HWND16 hwnd
)
1364 return IsZoomed( WIN_Handle32(hwnd
) );
1368 /**************************************************************************
1369 * GetDlgCtrlID (USER.277)
1371 INT16 WINAPI
GetDlgCtrlID16( HWND16 hwnd
)
1373 return GetDlgCtrlID( WIN_Handle32(hwnd
) );
1377 /**************************************************************************
1378 * GetDesktopHwnd (USER.278)
1380 * Exactly the same thing as GetDesktopWindow(), but not documented.
1381 * Don't ask me why...
1383 HWND16 WINAPI
GetDesktopHwnd16(void)
1385 return GetDesktopWindow16();
1389 /**************************************************************************
1390 * SetSystemMenu (USER.280)
1392 BOOL16 WINAPI
SetSystemMenu16( HWND16 hwnd
, HMENU16 hMenu
)
1394 return SetSystemMenu( WIN_Handle32(hwnd
), HMENU_32(hMenu
) );
1398 /**************************************************************************
1399 * GetDesktopWindow (USER.286)
1401 HWND16 WINAPI
GetDesktopWindow16(void)
1403 return HWND_16( GetDesktopWindow() );
1407 /**************************************************************************
1408 * GetLastActivePopup (USER.287)
1410 HWND16 WINAPI
GetLastActivePopup16( HWND16 hwnd
)
1412 return HWND_16( GetLastActivePopup( WIN_Handle32(hwnd
) ));
1416 /**************************************************************************
1417 * RedrawWindow (USER.290)
1419 BOOL16 WINAPI
RedrawWindow16( HWND16 hwnd
, const RECT16
*rectUpdate
,
1420 HRGN16 hrgnUpdate
, UINT16 flags
)
1425 r
.left
= rectUpdate
->left
;
1426 r
.top
= rectUpdate
->top
;
1427 r
.right
= rectUpdate
->right
;
1428 r
.bottom
= rectUpdate
->bottom
;
1429 return RedrawWindow(WIN_Handle32(hwnd
), &r
, HRGN_32(hrgnUpdate
), flags
);
1431 return RedrawWindow(WIN_Handle32(hwnd
), NULL
, HRGN_32(hrgnUpdate
), flags
);
1435 /**************************************************************************
1436 * LockWindowUpdate (USER.294)
1438 BOOL16 WINAPI
LockWindowUpdate16( HWND16 hwnd
)
1440 return LockWindowUpdate( WIN_Handle32(hwnd
) );
1444 /**************************************************************************
1445 * ScrollWindowEx (USER.319)
1447 INT16 WINAPI
ScrollWindowEx16( HWND16 hwnd
, INT16 dx
, INT16 dy
,
1448 const RECT16
*rect
, const RECT16
*clipRect
,
1449 HRGN16 hrgnUpdate
, LPRECT16 rcUpdate
,
1452 RECT rect32
, clipRect32
, rcUpdate32
;
1457 rect32
.left
= rect
->left
;
1458 rect32
.top
= rect
->top
;
1459 rect32
.right
= rect
->right
;
1460 rect32
.bottom
= rect
->bottom
;
1464 clipRect32
.left
= clipRect
->left
;
1465 clipRect32
.top
= clipRect
->top
;
1466 clipRect32
.right
= clipRect
->right
;
1467 clipRect32
.bottom
= clipRect
->bottom
;
1469 ret
= ScrollWindowEx( WIN_Handle32(hwnd
), dx
, dy
, rect
? &rect32
: NULL
,
1470 clipRect
? &clipRect32
: NULL
, HRGN_32(hrgnUpdate
),
1471 (rcUpdate
) ? &rcUpdate32
: NULL
, flags
);
1474 rcUpdate
->left
= rcUpdate32
.left
;
1475 rcUpdate
->top
= rcUpdate32
.top
;
1476 rcUpdate
->right
= rcUpdate32
.right
;
1477 rcUpdate
->bottom
= rcUpdate32
.bottom
;
1483 /**************************************************************************
1484 * FillWindow (USER.324)
1486 void WINAPI
FillWindow16( HWND16 hwndParent
, HWND16 hwnd
, HDC16 hdc
, HBRUSH16 hbrush
)
1490 GetClientRect( WIN_Handle32(hwnd
), &rect
);
1491 DPtoLP( HDC_32(hdc
), (LPPOINT
)&rect
, 2 );
1492 rc16
.left
= rect
.left
;
1493 rc16
.top
= rect
.top
;
1494 rc16
.right
= rect
.right
;
1495 rc16
.bottom
= rect
.bottom
;
1496 PaintRect16( hwndParent
, hwnd
, hdc
, hbrush
, &rc16
);
1500 /**************************************************************************
1501 * PaintRect (USER.325)
1503 void WINAPI
PaintRect16( HWND16 hwndParent
, HWND16 hwnd
, HDC16 hdc
,
1504 HBRUSH16 hbrush
, const RECT16
*rect
)
1506 if (hbrush
<= CTLCOLOR_STATIC
)
1508 HWND parent
= WIN_Handle32(hwndParent
), hwnd32
= WIN_Handle32(hwnd
);
1510 if (!parent
) return;
1511 hbrush
= SendMessageW( parent
, WM_CTLCOLORMSGBOX
+ hbrush
, hdc
, (LPARAM
)hwnd32
);
1512 if (!hbrush
) hbrush
= DefWindowProcW( parent
, WM_CTLCOLORMSGBOX
+ hbrush
,
1513 hdc
, (LPARAM
)hwnd32
);
1515 if (hbrush
) FillRect16( hdc
, rect
, hbrush
);
1519 /**************************************************************************
1520 * GetControlBrush (USER.326)
1522 HBRUSH16 WINAPI
GetControlBrush16( HWND16 hwnd
, HDC16 hdc
, UINT16 ctlType
)
1525 HWND hwnd32
= WIN_Handle32(hwnd
);
1526 HWND parent
= GetParent( hwnd32
);
1528 if (!parent
) parent
= hwnd32
;
1529 ret
= SendMessageW( parent
, WM_CTLCOLORMSGBOX
+ ctlType
, hdc
, (LPARAM
)hwnd32
);
1530 if (!ret
) ret
= DefWindowProcW( parent
, WM_CTLCOLORMSGBOX
+ ctlType
,
1531 hdc
, (LPARAM
)hwnd32
);
1536 /**************************************************************************
1537 * GetDCEx (USER.359)
1539 HDC16 WINAPI
GetDCEx16( HWND16 hwnd
, HRGN16 hrgnClip
, DWORD flags
)
1541 return HDC_16(GetDCEx(WIN_Handle32(hwnd
), HRGN_32(hrgnClip
), flags
));
1545 /**************************************************************************
1546 * GetWindowPlacement (USER.370)
1548 BOOL16 WINAPI
GetWindowPlacement16( HWND16 hwnd
, WINDOWPLACEMENT16
*wp16
)
1550 WINDOWPLACEMENT wpl
;
1552 wpl
.length
= sizeof(wpl
);
1553 if (!GetWindowPlacement( WIN_Handle32(hwnd
), &wpl
)) return FALSE
;
1554 wp16
->length
= sizeof(*wp16
);
1555 wp16
->flags
= wpl
.flags
;
1556 wp16
->showCmd
= wpl
.showCmd
;
1557 wp16
->ptMinPosition
.x
= wpl
.ptMinPosition
.x
;
1558 wp16
->ptMinPosition
.y
= wpl
.ptMinPosition
.y
;
1559 wp16
->ptMaxPosition
.x
= wpl
.ptMaxPosition
.x
;
1560 wp16
->ptMaxPosition
.y
= wpl
.ptMaxPosition
.y
;
1561 wp16
->rcNormalPosition
.left
= wpl
.rcNormalPosition
.left
;
1562 wp16
->rcNormalPosition
.top
= wpl
.rcNormalPosition
.top
;
1563 wp16
->rcNormalPosition
.right
= wpl
.rcNormalPosition
.right
;
1564 wp16
->rcNormalPosition
.bottom
= wpl
.rcNormalPosition
.bottom
;
1569 /**************************************************************************
1570 * SetWindowPlacement (USER.371)
1572 BOOL16 WINAPI
SetWindowPlacement16( HWND16 hwnd
, const WINDOWPLACEMENT16
*wp16
)
1574 WINDOWPLACEMENT wpl
;
1576 if (!wp16
) return FALSE
;
1577 wpl
.length
= sizeof(wpl
);
1578 wpl
.flags
= wp16
->flags
;
1579 wpl
.showCmd
= wp16
->showCmd
;
1580 wpl
.ptMinPosition
.x
= wp16
->ptMinPosition
.x
;
1581 wpl
.ptMinPosition
.y
= wp16
->ptMinPosition
.y
;
1582 wpl
.ptMaxPosition
.x
= wp16
->ptMaxPosition
.x
;
1583 wpl
.ptMaxPosition
.y
= wp16
->ptMaxPosition
.y
;
1584 wpl
.rcNormalPosition
.left
= wp16
->rcNormalPosition
.left
;
1585 wpl
.rcNormalPosition
.top
= wp16
->rcNormalPosition
.top
;
1586 wpl
.rcNormalPosition
.right
= wp16
->rcNormalPosition
.right
;
1587 wpl
.rcNormalPosition
.bottom
= wp16
->rcNormalPosition
.bottom
;
1588 return SetWindowPlacement( WIN_Handle32(hwnd
), &wpl
);
1592 /***********************************************************************
1593 * RegisterClassEx (USER.397)
1595 ATOM WINAPI
RegisterClassEx16( const WNDCLASSEX16
*wc
)
1597 struct class_entry
*class;
1602 inst
= GetExePtr( wc
->hInstance
);
1603 if (!inst
) inst
= GetModuleHandle16( NULL
);
1605 wc32
.cbSize
= sizeof(wc32
);
1606 wc32
.style
= wc
->style
;
1607 wc32
.lpfnWndProc
= WINPROC_AllocProc16( wc
->lpfnWndProc
);
1608 wc32
.cbClsExtra
= wc
->cbClsExtra
;
1609 wc32
.cbWndExtra
= wc
->cbWndExtra
;
1610 wc32
.hInstance
= HINSTANCE_32(inst
);
1611 wc32
.hIcon
= get_icon_32(wc
->hIcon
);
1612 wc32
.hCursor
= get_icon_32( wc
->hCursor
);
1613 wc32
.hbrBackground
= HBRUSH_32(wc
->hbrBackground
);
1614 wc32
.lpszMenuName
= MapSL(wc
->lpszMenuName
);
1615 wc32
.lpszClassName
= MapSL(wc
->lpszClassName
);
1616 wc32
.hIconSm
= get_icon_32(wc
->hIconSm
);
1617 atom
= RegisterClassExA( &wc32
);
1618 if ((class = HeapAlloc( GetProcessHeap(), 0, sizeof(*class) )))
1622 list_add_tail( &class_list
, &class->entry
);
1628 /***********************************************************************
1629 * GetClassInfoEx (USER.398)
1631 * FIXME: this is just a guess, I have no idea if GetClassInfoEx() is the
1632 * same in Win16 as in Win32. --AJ
1634 BOOL16 WINAPI
GetClassInfoEx16( HINSTANCE16 hInst16
, SEGPTR name
, WNDCLASSEX16
*wc
)
1636 static HMODULE user32_module
;
1638 HINSTANCE hInstance
;
1641 if (!user32_module
) user32_module
= GetModuleHandleA( "user32.dll" );
1642 if (hInst16
== GetModuleHandle16("user")) hInstance
= user32_module
;
1643 else hInstance
= HINSTANCE_32(GetExePtr( hInst16
));
1645 ret
= GetClassInfoExA( hInstance
, MapSL(name
), &wc32
);
1649 wc
->lpfnWndProc
= WINPROC_GetProc16( wc32
.lpfnWndProc
, FALSE
);
1650 wc
->style
= wc32
.style
;
1651 wc
->cbClsExtra
= wc32
.cbClsExtra
;
1652 wc
->cbWndExtra
= wc32
.cbWndExtra
;
1653 wc
->hInstance
= (wc32
.hInstance
== user32_module
) ? GetModuleHandle16("user") : HINSTANCE_16(wc32
.hInstance
);
1654 wc
->hIcon
= get_icon_16( wc32
.hIcon
);
1655 wc
->hIconSm
= get_icon_16( wc32
.hIconSm
);
1656 wc
->hCursor
= get_icon_16( wc32
.hCursor
);
1657 wc
->hbrBackground
= HBRUSH_16(wc32
.hbrBackground
);
1658 wc
->lpszClassName
= 0;
1659 wc
->lpszMenuName
= MapLS(wc32
.lpszMenuName
); /* FIXME: leak */
1665 /**************************************************************************
1666 * ChildWindowFromPointEx (USER.399)
1668 HWND16 WINAPI
ChildWindowFromPointEx16( HWND16 hwndParent
, POINT16 pt
, UINT16 uFlags
)
1674 return HWND_16( ChildWindowFromPointEx( WIN_Handle32(hwndParent
), pt32
, uFlags
));
1678 /**************************************************************************
1679 * GetPriorityClipboardFormat (USER.402)
1681 INT16 WINAPI
GetPriorityClipboardFormat16( UINT16
*list
, INT16 count
)
1685 for (i
= 0; i
< count
; i
++)
1686 if (IsClipboardFormatAvailable( list
[i
] )) return list
[i
];
1691 /***********************************************************************
1692 * UnregisterClass (USER.403)
1694 BOOL16 WINAPI
UnregisterClass16( LPCSTR className
, HINSTANCE16 hInstance
)
1698 if (hInstance
== GetModuleHandle16("user")) hInstance
= 0;
1699 else hInstance
= GetExePtr( hInstance
);
1701 if ((atom
= GlobalFindAtomA( className
)))
1703 struct class_entry
*class;
1704 LIST_FOR_EACH_ENTRY( class, &class_list
, struct class_entry
, entry
)
1706 if (class->inst
!= hInstance
) continue;
1707 if (class->atom
!= atom
) continue;
1708 list_remove( &class->entry
);
1709 HeapFree( GetProcessHeap(), 0, class );
1713 return UnregisterClassA( className
, HINSTANCE_32(hInstance
) );
1717 /***********************************************************************
1718 * GetClassInfo (USER.404)
1720 BOOL16 WINAPI
GetClassInfo16( HINSTANCE16 hInst16
, SEGPTR name
, WNDCLASS16
*wc
)
1723 UINT16 ret
= GetClassInfoEx16( hInst16
, name
, &wcex
);
1727 wc
->style
= wcex
.style
;
1728 wc
->lpfnWndProc
= wcex
.lpfnWndProc
;
1729 wc
->cbClsExtra
= wcex
.cbClsExtra
;
1730 wc
->cbWndExtra
= wcex
.cbWndExtra
;
1731 wc
->hInstance
= wcex
.hInstance
;
1732 wc
->hIcon
= wcex
.hIcon
;
1733 wc
->hCursor
= wcex
.hCursor
;
1734 wc
->hbrBackground
= wcex
.hbrBackground
;
1735 wc
->lpszMenuName
= wcex
.lpszMenuName
;
1736 wc
->lpszClassName
= wcex
.lpszClassName
;
1742 /**************************************************************************
1743 * TrackPopupMenu (USER.416)
1745 BOOL16 WINAPI
TrackPopupMenu16( HMENU16 hMenu
, UINT16 wFlags
, INT16 x
, INT16 y
,
1746 INT16 nReserved
, HWND16 hwnd
, const RECT16
*lpRect
)
1751 r
.left
= lpRect
->left
;
1752 r
.top
= lpRect
->top
;
1753 r
.right
= lpRect
->right
;
1754 r
.bottom
= lpRect
->bottom
;
1756 return TrackPopupMenu( HMENU_32(hMenu
), wFlags
, x
, y
, nReserved
,
1757 WIN_Handle32(hwnd
), lpRect
? &r
: NULL
);
1761 /**************************************************************************
1762 * FindWindowEx (USER.427)
1764 HWND16 WINAPI
FindWindowEx16( HWND16 parent
, HWND16 child
, LPCSTR className
, LPCSTR title
)
1766 return HWND_16( FindWindowExA( WIN_Handle32(parent
), WIN_Handle32(child
),
1767 className
, title
));
1771 /***********************************************************************
1772 * DefFrameProc (USER.445)
1774 LRESULT WINAPI
DefFrameProc16( HWND16 hwnd
, HWND16 hwndMDIClient
,
1775 UINT16 message
, WPARAM16 wParam
, LPARAM lParam
)
1780 lParam
= (LPARAM
)MapSL(lParam
);
1786 return DefFrameProcA( WIN_Handle32(hwnd
), WIN_Handle32(hwndMDIClient
),
1787 message
, wParam
, lParam
);
1791 MDINEXTMENU next_menu
;
1792 DefFrameProcW( WIN_Handle32(hwnd
), WIN_Handle32(hwndMDIClient
),
1793 message
, wParam
, (LPARAM
)&next_menu
);
1794 return MAKELONG( HMENU_16(next_menu
.hmenuNext
), HWND_16(next_menu
.hwndNext
) );
1797 return DefWindowProc16(hwnd
, message
, wParam
, lParam
);
1802 /***********************************************************************
1803 * DefMDIChildProc (USER.447)
1805 LRESULT WINAPI
DefMDIChildProc16( HWND16 hwnd
, UINT16 message
,
1806 WPARAM16 wParam
, LPARAM lParam
)
1811 return DefMDIChildProcA( WIN_Handle32(hwnd
), message
, wParam
, (LPARAM
)MapSL(lParam
) );
1816 case WM_CHILDACTIVATE
:
1821 return DefMDIChildProcW( WIN_Handle32(hwnd
), message
, wParam
, lParam
);
1823 case WM_GETMINMAXINFO
:
1825 MINMAXINFO16
*mmi16
= MapSL(lParam
);
1828 mmi
.ptReserved
.x
= mmi16
->ptReserved
.x
;
1829 mmi
.ptReserved
.y
= mmi16
->ptReserved
.y
;
1830 mmi
.ptMaxSize
.x
= mmi16
->ptMaxSize
.x
;
1831 mmi
.ptMaxSize
.y
= mmi16
->ptMaxSize
.y
;
1832 mmi
.ptMaxPosition
.x
= mmi16
->ptMaxPosition
.x
;
1833 mmi
.ptMaxPosition
.y
= mmi16
->ptMaxPosition
.y
;
1834 mmi
.ptMinTrackSize
.x
= mmi16
->ptMinTrackSize
.x
;
1835 mmi
.ptMinTrackSize
.y
= mmi16
->ptMinTrackSize
.y
;
1836 mmi
.ptMaxTrackSize
.x
= mmi16
->ptMaxTrackSize
.x
;
1837 mmi
.ptMaxTrackSize
.y
= mmi16
->ptMaxTrackSize
.y
;
1839 DefMDIChildProcW( WIN_Handle32(hwnd
), message
, wParam
, (LPARAM
)&mmi
);
1841 mmi16
->ptReserved
.x
= mmi
.ptReserved
.x
;
1842 mmi16
->ptReserved
.y
= mmi
.ptReserved
.y
;
1843 mmi16
->ptMaxSize
.x
= mmi
.ptMaxSize
.x
;
1844 mmi16
->ptMaxSize
.y
= mmi
.ptMaxSize
.y
;
1845 mmi16
->ptMaxPosition
.x
= mmi
.ptMaxPosition
.x
;
1846 mmi16
->ptMaxPosition
.y
= mmi
.ptMaxPosition
.y
;
1847 mmi16
->ptMinTrackSize
.x
= mmi
.ptMinTrackSize
.x
;
1848 mmi16
->ptMinTrackSize
.y
= mmi
.ptMinTrackSize
.y
;
1849 mmi16
->ptMaxTrackSize
.x
= mmi
.ptMaxTrackSize
.x
;
1850 mmi16
->ptMaxTrackSize
.y
= mmi
.ptMaxTrackSize
.y
;
1855 MDINEXTMENU next_menu
;
1856 DefMDIChildProcW( WIN_Handle32(hwnd
), message
, wParam
, (LPARAM
)&next_menu
);
1857 return MAKELONG( HMENU_16(next_menu
.hmenuNext
), HWND_16(next_menu
.hwndNext
) );
1860 return DefWindowProc16(hwnd
, message
, wParam
, lParam
);
1865 /**************************************************************************
1866 * DrawAnimatedRects (USER.448)
1868 BOOL16 WINAPI
DrawAnimatedRects16( HWND16 hwnd
, INT16 idAni
,
1869 const RECT16
* lprcFrom
, const RECT16
* lprcTo
)
1871 RECT rcFrom32
, rcTo32
;
1872 rcFrom32
.left
= lprcFrom
->left
;
1873 rcFrom32
.top
= lprcFrom
->top
;
1874 rcFrom32
.right
= lprcFrom
->right
;
1875 rcFrom32
.bottom
= lprcFrom
->bottom
;
1876 rcTo32
.left
= lprcTo
->left
;
1877 rcTo32
.top
= lprcTo
->top
;
1878 rcTo32
.right
= lprcTo
->right
;
1879 rcTo32
.bottom
= lprcTo
->bottom
;
1880 return DrawAnimatedRects( WIN_Handle32(hwnd
), idAni
, &rcFrom32
, &rcTo32
);
1884 /***********************************************************************
1885 * CreateWindowEx (USER.452)
1887 HWND16 WINAPI
CreateWindowEx16( DWORD exStyle
, LPCSTR className
,
1888 LPCSTR windowName
, DWORD style
, INT16 x
,
1889 INT16 y
, INT16 width
, INT16 height
,
1890 HWND16 parent
, HMENU16 menu
,
1891 HINSTANCE16 instance
, LPVOID data
)
1897 /* Fix the coordinates */
1899 cs
.x
= (x
== CW_USEDEFAULT16
) ? CW_USEDEFAULT
: (INT
)x
;
1900 cs
.y
= (y
== CW_USEDEFAULT16
) ? CW_USEDEFAULT
: (INT
)y
;
1901 cs
.cx
= (width
== CW_USEDEFAULT16
) ? CW_USEDEFAULT
: (INT
)width
;
1902 cs
.cy
= (height
== CW_USEDEFAULT16
) ? CW_USEDEFAULT
: (INT
)height
;
1904 /* Create the window */
1906 cs
.lpCreateParams
= data
;
1907 cs
.hInstance
= HINSTANCE_32(instance
);
1908 cs
.hMenu
= HMENU_32(menu
);
1909 cs
.hwndParent
= WIN_Handle32( parent
);
1911 cs
.lpszName
= windowName
;
1912 cs
.lpszClass
= className
;
1913 cs
.dwExStyle
= exStyle
;
1916 if (!menu
&& (style
& (WS_CHILD
| WS_POPUP
)) != WS_CHILD
)
1919 HINSTANCE16 module
= GetExePtr( instance
);
1921 if (GetClassInfoA( HINSTANCE_32(module
), className
, &class ))
1922 cs
.hMenu
= HMENU_32( LoadMenu16( module
, class.lpszMenuName
));
1925 if (!IS_INTRESOURCE(className
))
1929 if (!MultiByteToWideChar( CP_ACP
, 0, className
, -1, bufferW
, ARRAY_SIZE(bufferW
)))
1931 hwnd
= create_window16( (CREATESTRUCTW
*)&cs
, bufferW
, HINSTANCE_32(instance
), FALSE
);
1935 if (!GlobalGetAtomNameA( LOWORD(className
), buffer
, sizeof(buffer
) )) return 0;
1936 cs
.lpszClass
= buffer
;
1937 hwnd
= create_window16( (CREATESTRUCTW
*)&cs
, (LPCWSTR
)className
, HINSTANCE_32(instance
), FALSE
);
1939 return HWND_16( hwnd
);
1943 /***********************************************************************
1944 * GetInternalWindowPos (USER.460)
1946 UINT16 WINAPI
GetInternalWindowPos16( HWND16 hwnd
, LPRECT16 rectWnd
, LPPOINT16 ptIcon
)
1948 WINDOWPLACEMENT16 wndpl
;
1950 if (!GetWindowPlacement16( hwnd
, &wndpl
)) return 0;
1951 if (rectWnd
) *rectWnd
= wndpl
.rcNormalPosition
;
1952 if (ptIcon
) *ptIcon
= wndpl
.ptMinPosition
;
1953 return wndpl
.showCmd
;
1957 /**************************************************************************
1958 * SetInternalWindowPos (USER.461)
1960 void WINAPI
SetInternalWindowPos16( HWND16 hwnd
, UINT16 showCmd
, LPRECT16 rect
, LPPOINT16 pt
)
1967 rc32
.left
= rect
->left
;
1968 rc32
.top
= rect
->top
;
1969 rc32
.right
= rect
->right
;
1970 rc32
.bottom
= rect
->bottom
;
1977 SetInternalWindowPos( WIN_Handle32(hwnd
), showCmd
,
1978 rect
? &rc32
: NULL
, pt
? &pt32
: NULL
);
1982 /**************************************************************************
1983 * CalcChildScroll (USER.462)
1985 void WINAPI
CalcChildScroll16( HWND16 hwnd
, WORD scroll
)
1987 CalcChildScroll( WIN_Handle32(hwnd
), scroll
);
1991 /**************************************************************************
1992 * ScrollChildren (USER.463)
1994 void WINAPI
ScrollChildren16(HWND16 hwnd
, UINT16 uMsg
, WPARAM16 wParam
, LPARAM lParam
)
1996 ScrollChildren( WIN_Handle32(hwnd
), uMsg
, wParam
, lParam
);
2000 /**************************************************************************
2001 * DragDetect (USER.465)
2003 BOOL16 WINAPI
DragDetect16( HWND16 hwnd
, POINT16 pt
)
2009 return DragDetect( WIN_Handle32(hwnd
), pt32
);
2013 /**************************************************************************
2014 * SetScrollInfo (USER.475)
2016 INT16 WINAPI
SetScrollInfo16( HWND16 hwnd
, INT16 nBar
, const SCROLLINFO
*info
, BOOL16 redraw
)
2018 return SetScrollInfo( WIN_Handle32(hwnd
), nBar
, info
, redraw
);
2022 /**************************************************************************
2023 * GetScrollInfo (USER.476)
2025 BOOL16 WINAPI
GetScrollInfo16( HWND16 hwnd
, INT16 nBar
, LPSCROLLINFO info
)
2027 return GetScrollInfo( WIN_Handle32(hwnd
), nBar
, info
);
2031 /**************************************************************************
2032 * EnableScrollBar (USER.482)
2034 BOOL16 WINAPI
EnableScrollBar16( HWND16 hwnd
, INT16 nBar
, UINT16 flags
)
2036 return EnableScrollBar( WIN_Handle32(hwnd
), nBar
, flags
);
2040 /**************************************************************************
2041 * GetShellWindow (USER.600)
2043 HWND16 WINAPI
GetShellWindow16(void)
2045 return HWND_16( GetShellWindow() );
2049 /**************************************************************************
2050 * GetForegroundWindow (USER.608)
2052 HWND16 WINAPI
GetForegroundWindow16(void)
2054 return HWND_16( GetForegroundWindow() );
2058 /**************************************************************************
2059 * SetForegroundWindow (USER.609)
2061 BOOL16 WINAPI
SetForegroundWindow16( HWND16 hwnd
)
2063 return SetForegroundWindow( WIN_Handle32(hwnd
) );
2067 /**************************************************************************
2068 * DrawCaptionTemp (USER.657)
2070 BOOL16 WINAPI
DrawCaptionTemp16( HWND16 hwnd
, HDC16 hdc
, const RECT16
*rect
,
2071 HFONT16 hFont
, HICON16 hIcon
, LPCSTR str
, UINT16 uFlags
)
2077 rect32
.left
= rect
->left
;
2078 rect32
.top
= rect
->top
;
2079 rect32
.right
= rect
->right
;
2080 rect32
.bottom
= rect
->bottom
;
2082 return DrawCaptionTempA( WIN_Handle32(hwnd
), HDC_32(hdc
),
2083 rect
? &rect32
: NULL
, HFONT_32(hFont
),
2084 get_icon_32(hIcon
), str
, uFlags
& 0x1f );
2088 /**************************************************************************
2089 * DrawCaption (USER.660)
2091 BOOL16 WINAPI
DrawCaption16( HWND16 hwnd
, HDC16 hdc
, const RECT16
*rect
, UINT16 flags
)
2097 rect32
.left
= rect
->left
;
2098 rect32
.top
= rect
->top
;
2099 rect32
.right
= rect
->right
;
2100 rect32
.bottom
= rect
->bottom
;
2102 return DrawCaption(WIN_Handle32(hwnd
), HDC_32(hdc
), rect
? &rect32
: NULL
, flags
);
2106 /**************************************************************************
2107 * GetMenuItemRect (USER.665)
2109 BOOL16 WINAPI
GetMenuItemRect16( HWND16 hwnd
, HMENU16 hMenu
, UINT16 uItem
,
2114 if (!rect
) return FALSE
;
2115 res
= GetMenuItemRect( WIN_Handle32(hwnd
), HMENU_32(hMenu
), uItem
, &r32
);
2116 rect
->left
= r32
.left
;
2117 rect
->top
= r32
.top
;
2118 rect
->right
= r32
.right
;
2119 rect
->bottom
= r32
.bottom
;
2124 /**************************************************************************
2125 * SetWindowRgn (USER.668)
2127 INT16 WINAPI
SetWindowRgn16( HWND16 hwnd
, HRGN16 hrgn
, BOOL16 redraw
)
2129 return SetWindowRgn( WIN_Handle32(hwnd
), HRGN_32(hrgn
), redraw
);
2133 /**************************************************************************
2134 * MessageBoxIndirect (USER.827)
2136 INT16 WINAPI
MessageBoxIndirect16( LPMSGBOXPARAMS16 msgbox
)
2138 char caption
[256], text
[256];
2139 MSGBOXPARAMSA msgbox32
;
2141 msgbox32
.cbSize
= msgbox
->cbSize
;
2142 msgbox32
.hwndOwner
= WIN_Handle32( msgbox
->hwndOwner
);
2143 msgbox32
.hInstance
= 0;
2144 msgbox32
.dwStyle
= msgbox
->dwStyle
;
2145 msgbox32
.lpszIcon
= NULL
;
2146 msgbox32
.dwContextHelpId
= msgbox
->dwContextHelpId
;
2147 msgbox32
.lpfnMsgBoxCallback
= msgbox
->lpfnMsgBoxCallback
;
2148 msgbox32
.dwLanguageId
= msgbox
->dwLanguageId
;
2150 if (!HIWORD(msgbox
->lpszCaption
))
2152 LoadString16( msgbox
->hInstance
, LOWORD(msgbox
->lpszCaption
), caption
, sizeof(caption
) );
2153 msgbox32
.lpszCaption
= caption
;
2155 else msgbox32
.lpszCaption
= MapSL(msgbox
->lpszCaption
);
2157 if (!HIWORD(msgbox
->lpszText
))
2159 LoadString16( msgbox
->hInstance
, LOWORD(msgbox
->lpszText
), text
, sizeof(text
) );
2160 msgbox32
.lpszText
= text
;
2162 else msgbox32
.lpszText
= MapSL(msgbox
->lpszText
);
2164 if ((msgbox
->dwStyle
& MB_ICONMASK
) == MB_USERICON
)
2166 FIXME( "user icon %s not supported\n", debugstr_a( MapSL(msgbox
->lpszIcon
) ));
2167 msgbox32
.dwStyle
&= ~MB_USERICON
;
2170 return MessageBoxIndirectA( &msgbox32
);