2 * Misc 16-bit USER functions
4 * Copyright 1993, 1996 Alexandre Julliard
5 * Copyright 2002 Patrik Stridvall
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
29 #include "wine/winuser16.h"
33 #include "user_private.h"
36 #include "wine/debug.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(user
);
40 /* handle to handle 16 conversions */
41 #define HANDLE_16(h32) (LOWORD(h32))
43 /* handle16 to handle conversions */
44 #define HANDLE_32(h16) ((HANDLE)(ULONG_PTR)(h16))
45 #define HINSTANCE_32(h16) ((HINSTANCE)(ULONG_PTR)(h16))
47 #define IS_MENU_STRING_ITEM(flags) \
48 (((flags) & (MF_STRING | MF_BITMAP | MF_OWNERDRAW | MF_SEPARATOR)) == MF_STRING)
50 /* UserSeeUserDo parameters */
51 #define USUD_LOCALALLOC 0x0001
52 #define USUD_LOCALFREE 0x0002
53 #define USUD_LOCALCOMPACT 0x0003
54 #define USUD_LOCALHEAP 0x0004
55 #define USUD_FIRSTCLASS 0x0005
57 WORD WINAPI
DestroyIcon32(HGLOBAL16
, UINT16
);
60 struct gray_string_info
62 GRAYSTRINGPROC16 proc
;
67 /* callback for 16-bit gray string proc with opaque pointer */
68 static BOOL CALLBACK
gray_string_callback( HDC hdc
, LPARAM param
, INT len
)
70 const struct gray_string_info
*info
= (struct gray_string_info
*)param
;
74 args
[3] = HDC_16(hdc
);
75 args
[2] = HIWORD(info
->param
);
76 args
[1] = LOWORD(info
->param
);
78 WOWCallback16Ex( (DWORD
)info
->proc
, WCB16_PASCAL
, sizeof(args
), args
, &ret
);
82 /* callback for 16-bit gray string proc with string pointer */
83 static BOOL CALLBACK
gray_string_callback_ptr( HDC hdc
, LPARAM param
, INT len
)
85 const struct gray_string_info
*info
;
86 char *str
= (char *)param
;
88 info
= (struct gray_string_info
*)(str
- offsetof( struct gray_string_info
, str
));
89 return gray_string_callback( hdc
, (LPARAM
)info
, len
);
92 struct draw_state_info
98 /* callback for 16-bit DrawState functions */
99 static BOOL CALLBACK
draw_state_callback( HDC hdc
, LPARAM lparam
, WPARAM wparam
, int cx
, int cy
)
101 const struct draw_state_info
*info
= (struct draw_state_info
*)lparam
;
105 args
[5] = HDC_16(hdc
);
106 args
[4] = HIWORD(info
->param
);
107 args
[3] = LOWORD(info
->param
);
111 WOWCallback16Ex( (DWORD
)info
->proc
, WCB16_PASCAL
, sizeof(args
), args
, &ret
);
116 /**********************************************************************
119 INT16 WINAPI
InitApp16( HINSTANCE16 hInstance
)
121 /* Create task message queue */
122 return (InitThreadInput16( 0, 0 ) != 0);
126 /***********************************************************************
127 * ExitWindows (USER.7)
129 BOOL16 WINAPI
ExitWindows16( DWORD dwReturnCode
, UINT16 wReserved
)
131 return ExitWindowsEx( EWX_LOGOFF
, 0xffffffff );
135 /***********************************************************************
136 * GetTimerResolution (USER.14)
138 LONG WINAPI
GetTimerResolution16(void)
144 /***********************************************************************
145 * ClipCursor (USER.16)
147 BOOL16 WINAPI
ClipCursor16( const RECT16
*rect
)
151 if (!rect
) return ClipCursor( NULL
);
152 rect32
.left
= rect
->left
;
153 rect32
.top
= rect
->top
;
154 rect32
.right
= rect
->right
;
155 rect32
.bottom
= rect
->bottom
;
156 return ClipCursor( &rect32
);
160 /***********************************************************************
161 * GetCursorPos (USER.17)
163 BOOL16 WINAPI
GetCursorPos16( POINT16
*pt
)
174 /***********************************************************************
175 * SetCursor (USER.69)
177 HCURSOR16 WINAPI
SetCursor16(HCURSOR16 hCursor
)
179 return HCURSOR_16(SetCursor(HCURSOR_32(hCursor
)));
183 /***********************************************************************
184 * SetCursorPos (USER.70)
186 void WINAPI
SetCursorPos16( INT16 x
, INT16 y
)
188 SetCursorPos( x
, y
);
192 /***********************************************************************
193 * ShowCursor (USER.71)
195 INT16 WINAPI
ShowCursor16(BOOL16 bShow
)
197 return ShowCursor(bShow
);
201 /***********************************************************************
204 void WINAPI
SetRect16( LPRECT16 rect
, INT16 left
, INT16 top
, INT16 right
, INT16 bottom
)
209 rect
->bottom
= bottom
;
213 /***********************************************************************
214 * SetRectEmpty (USER.73)
216 void WINAPI
SetRectEmpty16( LPRECT16 rect
)
218 rect
->left
= rect
->right
= rect
->top
= rect
->bottom
= 0;
222 /***********************************************************************
225 BOOL16 WINAPI
CopyRect16( RECT16
*dest
, const RECT16
*src
)
232 /***********************************************************************
233 * IsRectEmpty (USER.75)
235 * Bug compat: Windows checks for 0 or negative width/height.
237 BOOL16 WINAPI
IsRectEmpty16( const RECT16
*rect
)
239 return ((rect
->left
>= rect
->right
) || (rect
->top
>= rect
->bottom
));
243 /***********************************************************************
246 BOOL16 WINAPI
PtInRect16( const RECT16
*rect
, POINT16 pt
)
248 return ((pt
.x
>= rect
->left
) && (pt
.x
< rect
->right
) &&
249 (pt
.y
>= rect
->top
) && (pt
.y
< rect
->bottom
));
253 /***********************************************************************
254 * OffsetRect (USER.77)
256 void WINAPI
OffsetRect16( LPRECT16 rect
, INT16 x
, INT16 y
)
265 /***********************************************************************
266 * InflateRect (USER.78)
268 void WINAPI
InflateRect16( LPRECT16 rect
, INT16 x
, INT16 y
)
277 /***********************************************************************
278 * IntersectRect (USER.79)
280 BOOL16 WINAPI
IntersectRect16( LPRECT16 dest
, const RECT16
*src1
,
283 if (IsRectEmpty16(src1
) || IsRectEmpty16(src2
) ||
284 (src1
->left
>= src2
->right
) || (src2
->left
>= src1
->right
) ||
285 (src1
->top
>= src2
->bottom
) || (src2
->top
>= src1
->bottom
))
287 SetRectEmpty16( dest
);
290 dest
->left
= max( src1
->left
, src2
->left
);
291 dest
->right
= min( src1
->right
, src2
->right
);
292 dest
->top
= max( src1
->top
, src2
->top
);
293 dest
->bottom
= min( src1
->bottom
, src2
->bottom
);
298 /***********************************************************************
299 * UnionRect (USER.80)
301 BOOL16 WINAPI
UnionRect16( LPRECT16 dest
, const RECT16
*src1
,
304 if (IsRectEmpty16(src1
))
306 if (IsRectEmpty16(src2
))
308 SetRectEmpty16( dest
);
315 if (IsRectEmpty16(src2
)) *dest
= *src1
;
318 dest
->left
= min( src1
->left
, src2
->left
);
319 dest
->right
= max( src1
->right
, src2
->right
);
320 dest
->top
= min( src1
->top
, src2
->top
);
321 dest
->bottom
= max( src1
->bottom
, src2
->bottom
);
328 /***********************************************************************
331 * The Win16 variant doesn't support special color brushes like
332 * the Win32 one, despite the fact that Win16, as well as Win32,
333 * supports special background brushes for a window class.
335 INT16 WINAPI
FillRect16( HDC16 hdc
, const RECT16
*rect
, HBRUSH16 hbrush
)
339 /* coordinates are logical so we cannot fast-check 'rect',
340 * it will be done later in the PatBlt().
343 if (!(prevBrush
= SelectObject( HDC_32(hdc
), HBRUSH_32(hbrush
) ))) return 0;
344 PatBlt( HDC_32(hdc
), rect
->left
, rect
->top
,
345 rect
->right
- rect
->left
, rect
->bottom
- rect
->top
, PATCOPY
);
346 SelectObject( HDC_32(hdc
), prevBrush
);
351 /***********************************************************************
352 * InvertRect (USER.82)
354 void WINAPI
InvertRect16( HDC16 hdc
, const RECT16
*rect
)
356 PatBlt( HDC_32(hdc
), rect
->left
, rect
->top
,
357 rect
->right
- rect
->left
, rect
->bottom
- rect
->top
, DSTINVERT
);
361 /***********************************************************************
362 * FrameRect (USER.83)
364 INT16 WINAPI
FrameRect16( HDC16 hdc
, const RECT16
*rect16
, HBRUSH16 hbrush
)
368 rect
.left
= rect16
->left
;
369 rect
.top
= rect16
->top
;
370 rect
.right
= rect16
->right
;
371 rect
.bottom
= rect16
->bottom
;
372 return FrameRect( HDC_32(hdc
), &rect
, HBRUSH_32(hbrush
) );
376 /***********************************************************************
379 BOOL16 WINAPI
DrawIcon16(HDC16 hdc
, INT16 x
, INT16 y
, HICON16 hIcon
)
381 return DrawIcon(HDC_32(hdc
), x
, y
, HICON_32(hIcon
));
385 /***********************************************************************
388 INT16 WINAPI
DrawText16( HDC16 hdc
, LPCSTR str
, INT16 count
, LPRECT16 rect
, UINT16 flags
)
396 rect32
.left
= rect
->left
;
397 rect32
.top
= rect
->top
;
398 rect32
.right
= rect
->right
;
399 rect32
.bottom
= rect
->bottom
;
400 ret
= DrawTextA( HDC_32(hdc
), str
, count
, &rect32
, flags
);
401 rect
->left
= rect32
.left
;
402 rect
->top
= rect32
.top
;
403 rect
->right
= rect32
.right
;
404 rect
->bottom
= rect32
.bottom
;
406 else ret
= DrawTextA( HDC_32(hdc
), str
, count
, NULL
, flags
);
411 /***********************************************************************
414 * See "Undocumented Windows". Used by W2.0 paint.exe.
416 DWORD WINAPI
IconSize16(void)
418 return MAKELONG(GetSystemMetrics(SM_CYICON
), GetSystemMetrics(SM_CXICON
));
422 /***********************************************************************
423 * AdjustWindowRect (USER.102)
425 BOOL16 WINAPI
AdjustWindowRect16( LPRECT16 rect
, DWORD style
, BOOL16 menu
)
427 return AdjustWindowRectEx16( rect
, style
, menu
, 0 );
431 /**************************************************************************
432 * CloseClipboard (USER.138)
434 BOOL16 WINAPI
CloseClipboard16(void)
436 return CloseClipboard();
440 /**************************************************************************
441 * EmptyClipboard (USER.139)
443 BOOL16 WINAPI
EmptyClipboard16(void)
445 return EmptyClipboard();
449 /**************************************************************************
450 * SetClipboardData (USER.141)
452 HANDLE16 WINAPI
SetClipboardData16(UINT16 wFormat
, HANDLE16 hData
)
454 return HANDLE_16(SetClipboardData(wFormat
, HANDLE_32(hData
)));
458 /**************************************************************************
459 * GetClipboardData (USER.142)
461 HANDLE16 WINAPI
GetClipboardData16(UINT16 wFormat
)
463 return HANDLE_16(GetClipboardData(wFormat
));
467 /**************************************************************************
468 * CountClipboardFormats (USER.143)
470 INT16 WINAPI
CountClipboardFormats16(void)
472 return CountClipboardFormats();
476 /**************************************************************************
477 * EnumClipboardFormats (USER.144)
479 UINT16 WINAPI
EnumClipboardFormats16( UINT16 id
)
481 return EnumClipboardFormats( id
);
485 /**************************************************************************
486 * RegisterClipboardFormat (USER.145)
488 UINT16 WINAPI
RegisterClipboardFormat16( LPCSTR name
)
490 return RegisterClipboardFormatA( name
);
494 /**************************************************************************
495 * GetClipboardFormatName (USER.146)
497 INT16 WINAPI
GetClipboardFormatName16( UINT16 id
, LPSTR buffer
, INT16 maxlen
)
499 return GetClipboardFormatNameA( id
, buffer
, maxlen
);
503 /**********************************************************************
504 * CreateMenu (USER.151)
506 HMENU16 WINAPI
CreateMenu16(void)
508 return HMENU_16( CreateMenu() );
512 /**********************************************************************
513 * DestroyMenu (USER.152)
515 BOOL16 WINAPI
DestroyMenu16( HMENU16 hMenu
)
517 return DestroyMenu( HMENU_32(hMenu
) );
521 /*******************************************************************
522 * ChangeMenu (USER.153)
524 BOOL16 WINAPI
ChangeMenu16( HMENU16 hMenu
, UINT16 pos
, SEGPTR data
,
525 UINT16 id
, UINT16 flags
)
527 if (flags
& MF_APPEND
) return AppendMenu16( hMenu
, flags
& ~MF_APPEND
, id
, data
);
529 /* FIXME: Word passes the item id in 'pos' and 0 or 0xffff as id */
530 /* for MF_DELETE. We should check the parameters for all others */
531 /* MF_* actions also (anybody got a doc on ChangeMenu?). */
533 if (flags
& MF_DELETE
) return DeleteMenu16(hMenu
, pos
, flags
& ~MF_DELETE
);
534 if (flags
& MF_CHANGE
) return ModifyMenu16(hMenu
, pos
, flags
& ~MF_CHANGE
, id
, data
);
535 if (flags
& MF_REMOVE
) return RemoveMenu16(hMenu
, flags
& MF_BYPOSITION
? pos
: id
,
536 flags
& ~MF_REMOVE
);
537 /* Default: MF_INSERT */
538 return InsertMenu16( hMenu
, pos
, flags
, id
, data
);
542 /*******************************************************************
543 * CheckMenuItem (USER.154)
545 BOOL16 WINAPI
CheckMenuItem16( HMENU16 hMenu
, UINT16 id
, UINT16 flags
)
547 return CheckMenuItem( HMENU_32(hMenu
), id
, flags
);
551 /**********************************************************************
552 * EnableMenuItem (USER.155)
554 BOOL16 WINAPI
EnableMenuItem16( HMENU16 hMenu
, UINT16 wItemID
, UINT16 wFlags
)
556 return EnableMenuItem( HMENU_32(hMenu
), wItemID
, wFlags
);
560 /**********************************************************************
561 * GetSubMenu (USER.159)
563 HMENU16 WINAPI
GetSubMenu16( HMENU16 hMenu
, INT16 nPos
)
565 return HMENU_16( GetSubMenu( HMENU_32(hMenu
), nPos
) );
569 /*******************************************************************
570 * GetMenuString (USER.161)
572 INT16 WINAPI
GetMenuString16( HMENU16 hMenu
, UINT16 wItemID
,
573 LPSTR str
, INT16 nMaxSiz
, UINT16 wFlags
)
575 return GetMenuStringA( HMENU_32(hMenu
), wItemID
, str
, nMaxSiz
, wFlags
);
579 /**********************************************************************
582 BOOL16 WINAPI
WinHelp16( HWND16 hWnd
, LPCSTR lpHelpFile
, UINT16 wCommand
,
588 /* We might call WinExec() */
589 ReleaseThunkLock(&mutex_count
);
591 ret
= WinHelpA(WIN_Handle32(hWnd
), lpHelpFile
, wCommand
, (DWORD
)MapSL(dwData
));
593 RestoreThunkLock(mutex_count
);
598 /***********************************************************************
599 * LoadCursor (USER.173)
601 HCURSOR16 WINAPI
LoadCursor16(HINSTANCE16 hInstance
, LPCSTR name
)
603 return HCURSOR_16(LoadCursorA(HINSTANCE_32(hInstance
), name
));
607 /***********************************************************************
608 * LoadIcon (USER.174)
610 HICON16 WINAPI
LoadIcon16(HINSTANCE16 hInstance
, LPCSTR name
)
612 return HICON_16(LoadIconA(HINSTANCE_32(hInstance
), name
));
615 /**********************************************************************
616 * LoadBitmap (USER.175)
618 HBITMAP16 WINAPI
LoadBitmap16(HINSTANCE16 hInstance
, LPCSTR name
)
620 return HBITMAP_16(LoadBitmapA(HINSTANCE_32(hInstance
), name
));
624 /***********************************************************************
625 * GetSystemMetrics (USER.179)
627 INT16 WINAPI
GetSystemMetrics16( INT16 index
)
629 return GetSystemMetrics( index
);
633 /*************************************************************************
634 * GetSysColor (USER.180)
636 COLORREF WINAPI
GetSysColor16( INT16 index
)
638 return GetSysColor( index
);
642 /*************************************************************************
643 * SetSysColors (USER.181)
645 VOID WINAPI
SetSysColors16( INT16 count
, const INT16
*list16
, const COLORREF
*values
)
649 if ((list
= HeapAlloc( GetProcessHeap(), 0, count
* sizeof(*list
) )))
651 for (i
= 0; i
< count
; i
++) list
[i
] = list16
[i
];
652 SetSysColors( count
, list
, values
);
653 HeapFree( GetProcessHeap(), 0, list
);
658 /***********************************************************************
659 * GrayString (USER.185)
661 BOOL16 WINAPI
GrayString16( HDC16 hdc
, HBRUSH16 hbr
, GRAYSTRINGPROC16 gsprc
,
662 LPARAM lParam
, INT16 cch
, INT16 x
, INT16 y
,
667 if (!gsprc
) return GrayStringA( HDC_32(hdc
), HBRUSH_32(hbr
), NULL
,
668 (LPARAM
)MapSL(lParam
), cch
, x
, y
, cx
, cy
);
670 if (cch
== -1 || (cch
&& cx
&& cy
))
672 /* lParam can be treated as an opaque pointer */
673 struct gray_string_info info
;
677 ret
= GrayStringA( HDC_32(hdc
), HBRUSH_32(hbr
), gray_string_callback
,
678 (LPARAM
)&info
, cch
, x
, y
, cx
, cy
);
680 else /* here we need some string conversions */
682 char *str16
= MapSL(lParam
);
683 struct gray_string_info
*info
;
685 if (!cch
) cch
= strlen(str16
);
686 if (!(info
= HeapAlloc( GetProcessHeap(), 0, sizeof(*info
) + cch
))) return FALSE
;
688 info
->param
= lParam
;
689 memcpy( info
->str
, str16
, cch
);
690 ret
= GrayStringA( HDC_32(hdc
), HBRUSH_32(hbr
), gray_string_callback_ptr
,
691 (LPARAM
)info
->str
, cch
, x
, y
, cx
, cy
);
692 HeapFree( GetProcessHeap(), 0, info
);
698 /**************************************************************************
699 * IsClipboardFormatAvailable (USER.193)
701 BOOL16 WINAPI
IsClipboardFormatAvailable16( UINT16 wFormat
)
703 return IsClipboardFormatAvailable( wFormat
);
707 /***********************************************************************
708 * TabbedTextOut (USER.196)
710 LONG WINAPI
TabbedTextOut16( HDC16 hdc
, INT16 x
, INT16 y
, LPCSTR lpstr
,
711 INT16 count
, INT16 nb_tabs
, const INT16
*tabs16
, INT16 tab_org
)
714 INT i
, *tabs
= HeapAlloc( GetProcessHeap(), 0, nb_tabs
* sizeof(tabs
) );
716 for (i
= 0; i
< nb_tabs
; i
++) tabs
[i
] = tabs16
[i
];
717 ret
= TabbedTextOutA( HDC_32(hdc
), x
, y
, lpstr
, count
, nb_tabs
, tabs
, tab_org
);
718 HeapFree( GetProcessHeap(), 0, tabs
);
723 /***********************************************************************
724 * GetTabbedTextExtent (USER.197)
726 DWORD WINAPI
GetTabbedTextExtent16( HDC16 hdc
, LPCSTR lpstr
, INT16 count
,
727 INT16 nb_tabs
, const INT16
*tabs16
)
730 INT i
, *tabs
= HeapAlloc( GetProcessHeap(), 0, nb_tabs
* sizeof(tabs
) );
732 for (i
= 0; i
< nb_tabs
; i
++) tabs
[i
] = tabs16
[i
];
733 ret
= GetTabbedTextExtentA( HDC_32(hdc
), lpstr
, count
, nb_tabs
, tabs
);
734 HeapFree( GetProcessHeap(), 0, tabs
);
739 /***********************************************************************
740 * UserSeeUserDo (USER.216)
742 DWORD WINAPI
UserSeeUserDo16(WORD wReqType
, WORD wParam1
, WORD wParam2
, WORD wParam3
)
744 STACK16FRAME
* stack16
= MapSL((SEGPTR
)NtCurrentTeb()->WOW32Reserved
);
745 HANDLE16 oldDS
= stack16
->ds
;
746 DWORD ret
= (DWORD
)-1;
748 stack16
->ds
= USER_HeapSel
;
751 case USUD_LOCALALLOC
:
752 ret
= LocalAlloc16(wParam1
, wParam3
);
755 ret
= LocalFree16(wParam1
);
757 case USUD_LOCALCOMPACT
:
758 ret
= LocalCompact16(wParam3
);
763 case USUD_FIRSTCLASS
:
764 FIXME("return a pointer to the first window class.\n");
767 WARN("wReqType %04x (unknown)\n", wReqType
);
774 /*************************************************************************
775 * ScrollDC (USER.221)
777 BOOL16 WINAPI
ScrollDC16( HDC16 hdc
, INT16 dx
, INT16 dy
, const RECT16
*rect
,
778 const RECT16
*cliprc
, HRGN16 hrgnUpdate
,
781 RECT rect32
, clipRect32
, rcUpdate32
;
786 rect32
.left
= rect
->left
;
787 rect32
.top
= rect
->top
;
788 rect32
.right
= rect
->right
;
789 rect32
.bottom
= rect
->bottom
;
793 clipRect32
.left
= cliprc
->left
;
794 clipRect32
.top
= cliprc
->top
;
795 clipRect32
.right
= cliprc
->right
;
796 clipRect32
.bottom
= cliprc
->bottom
;
798 ret
= ScrollDC( HDC_32(hdc
), dx
, dy
, rect
? &rect32
: NULL
,
799 cliprc
? &clipRect32
: NULL
, HRGN_32(hrgnUpdate
),
803 rcUpdate
->left
= rcUpdate32
.left
;
804 rcUpdate
->top
= rcUpdate32
.top
;
805 rcUpdate
->right
= rcUpdate32
.right
;
806 rcUpdate
->bottom
= rcUpdate32
.bottom
;
812 /***********************************************************************
813 * GetSystemDebugState (USER.231)
815 WORD WINAPI
GetSystemDebugState16(void)
817 return 0; /* FIXME */
821 /***********************************************************************
822 * EqualRect (USER.244)
824 BOOL16 WINAPI
EqualRect16( const RECT16
* rect1
, const RECT16
* rect2
)
826 return ((rect1
->left
== rect2
->left
) && (rect1
->right
== rect2
->right
) &&
827 (rect1
->top
== rect2
->top
) && (rect1
->bottom
== rect2
->bottom
));
831 /***********************************************************************
832 * ExitWindowsExec (USER.246)
834 BOOL16 WINAPI
ExitWindowsExec16( LPCSTR lpszExe
, LPCSTR lpszParams
)
836 TRACE("Should run the following in DOS-mode: \"%s %s\"\n",
837 lpszExe
, lpszParams
);
838 return ExitWindowsEx( EWX_LOGOFF
, 0xffffffff );
842 /***********************************************************************
843 * GetCursor (USER.247)
845 HCURSOR16 WINAPI
GetCursor16(void)
847 return HCURSOR_16(GetCursor());
851 /**********************************************************************
852 * GetAsyncKeyState (USER.249)
854 INT16 WINAPI
GetAsyncKeyState16( INT16 key
)
856 return GetAsyncKeyState( key
);
860 /**********************************************************************
861 * GetMenuState (USER.250)
863 UINT16 WINAPI
GetMenuState16( HMENU16 hMenu
, UINT16 wItemID
, UINT16 wFlags
)
865 return GetMenuState( HMENU_32(hMenu
), wItemID
, wFlags
);
869 /**********************************************************************
870 * GetMenuItemCount (USER.263)
872 INT16 WINAPI
GetMenuItemCount16( HMENU16 hMenu
)
874 return GetMenuItemCount( HMENU_32(hMenu
) );
878 /**********************************************************************
879 * GetMenuItemID (USER.264)
881 UINT16 WINAPI
GetMenuItemID16( HMENU16 hMenu
, INT16 nPos
)
883 return GetMenuItemID( HMENU_32(hMenu
), nPos
);
887 /***********************************************************************
888 * GlobalAddAtom (USER.268)
890 ATOM WINAPI
GlobalAddAtom16(LPCSTR lpString
)
892 return GlobalAddAtomA(lpString
);
895 /***********************************************************************
896 * GlobalDeleteAtom (USER.269)
898 ATOM WINAPI
GlobalDeleteAtom16(ATOM nAtom
)
900 return GlobalDeleteAtom(nAtom
);
903 /***********************************************************************
904 * GlobalFindAtom (USER.270)
906 ATOM WINAPI
GlobalFindAtom16(LPCSTR lpString
)
908 return GlobalFindAtomA(lpString
);
911 /***********************************************************************
912 * GlobalGetAtomName (USER.271)
914 UINT16 WINAPI
GlobalGetAtomName16(ATOM nAtom
, LPSTR lpBuffer
, INT16 nSize
)
916 return GlobalGetAtomNameA(nAtom
, lpBuffer
, nSize
);
920 /***********************************************************************
921 * ControlPanelInfo (USER.273)
923 void WINAPI
ControlPanelInfo16( INT16 nInfoType
, WORD wData
, LPSTR lpBuffer
)
925 FIXME("(%d, %04x, %p): stub.\n", nInfoType
, wData
, lpBuffer
);
929 /***********************************************************************
930 * OldSetDeskPattern (USER.279)
932 BOOL16 WINAPI
SetDeskPattern16(void)
934 return SystemParametersInfoA( SPI_SETDESKPATTERN
, -1, NULL
, FALSE
);
938 /***********************************************************************
939 * GetSysColorBrush (USER.281)
941 HBRUSH16 WINAPI
GetSysColorBrush16( INT16 index
)
943 return HBRUSH_16( GetSysColorBrush(index
) );
947 /***********************************************************************
948 * SelectPalette (USER.282)
950 HPALETTE16 WINAPI
SelectPalette16( HDC16 hdc
, HPALETTE16 hpal
, BOOL16 bForceBackground
)
952 return HPALETTE_16( SelectPalette( HDC_32(hdc
), HPALETTE_32(hpal
), bForceBackground
));
955 /***********************************************************************
956 * RealizePalette (USER.283)
958 UINT16 WINAPI
RealizePalette16( HDC16 hdc
)
960 return UserRealizePalette( HDC_32(hdc
) );
964 /***********************************************************************
965 * GetFreeSystemResources (USER.284)
967 WORD WINAPI
GetFreeSystemResources16( WORD resType
)
969 STACK16FRAME
* stack16
= MapSL((SEGPTR
)NtCurrentTeb()->WOW32Reserved
);
970 HANDLE16 oldDS
= stack16
->ds
;
971 HINSTANCE16 gdi_inst
;
973 int userPercent
, gdiPercent
;
975 if ((gdi_inst
= LoadLibrary16( "GDI" )) < 32) return 0;
976 gdi_heap
= gdi_inst
| 7;
980 case GFSR_USERRESOURCES
:
981 stack16
->ds
= USER_HeapSel
;
982 userPercent
= (int)LocalCountFree16() * 100 / LocalHeapSize16();
987 case GFSR_GDIRESOURCES
:
988 stack16
->ds
= gdi_inst
;
989 gdiPercent
= (int)LocalCountFree16() * 100 / LocalHeapSize16();
994 case GFSR_SYSTEMRESOURCES
:
995 stack16
->ds
= USER_HeapSel
;
996 userPercent
= (int)LocalCountFree16() * 100 / LocalHeapSize16();
997 stack16
->ds
= gdi_inst
;
998 gdiPercent
= (int)LocalCountFree16() * 100 / LocalHeapSize16();
1003 userPercent
= gdiPercent
= 0;
1006 FreeLibrary16( gdi_inst
);
1007 TRACE("<- userPercent %d, gdiPercent %d\n", userPercent
, gdiPercent
);
1008 return (WORD
)min( userPercent
, gdiPercent
);
1012 /***********************************************************************
1013 * SetDeskWallPaper (USER.285)
1015 BOOL16 WINAPI
SetDeskWallPaper16( LPCSTR filename
)
1017 return SetDeskWallPaper( filename
);
1021 /***********************************************************************
1022 * GetClipCursor (USER.309)
1024 void WINAPI
GetClipCursor16( RECT16
*rect
)
1029 GetClipCursor( &rect32
);
1030 rect
->left
= rect32
.left
;
1031 rect
->top
= rect32
.top
;
1032 rect
->right
= rect32
.right
;
1033 rect
->bottom
= rect32
.bottom
;
1038 /***********************************************************************
1039 * SignalProc (USER.314)
1041 void WINAPI
SignalProc16( HANDLE16 hModule
, UINT16 code
,
1042 UINT16 uExitFn
, HINSTANCE16 hInstance
, HQUEUE16 hQueue
)
1044 if (code
== USIG16_DLL_UNLOAD
)
1046 /* HOOK_FreeModuleHooks( hModule ); */
1047 CLASS_FreeModuleClasses( hModule
);
1048 CURSORICON_FreeModuleIcons( hModule
);
1053 /***********************************************************************
1054 * SetEventHook (USER.321)
1056 * Used by Turbo Debugger for Windows
1058 FARPROC16 WINAPI
SetEventHook16(FARPROC16 lpfnEventHook
)
1060 FIXME("(lpfnEventHook=%p): stub\n", lpfnEventHook
);
1065 /**********************************************************************
1066 * EnableHardwareInput (USER.331)
1068 BOOL16 WINAPI
EnableHardwareInput16(BOOL16 bEnable
)
1070 FIXME("(%d) - stub\n", bEnable
);
1075 /***********************************************************************
1076 * IsUserIdle (USER.333)
1078 BOOL16 WINAPI
IsUserIdle16(void)
1080 if ( GetAsyncKeyState( VK_LBUTTON
) & 0x8000 )
1082 if ( GetAsyncKeyState( VK_RBUTTON
) & 0x8000 )
1084 if ( GetAsyncKeyState( VK_MBUTTON
) & 0x8000 )
1086 /* Should check for screen saver activation here ... */
1091 /**********************************************************************
1092 * LoadDIBIconHandler (USER.357)
1094 * RT_ICON resource loader, installed by USER_SignalProc when module
1097 HGLOBAL16 WINAPI
LoadDIBIconHandler16( HGLOBAL16 hMemObj
, HMODULE16 hModule
, HRSRC16 hRsrc
)
1099 /* If hResource is zero we must allocate a new memory block, if it's
1100 * non-zero but GlobalLock() returns NULL then it was discarded and
1101 * we have to recommit some memory, otherwise we just need to check
1102 * the block size. See LoadProc() in 16-bit SDK for more.
1104 FIXME( "%x %x %x: stub, not supported anymore\n", hMemObj
, hModule
, hRsrc
);
1108 /**********************************************************************
1109 * LoadDIBCursorHandler (USER.356)
1111 * RT_CURSOR resource loader. Same as above.
1113 HGLOBAL16 WINAPI
LoadDIBCursorHandler16( HGLOBAL16 hMemObj
, HMODULE16 hModule
, HRSRC16 hRsrc
)
1115 FIXME( "%x %x %x: stub, not supported anymore\n", hMemObj
, hModule
, hRsrc
);
1120 /**********************************************************************
1123 BOOL16 WINAPI
IsMenu16( HMENU16 hmenu
)
1125 return IsMenu( HMENU_32(hmenu
) );
1129 /***********************************************************************
1132 BOOL16 WINAPI
DCHook16( HDC16 hdc
, WORD code
, DWORD data
, LPARAM lParam
)
1134 FIXME( "hDC = %x, %i: stub\n", hdc
, code
);
1139 /***********************************************************************
1140 * SubtractRect (USER.373)
1142 BOOL16 WINAPI
SubtractRect16( LPRECT16 dest
, const RECT16
*src1
,
1143 const RECT16
*src2
)
1147 if (IsRectEmpty16( src1
))
1149 SetRectEmpty16( dest
);
1153 if (IntersectRect16( &tmp
, src1
, src2
))
1155 if (EqualRect16( &tmp
, dest
))
1157 SetRectEmpty16( dest
);
1160 if ((tmp
.top
== dest
->top
) && (tmp
.bottom
== dest
->bottom
))
1162 if (tmp
.left
== dest
->left
) dest
->left
= tmp
.right
;
1163 else if (tmp
.right
== dest
->right
) dest
->right
= tmp
.left
;
1165 else if ((tmp
.left
== dest
->left
) && (tmp
.right
== dest
->right
))
1167 if (tmp
.top
== dest
->top
) dest
->top
= tmp
.bottom
;
1168 else if (tmp
.bottom
== dest
->bottom
) dest
->bottom
= tmp
.top
;
1175 /**********************************************************************
1176 * SetMenuContextHelpId (USER.384)
1178 BOOL16 WINAPI
SetMenuContextHelpId16( HMENU16 hMenu
, DWORD dwContextHelpID
)
1180 return SetMenuContextHelpId( HMENU_32(hMenu
), dwContextHelpID
);
1184 /**********************************************************************
1185 * GetMenuContextHelpId (USER.385)
1187 DWORD WINAPI
GetMenuContextHelpId16( HMENU16 hMenu
)
1189 return GetMenuContextHelpId( HMENU_32(hMenu
) );
1193 /***********************************************************************
1194 * LoadImage (USER.389)
1197 HANDLE16 WINAPI
LoadImage16(HINSTANCE16 hinst
, LPCSTR name
, UINT16 type
,
1198 INT16 desiredx
, INT16 desiredy
, UINT16 loadflags
)
1200 return HANDLE_16(LoadImageA(HINSTANCE_32(hinst
), name
, type
, desiredx
,
1201 desiredy
, loadflags
));
1204 /******************************************************************************
1205 * CopyImage (USER.390) Creates new image and copies attributes to it
1208 HICON16 WINAPI
CopyImage16(HANDLE16 hnd
, UINT16 type
, INT16 desiredx
,
1209 INT16 desiredy
, UINT16 flags
)
1211 return HICON_16(CopyImage(HANDLE_32(hnd
), (UINT
)type
, (INT
)desiredx
,
1212 (INT
)desiredy
, (UINT
)flags
));
1215 /**********************************************************************
1216 * DrawIconEx (USER.394)
1218 BOOL16 WINAPI
DrawIconEx16(HDC16 hdc
, INT16 xLeft
, INT16 yTop
, HICON16 hIcon
,
1219 INT16 cxWidth
, INT16 cyWidth
, UINT16 istep
,
1220 HBRUSH16 hbr
, UINT16 flags
)
1222 return DrawIconEx(HDC_32(hdc
), xLeft
, yTop
, HICON_32(hIcon
), cxWidth
, cyWidth
,
1223 istep
, HBRUSH_32(hbr
), flags
);
1226 /**********************************************************************
1227 * GetIconInfo (USER.395)
1229 BOOL16 WINAPI
GetIconInfo16(HICON16 hIcon
, LPICONINFO16 iconinfo
)
1232 BOOL16 ret
= GetIconInfo(HICON_32(hIcon
), &ii32
);
1234 iconinfo
->fIcon
= ii32
.fIcon
;
1235 iconinfo
->xHotspot
= ii32
.xHotspot
;
1236 iconinfo
->yHotspot
= ii32
.yHotspot
;
1237 iconinfo
->hbmMask
= HBITMAP_16(ii32
.hbmMask
);
1238 iconinfo
->hbmColor
= HBITMAP_16(ii32
.hbmColor
);
1243 /***********************************************************************
1244 * FinalUserInit (USER.400)
1246 void WINAPI
FinalUserInit16( void )
1248 /* FIXME: Should chain to FinalGdiInit */
1252 /***********************************************************************
1253 * CreateCursor (USER.406)
1255 HCURSOR16 WINAPI
CreateCursor16(HINSTANCE16 hInstance
,
1256 INT16 xHotSpot
, INT16 yHotSpot
,
1257 INT16 nWidth
, INT16 nHeight
,
1258 LPCVOID lpANDbits
, LPCVOID lpXORbits
)
1260 CURSORICONINFO info
;
1262 info
.ptHotSpot
.x
= xHotSpot
;
1263 info
.ptHotSpot
.y
= yHotSpot
;
1264 info
.nWidth
= nWidth
;
1265 info
.nHeight
= nHeight
;
1266 info
.nWidthBytes
= 0;
1268 info
.bBitsPerPixel
= 1;
1270 return CreateCursorIconIndirect16(hInstance
, &info
, lpANDbits
, lpXORbits
);
1274 /***********************************************************************
1275 * InitThreadInput (USER.409)
1277 HQUEUE16 WINAPI
InitThreadInput16( WORD unknown
, WORD flags
)
1279 /* nothing to do here */
1284 /*******************************************************************
1285 * InsertMenu (USER.410)
1287 BOOL16 WINAPI
InsertMenu16( HMENU16 hMenu
, UINT16 pos
, UINT16 flags
,
1288 UINT16 id
, SEGPTR data
)
1290 UINT pos32
= (UINT
)pos
;
1291 if ((pos
== (UINT16
)-1) && (flags
& MF_BYPOSITION
)) pos32
= (UINT
)-1;
1292 if (IS_MENU_STRING_ITEM(flags
) && data
)
1293 return InsertMenuA( HMENU_32(hMenu
), pos32
, flags
, id
, MapSL(data
) );
1294 return InsertMenuA( HMENU_32(hMenu
), pos32
, flags
, id
, (LPSTR
)data
);
1298 /*******************************************************************
1299 * AppendMenu (USER.411)
1301 BOOL16 WINAPI
AppendMenu16(HMENU16 hMenu
, UINT16 flags
, UINT16 id
, SEGPTR data
)
1303 return InsertMenu16( hMenu
, -1, flags
| MF_BYPOSITION
, id
, data
);
1307 /**********************************************************************
1308 * RemoveMenu (USER.412)
1310 BOOL16 WINAPI
RemoveMenu16( HMENU16 hMenu
, UINT16 nPos
, UINT16 wFlags
)
1312 return RemoveMenu( HMENU_32(hMenu
), nPos
, wFlags
);
1316 /**********************************************************************
1317 * DeleteMenu (USER.413)
1319 BOOL16 WINAPI
DeleteMenu16( HMENU16 hMenu
, UINT16 nPos
, UINT16 wFlags
)
1321 return DeleteMenu( HMENU_32(hMenu
), nPos
, wFlags
);
1325 /*******************************************************************
1326 * ModifyMenu (USER.414)
1328 BOOL16 WINAPI
ModifyMenu16( HMENU16 hMenu
, UINT16 pos
, UINT16 flags
,
1329 UINT16 id
, SEGPTR data
)
1331 if (IS_MENU_STRING_ITEM(flags
))
1332 return ModifyMenuA( HMENU_32(hMenu
), pos
, flags
, id
, MapSL(data
) );
1333 return ModifyMenuA( HMENU_32(hMenu
), pos
, flags
, id
, (LPSTR
)data
);
1337 /**********************************************************************
1338 * CreatePopupMenu (USER.415)
1340 HMENU16 WINAPI
CreatePopupMenu16(void)
1342 return HMENU_16( CreatePopupMenu() );
1346 /**********************************************************************
1347 * SetMenuItemBitmaps (USER.418)
1349 BOOL16 WINAPI
SetMenuItemBitmaps16( HMENU16 hMenu
, UINT16 nPos
, UINT16 wFlags
,
1350 HBITMAP16 hNewUnCheck
, HBITMAP16 hNewCheck
)
1352 return SetMenuItemBitmaps( HMENU_32(hMenu
), nPos
, wFlags
,
1353 HBITMAP_32(hNewUnCheck
), HBITMAP_32(hNewCheck
) );
1357 /***********************************************************************
1358 * lstrcmp (USER.430)
1360 INT16 WINAPI
lstrcmp16( LPCSTR str1
, LPCSTR str2
)
1362 return strcmp( str1
, str2
);
1366 /***********************************************************************
1367 * AnsiUpper (USER.431)
1369 SEGPTR WINAPI
AnsiUpper16( SEGPTR strOrChar
)
1371 /* uppercase only one char if strOrChar < 0x10000 */
1372 if (HIWORD(strOrChar
))
1374 CharUpperA( MapSL(strOrChar
) );
1377 else return (SEGPTR
)CharUpperA( (LPSTR
)strOrChar
);
1381 /***********************************************************************
1382 * AnsiLower (USER.432)
1384 SEGPTR WINAPI
AnsiLower16( SEGPTR strOrChar
)
1386 /* lowercase only one char if strOrChar < 0x10000 */
1387 if (HIWORD(strOrChar
))
1389 CharLowerA( MapSL(strOrChar
) );
1392 else return (SEGPTR
)CharLowerA( (LPSTR
)strOrChar
);
1396 /***********************************************************************
1397 * AnsiUpperBuff (USER.437)
1399 UINT16 WINAPI
AnsiUpperBuff16( LPSTR str
, UINT16 len
)
1401 CharUpperBuffA( str
, len
? len
: 65536 );
1406 /***********************************************************************
1407 * AnsiLowerBuff (USER.438)
1409 UINT16 WINAPI
AnsiLowerBuff16( LPSTR str
, UINT16 len
)
1411 CharLowerBuffA( str
, len
? len
: 65536 );
1416 /*******************************************************************
1417 * InsertMenuItem (USER.441)
1421 BOOL16 WINAPI
InsertMenuItem16( HMENU16 hmenu
, UINT16 pos
, BOOL16 byposition
,
1422 const MENUITEMINFO16
*mii
)
1426 miia
.cbSize
= sizeof(miia
);
1427 miia
.fMask
= mii
->fMask
;
1428 miia
.dwTypeData
= (LPSTR
)mii
->dwTypeData
;
1429 miia
.fType
= mii
->fType
;
1430 miia
.fState
= mii
->fState
;
1431 miia
.wID
= mii
->wID
;
1432 miia
.hSubMenu
= HMENU_32(mii
->hSubMenu
);
1433 miia
.hbmpChecked
= HBITMAP_32(mii
->hbmpChecked
);
1434 miia
.hbmpUnchecked
= HBITMAP_32(mii
->hbmpUnchecked
);
1435 miia
.dwItemData
= mii
->dwItemData
;
1436 miia
.cch
= mii
->cch
;
1437 if (IS_MENU_STRING_ITEM(miia
.fType
))
1438 miia
.dwTypeData
= MapSL(mii
->dwTypeData
);
1439 return InsertMenuItemA( HMENU_32(hmenu
), pos
, byposition
, &miia
);
1443 /**********************************************************************
1444 * DrawState (USER.449)
1446 BOOL16 WINAPI
DrawState16( HDC16 hdc
, HBRUSH16 hbr
, DRAWSTATEPROC16 func
, LPARAM ldata
,
1447 WPARAM16 wdata
, INT16 x
, INT16 y
, INT16 cx
, INT16 cy
, UINT16 flags
)
1449 struct draw_state_info info
;
1450 UINT opcode
= flags
& 0xf;
1452 if (opcode
== DST_TEXT
|| opcode
== DST_PREFIXTEXT
)
1454 /* make sure DrawStateA doesn't try to use ldata as a pointer */
1455 if (!wdata
) wdata
= strlen( MapSL(ldata
) );
1459 if (!GetTextExtentPoint32A( HDC_32(hdc
), MapSL(ldata
), wdata
, &s
)) return FALSE
;
1466 return DrawStateA( HDC_32(hdc
), HBRUSH_32(hbr
), draw_state_callback
,
1467 (LPARAM
)&info
, wdata
, x
, y
, cx
, cy
, flags
);
1471 /**********************************************************************
1472 * CreateIconFromResourceEx (USER.450)
1474 * FIXME: not sure about exact parameter types
1476 HICON16 WINAPI
CreateIconFromResourceEx16(LPBYTE bits
, UINT16 cbSize
,
1477 BOOL16 bIcon
, DWORD dwVersion
,
1478 INT16 width
, INT16 height
,
1481 return HICON_16(CreateIconFromResourceEx(bits
, cbSize
, bIcon
, dwVersion
,
1482 width
, height
, cFlag
));
1486 /***********************************************************************
1487 * AdjustWindowRectEx (USER.454)
1489 BOOL16 WINAPI
AdjustWindowRectEx16( LPRECT16 rect
, DWORD style
, BOOL16 menu
, DWORD exStyle
)
1494 rect32
.left
= rect
->left
;
1495 rect32
.top
= rect
->top
;
1496 rect32
.right
= rect
->right
;
1497 rect32
.bottom
= rect
->bottom
;
1498 ret
= AdjustWindowRectEx( &rect32
, style
, menu
, exStyle
);
1499 rect
->left
= rect32
.left
;
1500 rect
->top
= rect32
.top
;
1501 rect
->right
= rect32
.right
;
1502 rect
->bottom
= rect32
.bottom
;
1507 /***********************************************************************
1508 * DestroyIcon (USER.457)
1510 BOOL16 WINAPI
DestroyIcon16(HICON16 hIcon
)
1512 return DestroyIcon32(hIcon
, 0);
1515 /***********************************************************************
1516 * DestroyCursor (USER.458)
1518 BOOL16 WINAPI
DestroyCursor16(HCURSOR16 hCursor
)
1520 return DestroyIcon32(hCursor
, 0);
1523 /*******************************************************************
1524 * DRAG_QueryUpdate16
1526 * Recursively find a child that contains spDragInfo->pt point
1527 * and send WM_QUERYDROPOBJECT. Helper for DragObject16.
1529 static BOOL
DRAG_QueryUpdate16( HWND hQueryWnd
, SEGPTR spDragInfo
)
1534 LPDRAGINFO16 ptrDragInfo
= MapSL(spDragInfo
);
1538 if (!IsWindowEnabled(hQueryWnd
)) return FALSE
;
1540 old_pt
.x
= ptrDragInfo
->pt
.x
;
1541 old_pt
.y
= ptrDragInfo
->pt
.y
;
1543 ScreenToClient( hQueryWnd
, &pt
);
1544 child
= ChildWindowFromPointEx( hQueryWnd
, pt
, CWP_SKIPINVISIBLE
);
1545 if (!child
) return FALSE
;
1547 if (child
!= hQueryWnd
)
1550 if (DRAG_QueryUpdate16( child
, spDragInfo
)) return TRUE
;
1554 GetClientRect( hQueryWnd
, &tempRect
);
1555 wParam
= !PtInRect( &tempRect
, pt
);
1558 ptrDragInfo
->pt
.x
= pt
.x
;
1559 ptrDragInfo
->pt
.y
= pt
.y
;
1560 ptrDragInfo
->hScope
= HWND_16(hQueryWnd
);
1562 bResult
= SendMessage16( HWND_16(hQueryWnd
), WM_QUERYDROPOBJECT
, wParam
, spDragInfo
);
1566 ptrDragInfo
->pt
.x
= old_pt
.x
;
1567 ptrDragInfo
->pt
.y
= old_pt
.y
;
1573 /******************************************************************************
1574 * DragObject (USER.464)
1576 DWORD WINAPI
DragObject16( HWND16 hwndScope
, HWND16 hWnd
, UINT16 wObj
,
1577 HANDLE16 hOfStruct
, WORD szList
, HCURSOR16 hCursor
)
1580 LPDRAGINFO16 lpDragInfo
;
1582 HCURSOR hOldCursor
=0, hBummer
=0;
1583 HGLOBAL16 hDragInfo
= GlobalAlloc16( GMEM_SHARE
| GMEM_ZEROINIT
, 2*sizeof(DRAGINFO16
));
1584 HCURSOR hCurrentCursor
= 0;
1585 HWND16 hCurrentWnd
= 0;
1587 lpDragInfo
= (LPDRAGINFO16
) GlobalLock16(hDragInfo
);
1588 spDragInfo
= WOWGlobalLock16(hDragInfo
);
1590 if( !lpDragInfo
|| !spDragInfo
) return 0L;
1592 if (!(hBummer
= LoadCursorA(0, MAKEINTRESOURCEA(OCR_NO
))))
1594 GlobalFree16(hDragInfo
);
1598 if(hCursor
) hOldCursor
= SetCursor(HCURSOR_32(hCursor
));
1600 lpDragInfo
->hWnd
= hWnd
;
1601 lpDragInfo
->hScope
= 0;
1602 lpDragInfo
->wFlags
= wObj
;
1603 lpDragInfo
->hList
= szList
; /* near pointer! */
1604 lpDragInfo
->hOfStruct
= hOfStruct
;
1607 SetCapture( HWND_32(hWnd
) );
1612 GetMessageW( &msg
, 0, WM_MOUSEFIRST
, WM_MOUSELAST
);
1614 *(lpDragInfo
+1) = *lpDragInfo
;
1616 lpDragInfo
->pt
.x
= msg
.pt
.x
;
1617 lpDragInfo
->pt
.y
= msg
.pt
.y
;
1619 /* update DRAGINFO struct */
1620 if( DRAG_QueryUpdate16(WIN_Handle32(hwndScope
), spDragInfo
) > 0 )
1621 hCurrentCursor
= HCURSOR_32(hCursor
);
1624 hCurrentCursor
= hBummer
;
1625 lpDragInfo
->hScope
= 0;
1627 if( hCurrentCursor
)
1628 SetCursor(hCurrentCursor
);
1630 /* send WM_DRAGLOOP */
1631 SendMessage16( hWnd
, WM_DRAGLOOP
, (WPARAM16
)(hCurrentCursor
!= hBummer
),
1632 (LPARAM
) spDragInfo
);
1633 /* send WM_DRAGSELECT or WM_DRAGMOVE */
1634 if( hCurrentWnd
!= lpDragInfo
->hScope
)
1637 SendMessage16( hCurrentWnd
, WM_DRAGSELECT
, 0,
1638 (LPARAM
)MAKELONG(LOWORD(spDragInfo
)+sizeof(DRAGINFO16
),
1639 HIWORD(spDragInfo
)) );
1640 hCurrentWnd
= lpDragInfo
->hScope
;
1642 SendMessage16( hCurrentWnd
, WM_DRAGSELECT
, 1, (LPARAM
)spDragInfo
);
1646 SendMessage16( hCurrentWnd
, WM_DRAGMOVE
, 0, (LPARAM
)spDragInfo
);
1648 } while( msg
.message
!= WM_LBUTTONUP
&& msg
.message
!= WM_NCLBUTTONUP
);
1651 ShowCursor( FALSE
);
1653 if( hCursor
) SetCursor(hOldCursor
);
1655 if( hCurrentCursor
!= hBummer
)
1656 msg
.lParam
= SendMessage16( lpDragInfo
->hScope
, WM_DROPOBJECT
,
1657 (WPARAM16
)hWnd
, (LPARAM
)spDragInfo
);
1660 GlobalFree16(hDragInfo
);
1662 return (DWORD
)(msg
.lParam
);
1666 /***********************************************************************
1667 * DrawFocusRect (USER.466)
1669 void WINAPI
DrawFocusRect16( HDC16 hdc
, const RECT16
* rc
)
1673 rect32
.left
= rc
->left
;
1674 rect32
.top
= rc
->top
;
1675 rect32
.right
= rc
->right
;
1676 rect32
.bottom
= rc
->bottom
;
1677 DrawFocusRect( HDC_32(hdc
), &rect32
);
1681 /***********************************************************************
1682 * AnsiNext (USER.472)
1684 SEGPTR WINAPI
AnsiNext16(SEGPTR current
)
1686 char *ptr
= MapSL(current
);
1687 return current
+ (CharNextA(ptr
) - ptr
);
1691 /***********************************************************************
1692 * AnsiPrev (USER.473)
1694 SEGPTR WINAPI
AnsiPrev16( LPCSTR start
, SEGPTR current
)
1696 char *ptr
= MapSL(current
);
1697 return current
- (ptr
- CharPrevA( start
, ptr
));
1701 /***********************************************************************
1702 * FormatMessage (USER.606)
1704 DWORD WINAPI
FormatMessage16(
1706 SEGPTR lpSource
, /* [in] NOTE: not always a valid pointer */
1709 LPSTR lpBuffer
, /* [out] NOTE: *((HLOCAL16*)) for FORMAT_MESSAGE_ALLOCATE_BUFFER*/
1711 LPDWORD args
) /* [in] NOTE: va_list *args */
1714 /* This implementation is completely dependent on the format of the va_list on x86 CPUs */
1718 DWORD width
= dwFlags
& FORMAT_MESSAGE_MAX_WIDTH_MASK
;
1720 LPSTR allocstring
= NULL
;
1722 TRACE("(0x%x,%x,%d,0x%x,%p,%d,%p)\n",
1723 dwFlags
,lpSource
,dwMessageId
,dwLanguageId
,lpBuffer
,nSize
,args
);
1724 if ((dwFlags
& FORMAT_MESSAGE_FROM_SYSTEM
)
1725 && (dwFlags
& FORMAT_MESSAGE_FROM_HMODULE
)) return 0;
1726 if ((dwFlags
& FORMAT_MESSAGE_FROM_STRING
)
1727 &&((dwFlags
& FORMAT_MESSAGE_FROM_SYSTEM
)
1728 || (dwFlags
& FORMAT_MESSAGE_FROM_HMODULE
))) return 0;
1730 if (width
&& width
!= FORMAT_MESSAGE_MAX_WIDTH_MASK
)
1731 FIXME("line wrapping (%u) not supported.\n", width
);
1733 if (dwFlags
& FORMAT_MESSAGE_FROM_STRING
)
1735 char *source
= MapSL(lpSource
);
1736 from
= HeapAlloc( GetProcessHeap(), 0, strlen(source
)+1 );
1737 strcpy( from
, source
);
1739 else if (dwFlags
& FORMAT_MESSAGE_FROM_SYSTEM
) {
1740 from
= HeapAlloc( GetProcessHeap(),0,200 );
1741 sprintf(from
,"Systemmessage, messageid = 0x%08x\n",dwMessageId
);
1743 else if (dwFlags
& FORMAT_MESSAGE_FROM_HMODULE
) {
1745 HINSTANCE16 hinst16
= ((HINSTANCE16
)lpSource
& 0xffff);
1747 dwMessageId
&= 0xFFFF;
1748 bufsize
=LoadString16(hinst16
,dwMessageId
,NULL
,0);
1750 from
= HeapAlloc( GetProcessHeap(), 0, bufsize
+1);
1751 LoadString16(hinst16
,dwMessageId
,from
,bufsize
+1);
1754 target
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, 100);
1758 #define ADD_TO_T(c) \
1760 if (t-target == talloced) {\
1761 target = HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,target,talloced*2);\
1762 t = target+talloced;\
1768 while (*f
&& !eos
) {
1771 char *fmtstr
,*x
,*lastf
;
1772 DWORD
*argliststart
;
1782 case '1':case '2':case '3':case '4':case '5':
1783 case '6':case '7':case '8':case '9':
1786 case '0':case '1':case '2':case '3':
1787 case '4':case '5':case '6':case '7':
1790 insertnr
=insertnr
*10+*f
-'0';
1799 if (NULL
!=(x
=strchr(f
,'!'))) {
1801 fmtstr
=HeapAlloc(GetProcessHeap(),0,strlen(f
)+2);
1802 sprintf(fmtstr
,"%%%s",f
);
1805 fmtstr
=HeapAlloc(GetProcessHeap(),0,strlen(f
)+2);
1806 sprintf(fmtstr
,"%%%s",f
);
1807 f
+=strlen(f
); /*at \0*/
1813 fmtstr
=HeapAlloc( GetProcessHeap(), 0, 3 );
1814 strcpy( fmtstr
, "%s" );
1819 LPSTR b
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sz
= 100);
1821 argliststart
=args
+insertnr
-1;
1823 /* CMF - This makes a BIG assumption about va_list */
1824 while ((ret
= vsnprintf(b
, sz
, fmtstr
, (va_list) argliststart
) < 0) || (ret
>= sz
)) {
1825 sz
= (ret
== -1 ? sz
+ 100 : ret
+ 1);
1826 b
= HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, b
, sz
);
1828 for (x
=b
; *x
; x
++) ADD_TO_T(*x
);
1829 HeapFree(GetProcessHeap(), 0, b
);
1831 /* NULL args - copy formatstr
1834 while ((lastf
<f
)&&(*lastf
)) {
1838 HeapFree(GetProcessHeap(),0,fmtstr
);
1840 case '0': /* Just stop processing format string */
1844 case 'n': /* 16 bit version just outputs 'n' */
1849 } else { /* '\n' or '\r' gets mapped to "\r\n" */
1850 if(*f
== '\n' || *f
== '\r') {
1854 if(*f
++ == '\r' && *f
== '\n')
1864 talloced
= strlen(target
)+1;
1865 if (nSize
&& talloced
<nSize
) {
1866 target
= HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,target
,nSize
);
1868 TRACE("-- %s\n",debugstr_a(target
));
1869 if (dwFlags
& FORMAT_MESSAGE_ALLOCATE_BUFFER
) {
1870 /* nSize is the MINIMUM size */
1871 HLOCAL16 h
= LocalAlloc16(LPTR
,talloced
);
1872 SEGPTR ptr
= LocalLock16(h
);
1873 allocstring
= MapSL( ptr
);
1874 memcpy( allocstring
,target
,talloced
);
1876 *((HLOCAL16
*)lpBuffer
) = h
;
1878 lstrcpynA(lpBuffer
,target
,nSize
);
1879 HeapFree(GetProcessHeap(),0,target
);
1880 HeapFree(GetProcessHeap(),0,from
);
1881 return (dwFlags
& FORMAT_MESSAGE_ALLOCATE_BUFFER
) ?
1882 strlen(allocstring
):
1886 #endif /* __i386__ */
1891 /***********************************************************************
1892 * ChangeDisplaySettings (USER.620)
1894 LONG WINAPI
ChangeDisplaySettings16( LPDEVMODEA devmode
, DWORD flags
)
1896 return ChangeDisplaySettingsA( devmode
, flags
);
1900 /***********************************************************************
1901 * EnumDisplaySettings (USER.621)
1903 BOOL16 WINAPI
EnumDisplaySettings16( LPCSTR name
, DWORD n
, LPDEVMODEA devmode
)
1905 return EnumDisplaySettingsA( name
, n
, devmode
);
1908 /**********************************************************************
1909 * DrawFrameControl (USER.656)
1911 BOOL16 WINAPI
DrawFrameControl16( HDC16 hdc
, LPRECT16 rc
, UINT16 uType
, UINT16 uState
)
1916 rect32
.left
= rc
->left
;
1917 rect32
.top
= rc
->top
;
1918 rect32
.right
= rc
->right
;
1919 rect32
.bottom
= rc
->bottom
;
1920 ret
= DrawFrameControl( HDC_32(hdc
), &rect32
, uType
, uState
);
1921 rc
->left
= rect32
.left
;
1922 rc
->top
= rect32
.top
;
1923 rc
->right
= rect32
.right
;
1924 rc
->bottom
= rect32
.bottom
;
1928 /**********************************************************************
1929 * DrawEdge (USER.659)
1931 BOOL16 WINAPI
DrawEdge16( HDC16 hdc
, LPRECT16 rc
, UINT16 edge
, UINT16 flags
)
1936 rect32
.left
= rc
->left
;
1937 rect32
.top
= rc
->top
;
1938 rect32
.right
= rc
->right
;
1939 rect32
.bottom
= rc
->bottom
;
1940 ret
= DrawEdge( HDC_32(hdc
), &rect32
, edge
, flags
);
1941 rc
->left
= rect32
.left
;
1942 rc
->top
= rect32
.top
;
1943 rc
->right
= rect32
.right
;
1944 rc
->bottom
= rect32
.bottom
;
1948 /**********************************************************************
1949 * CheckMenuRadioItem (USER.666)
1951 BOOL16 WINAPI
CheckMenuRadioItem16(HMENU16 hMenu
, UINT16 first
, UINT16 last
,
1952 UINT16 check
, BOOL16 bypos
)
1954 return CheckMenuRadioItem( HMENU_32(hMenu
), first
, last
, check
, bypos
);