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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #include "wine/winuser16.h"
31 #include "user_private.h"
34 #include "cursoricon.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(user
);
39 /* handle to handle 16 conversions */
40 #define HANDLE_16(h32) (LOWORD(h32))
42 /* handle16 to handle conversions */
43 #define HANDLE_32(h16) ((HANDLE)(ULONG_PTR)(h16))
44 #define HINSTANCE_32(h16) ((HINSTANCE)(ULONG_PTR)(h16))
46 #define IS_MENU_STRING_ITEM(flags) \
47 (((flags) & (MF_STRING | MF_BITMAP | MF_OWNERDRAW | MF_SEPARATOR)) == MF_STRING)
49 /* UserSeeUserDo parameters */
50 #define USUD_LOCALALLOC 0x0001
51 #define USUD_LOCALFREE 0x0002
52 #define USUD_LOCALCOMPACT 0x0003
53 #define USUD_LOCALHEAP 0x0004
54 #define USUD_FIRSTCLASS 0x0005
56 WORD WINAPI
DestroyIcon32(HGLOBAL16
, UINT16
);
59 struct gray_string_info
61 GRAYSTRINGPROC16 proc
;
66 /* callback for 16-bit gray string proc with opaque pointer */
67 static BOOL CALLBACK
gray_string_callback( HDC hdc
, LPARAM param
, INT len
)
69 const struct gray_string_info
*info
= (struct gray_string_info
*)param
;
73 args
[3] = HDC_16(hdc
);
74 args
[2] = HIWORD(info
->param
);
75 args
[1] = LOWORD(info
->param
);
77 WOWCallback16Ex( (DWORD
)info
->proc
, WCB16_PASCAL
, sizeof(args
), args
, &ret
);
81 /* callback for 16-bit gray string proc with string pointer */
82 static BOOL CALLBACK
gray_string_callback_ptr( HDC hdc
, LPARAM param
, INT len
)
84 const struct gray_string_info
*info
;
85 char *str
= (char *)param
;
87 info
= (struct gray_string_info
*)(str
- offsetof( struct gray_string_info
, str
));
88 return gray_string_callback( hdc
, (LPARAM
)info
, len
);
91 struct draw_state_info
97 /* callback for 16-bit DrawState functions */
98 static BOOL CALLBACK
draw_state_callback( HDC hdc
, LPARAM lparam
, WPARAM wparam
, int cx
, int cy
)
100 const struct draw_state_info
*info
= (struct draw_state_info
*)lparam
;
104 args
[5] = HDC_16(hdc
);
105 args
[4] = HIWORD(info
->param
);
106 args
[3] = LOWORD(info
->param
);
110 WOWCallback16Ex( (DWORD
)info
->proc
, WCB16_PASCAL
, sizeof(args
), args
, &ret
);
115 /**********************************************************************
118 INT16 WINAPI
InitApp16( HINSTANCE16 hInstance
)
120 /* Create task message queue */
121 return (InitThreadInput16( 0, 0 ) != 0);
125 /***********************************************************************
126 * ExitWindows (USER.7)
128 BOOL16 WINAPI
ExitWindows16( DWORD dwReturnCode
, UINT16 wReserved
)
130 return ExitWindowsEx( EWX_LOGOFF
, 0xffffffff );
134 /***********************************************************************
135 * GetTimerResolution (USER.14)
137 LONG WINAPI
GetTimerResolution16(void)
143 /***********************************************************************
144 * ClipCursor (USER.16)
146 BOOL16 WINAPI
ClipCursor16( const RECT16
*rect
)
150 if (!rect
) return ClipCursor( NULL
);
151 rect32
.left
= rect
->left
;
152 rect32
.top
= rect
->top
;
153 rect32
.right
= rect
->right
;
154 rect32
.bottom
= rect
->bottom
;
155 return ClipCursor( &rect32
);
159 /***********************************************************************
160 * GetCursorPos (USER.17)
162 BOOL16 WINAPI
GetCursorPos16( POINT16
*pt
)
173 /***********************************************************************
174 * SetCursor (USER.69)
176 HCURSOR16 WINAPI
SetCursor16(HCURSOR16 hCursor
)
178 return HCURSOR_16(SetCursor(HCURSOR_32(hCursor
)));
182 /***********************************************************************
183 * SetCursorPos (USER.70)
185 void WINAPI
SetCursorPos16( INT16 x
, INT16 y
)
187 SetCursorPos( x
, y
);
191 /***********************************************************************
192 * ShowCursor (USER.71)
194 INT16 WINAPI
ShowCursor16(BOOL16 bShow
)
196 return ShowCursor(bShow
);
200 /***********************************************************************
203 void WINAPI
SetRect16( LPRECT16 rect
, INT16 left
, INT16 top
, INT16 right
, INT16 bottom
)
208 rect
->bottom
= bottom
;
212 /***********************************************************************
213 * SetRectEmpty (USER.73)
215 void WINAPI
SetRectEmpty16( LPRECT16 rect
)
217 rect
->left
= rect
->right
= rect
->top
= rect
->bottom
= 0;
221 /***********************************************************************
224 BOOL16 WINAPI
CopyRect16( RECT16
*dest
, const RECT16
*src
)
231 /***********************************************************************
232 * IsRectEmpty (USER.75)
234 * Bug compat: Windows checks for 0 or negative width/height.
236 BOOL16 WINAPI
IsRectEmpty16( const RECT16
*rect
)
238 return ((rect
->left
>= rect
->right
) || (rect
->top
>= rect
->bottom
));
242 /***********************************************************************
245 BOOL16 WINAPI
PtInRect16( const RECT16
*rect
, POINT16 pt
)
247 return ((pt
.x
>= rect
->left
) && (pt
.x
< rect
->right
) &&
248 (pt
.y
>= rect
->top
) && (pt
.y
< rect
->bottom
));
252 /***********************************************************************
253 * OffsetRect (USER.77)
255 void WINAPI
OffsetRect16( LPRECT16 rect
, INT16 x
, INT16 y
)
264 /***********************************************************************
265 * InflateRect (USER.78)
267 void WINAPI
InflateRect16( LPRECT16 rect
, INT16 x
, INT16 y
)
276 /***********************************************************************
277 * IntersectRect (USER.79)
279 BOOL16 WINAPI
IntersectRect16( LPRECT16 dest
, const RECT16
*src1
,
282 if (IsRectEmpty16(src1
) || IsRectEmpty16(src2
) ||
283 (src1
->left
>= src2
->right
) || (src2
->left
>= src1
->right
) ||
284 (src1
->top
>= src2
->bottom
) || (src2
->top
>= src1
->bottom
))
286 SetRectEmpty16( dest
);
289 dest
->left
= max( src1
->left
, src2
->left
);
290 dest
->right
= min( src1
->right
, src2
->right
);
291 dest
->top
= max( src1
->top
, src2
->top
);
292 dest
->bottom
= min( src1
->bottom
, src2
->bottom
);
297 /***********************************************************************
298 * UnionRect (USER.80)
300 BOOL16 WINAPI
UnionRect16( LPRECT16 dest
, const RECT16
*src1
,
303 if (IsRectEmpty16(src1
))
305 if (IsRectEmpty16(src2
))
307 SetRectEmpty16( dest
);
314 if (IsRectEmpty16(src2
)) *dest
= *src1
;
317 dest
->left
= min( src1
->left
, src2
->left
);
318 dest
->right
= max( src1
->right
, src2
->right
);
319 dest
->top
= min( src1
->top
, src2
->top
);
320 dest
->bottom
= max( src1
->bottom
, src2
->bottom
);
327 /***********************************************************************
330 * The Win16 variant doesn't support special color brushes like
331 * the Win32 one, despite the fact that Win16, as well as Win32,
332 * supports special background brushes for a window class.
334 INT16 WINAPI
FillRect16( HDC16 hdc
, const RECT16
*rect
, HBRUSH16 hbrush
)
338 /* coordinates are logical so we cannot fast-check 'rect',
339 * it will be done later in the PatBlt().
342 if (!(prevBrush
= SelectObject( HDC_32(hdc
), HBRUSH_32(hbrush
) ))) return 0;
343 PatBlt( HDC_32(hdc
), rect
->left
, rect
->top
,
344 rect
->right
- rect
->left
, rect
->bottom
- rect
->top
, PATCOPY
);
345 SelectObject( HDC_32(hdc
), prevBrush
);
350 /***********************************************************************
351 * InvertRect (USER.82)
353 void WINAPI
InvertRect16( HDC16 hdc
, const RECT16
*rect
)
355 PatBlt( HDC_32(hdc
), rect
->left
, rect
->top
,
356 rect
->right
- rect
->left
, rect
->bottom
- rect
->top
, DSTINVERT
);
360 /***********************************************************************
361 * FrameRect (USER.83)
363 INT16 WINAPI
FrameRect16( HDC16 hdc
, const RECT16
*rect16
, HBRUSH16 hbrush
)
367 rect
.left
= rect16
->left
;
368 rect
.top
= rect16
->top
;
369 rect
.right
= rect16
->right
;
370 rect
.bottom
= rect16
->bottom
;
371 return FrameRect( HDC_32(hdc
), &rect
, HBRUSH_32(hbrush
) );
375 /***********************************************************************
378 BOOL16 WINAPI
DrawIcon16(HDC16 hdc
, INT16 x
, INT16 y
, HICON16 hIcon
)
380 return DrawIcon(HDC_32(hdc
), x
, y
, HICON_32(hIcon
));
384 /***********************************************************************
387 INT16 WINAPI
DrawText16( HDC16 hdc
, LPCSTR str
, INT16 count
, LPRECT16 rect
, UINT16 flags
)
395 rect32
.left
= rect
->left
;
396 rect32
.top
= rect
->top
;
397 rect32
.right
= rect
->right
;
398 rect32
.bottom
= rect
->bottom
;
399 ret
= DrawTextA( HDC_32(hdc
), str
, count
, &rect32
, flags
);
400 rect
->left
= rect32
.left
;
401 rect
->top
= rect32
.top
;
402 rect
->right
= rect32
.right
;
403 rect
->bottom
= rect32
.bottom
;
405 else ret
= DrawTextA( HDC_32(hdc
), str
, count
, NULL
, flags
);
410 /***********************************************************************
413 * See "Undocumented Windows". Used by W2.0 paint.exe.
415 DWORD WINAPI
IconSize16(void)
417 return MAKELONG(GetSystemMetrics(SM_CYICON
), GetSystemMetrics(SM_CXICON
));
421 /***********************************************************************
422 * AdjustWindowRect (USER.102)
424 BOOL16 WINAPI
AdjustWindowRect16( LPRECT16 rect
, DWORD style
, BOOL16 menu
)
426 return AdjustWindowRectEx16( rect
, style
, menu
, 0 );
430 /**************************************************************************
431 * CloseClipboard (USER.138)
433 BOOL16 WINAPI
CloseClipboard16(void)
435 return CloseClipboard();
439 /**************************************************************************
440 * EmptyClipboard (USER.139)
442 BOOL16 WINAPI
EmptyClipboard16(void)
444 return EmptyClipboard();
448 /**************************************************************************
449 * CountClipboardFormats (USER.143)
451 INT16 WINAPI
CountClipboardFormats16(void)
453 return CountClipboardFormats();
457 /**************************************************************************
458 * EnumClipboardFormats (USER.144)
460 UINT16 WINAPI
EnumClipboardFormats16( UINT16 id
)
462 return EnumClipboardFormats( id
);
466 /**************************************************************************
467 * RegisterClipboardFormat (USER.145)
469 UINT16 WINAPI
RegisterClipboardFormat16( LPCSTR name
)
471 return RegisterClipboardFormatA( name
);
475 /**************************************************************************
476 * GetClipboardFormatName (USER.146)
478 INT16 WINAPI
GetClipboardFormatName16( UINT16 id
, LPSTR buffer
, INT16 maxlen
)
480 return GetClipboardFormatNameA( id
, buffer
, maxlen
);
484 /**********************************************************************
485 * CreateMenu (USER.151)
487 HMENU16 WINAPI
CreateMenu16(void)
489 return HMENU_16( CreateMenu() );
493 /**********************************************************************
494 * DestroyMenu (USER.152)
496 BOOL16 WINAPI
DestroyMenu16( HMENU16 hMenu
)
498 return DestroyMenu( HMENU_32(hMenu
) );
502 /*******************************************************************
503 * ChangeMenu (USER.153)
505 BOOL16 WINAPI
ChangeMenu16( HMENU16 hMenu
, UINT16 pos
, SEGPTR data
,
506 UINT16 id
, UINT16 flags
)
508 if (flags
& MF_APPEND
) return AppendMenu16( hMenu
, flags
& ~MF_APPEND
, id
, data
);
510 /* FIXME: Word passes the item id in 'pos' and 0 or 0xffff as id */
511 /* for MF_DELETE. We should check the parameters for all others */
512 /* MF_* actions also (anybody got a doc on ChangeMenu?). */
514 if (flags
& MF_DELETE
) return DeleteMenu16(hMenu
, pos
, flags
& ~MF_DELETE
);
515 if (flags
& MF_CHANGE
) return ModifyMenu16(hMenu
, pos
, flags
& ~MF_CHANGE
, id
, data
);
516 if (flags
& MF_REMOVE
) return RemoveMenu16(hMenu
, flags
& MF_BYPOSITION
? pos
: id
,
517 flags
& ~MF_REMOVE
);
518 /* Default: MF_INSERT */
519 return InsertMenu16( hMenu
, pos
, flags
, id
, data
);
523 /*******************************************************************
524 * CheckMenuItem (USER.154)
526 BOOL16 WINAPI
CheckMenuItem16( HMENU16 hMenu
, UINT16 id
, UINT16 flags
)
528 return CheckMenuItem( HMENU_32(hMenu
), id
, flags
);
532 /**********************************************************************
533 * EnableMenuItem (USER.155)
535 UINT16 WINAPI
EnableMenuItem16( HMENU16 hMenu
, UINT16 wItemID
, UINT16 wFlags
)
537 return EnableMenuItem( HMENU_32(hMenu
), wItemID
, wFlags
);
541 /**********************************************************************
542 * GetSubMenu (USER.159)
544 HMENU16 WINAPI
GetSubMenu16( HMENU16 hMenu
, INT16 nPos
)
546 return HMENU_16( GetSubMenu( HMENU_32(hMenu
), nPos
) );
550 /*******************************************************************
551 * GetMenuString (USER.161)
553 INT16 WINAPI
GetMenuString16( HMENU16 hMenu
, UINT16 wItemID
,
554 LPSTR str
, INT16 nMaxSiz
, UINT16 wFlags
)
556 return GetMenuStringA( HMENU_32(hMenu
), wItemID
, str
, nMaxSiz
, wFlags
);
560 /**********************************************************************
563 BOOL16 WINAPI
WinHelp16( HWND16 hWnd
, LPCSTR lpHelpFile
, UINT16 wCommand
,
569 /* We might call WinExec() */
570 ReleaseThunkLock(&mutex_count
);
572 ret
= WinHelpA(WIN_Handle32(hWnd
), lpHelpFile
, wCommand
, (DWORD
)MapSL(dwData
));
574 RestoreThunkLock(mutex_count
);
579 /***********************************************************************
580 * LoadCursor (USER.173)
582 HCURSOR16 WINAPI
LoadCursor16(HINSTANCE16 hInstance
, LPCSTR name
)
584 return HCURSOR_16(LoadCursorA(HINSTANCE_32(hInstance
), name
));
588 /***********************************************************************
589 * LoadIcon (USER.174)
591 HICON16 WINAPI
LoadIcon16(HINSTANCE16 hInstance
, LPCSTR name
)
593 return HICON_16(LoadIconA(HINSTANCE_32(hInstance
), name
));
596 /**********************************************************************
597 * LoadBitmap (USER.175)
599 HBITMAP16 WINAPI
LoadBitmap16(HINSTANCE16 hInstance
, LPCSTR name
)
601 return HBITMAP_16(LoadBitmapA(HINSTANCE_32(hInstance
), name
));
605 /***********************************************************************
606 * GetSystemMetrics (USER.179)
608 INT16 WINAPI
GetSystemMetrics16( INT16 index
)
610 return GetSystemMetrics( index
);
614 /*************************************************************************
615 * GetSysColor (USER.180)
617 COLORREF WINAPI
GetSysColor16( INT16 index
)
619 return GetSysColor( index
);
623 /*************************************************************************
624 * SetSysColors (USER.181)
626 VOID WINAPI
SetSysColors16( INT16 count
, const INT16
*list16
, const COLORREF
*values
)
630 if ((list
= HeapAlloc( GetProcessHeap(), 0, count
* sizeof(*list
) )))
632 for (i
= 0; i
< count
; i
++) list
[i
] = list16
[i
];
633 SetSysColors( count
, list
, values
);
634 HeapFree( GetProcessHeap(), 0, list
);
639 /***********************************************************************
640 * GrayString (USER.185)
642 BOOL16 WINAPI
GrayString16( HDC16 hdc
, HBRUSH16 hbr
, GRAYSTRINGPROC16 gsprc
,
643 LPARAM lParam
, INT16 cch
, INT16 x
, INT16 y
,
648 if (!gsprc
) return GrayStringA( HDC_32(hdc
), HBRUSH_32(hbr
), NULL
,
649 (LPARAM
)MapSL(lParam
), cch
, x
, y
, cx
, cy
);
651 if (cch
== -1 || (cch
&& cx
&& cy
))
653 /* lParam can be treated as an opaque pointer */
654 struct gray_string_info info
;
658 ret
= GrayStringA( HDC_32(hdc
), HBRUSH_32(hbr
), gray_string_callback
,
659 (LPARAM
)&info
, cch
, x
, y
, cx
, cy
);
661 else /* here we need some string conversions */
663 char *str16
= MapSL(lParam
);
664 struct gray_string_info
*info
;
666 if (!cch
) cch
= strlen(str16
);
667 if (!(info
= HeapAlloc( GetProcessHeap(), 0, sizeof(*info
) + cch
))) return FALSE
;
669 info
->param
= lParam
;
670 memcpy( info
->str
, str16
, cch
);
671 ret
= GrayStringA( HDC_32(hdc
), HBRUSH_32(hbr
), gray_string_callback_ptr
,
672 (LPARAM
)info
->str
, cch
, x
, y
, cx
, cy
);
673 HeapFree( GetProcessHeap(), 0, info
);
679 /**************************************************************************
680 * IsClipboardFormatAvailable (USER.193)
682 BOOL16 WINAPI
IsClipboardFormatAvailable16( UINT16 wFormat
)
684 return IsClipboardFormatAvailable( wFormat
);
688 /***********************************************************************
689 * TabbedTextOut (USER.196)
691 LONG WINAPI
TabbedTextOut16( HDC16 hdc
, INT16 x
, INT16 y
, LPCSTR lpstr
,
692 INT16 count
, INT16 nb_tabs
, const INT16
*tabs16
, INT16 tab_org
)
695 INT i
, *tabs
= HeapAlloc( GetProcessHeap(), 0, nb_tabs
* sizeof(tabs
) );
697 for (i
= 0; i
< nb_tabs
; i
++) tabs
[i
] = tabs16
[i
];
698 ret
= TabbedTextOutA( HDC_32(hdc
), x
, y
, lpstr
, count
, nb_tabs
, tabs
, tab_org
);
699 HeapFree( GetProcessHeap(), 0, tabs
);
704 /***********************************************************************
705 * GetTabbedTextExtent (USER.197)
707 DWORD WINAPI
GetTabbedTextExtent16( HDC16 hdc
, LPCSTR lpstr
, INT16 count
,
708 INT16 nb_tabs
, const INT16
*tabs16
)
711 INT i
, *tabs
= HeapAlloc( GetProcessHeap(), 0, nb_tabs
* sizeof(tabs
) );
713 for (i
= 0; i
< nb_tabs
; i
++) tabs
[i
] = tabs16
[i
];
714 ret
= GetTabbedTextExtentA( HDC_32(hdc
), lpstr
, count
, nb_tabs
, tabs
);
715 HeapFree( GetProcessHeap(), 0, tabs
);
720 /***********************************************************************
721 * UserSeeUserDo (USER.216)
723 DWORD WINAPI
UserSeeUserDo16(WORD wReqType
, WORD wParam1
, WORD wParam2
, WORD wParam3
)
725 STACK16FRAME
* stack16
= MapSL((SEGPTR
)NtCurrentTeb()->WOW32Reserved
);
726 HANDLE16 oldDS
= stack16
->ds
;
727 DWORD ret
= (DWORD
)-1;
729 stack16
->ds
= USER_HeapSel
;
732 case USUD_LOCALALLOC
:
733 ret
= LocalAlloc16(wParam1
, wParam3
);
736 ret
= LocalFree16(wParam1
);
738 case USUD_LOCALCOMPACT
:
739 ret
= LocalCompact16(wParam3
);
744 case USUD_FIRSTCLASS
:
745 FIXME("return a pointer to the first window class.\n");
748 WARN("wReqType %04x (unknown)\n", wReqType
);
755 /*************************************************************************
756 * ScrollDC (USER.221)
758 BOOL16 WINAPI
ScrollDC16( HDC16 hdc
, INT16 dx
, INT16 dy
, const RECT16
*rect
,
759 const RECT16
*cliprc
, HRGN16 hrgnUpdate
,
762 RECT rect32
, clipRect32
, rcUpdate32
;
767 rect32
.left
= rect
->left
;
768 rect32
.top
= rect
->top
;
769 rect32
.right
= rect
->right
;
770 rect32
.bottom
= rect
->bottom
;
774 clipRect32
.left
= cliprc
->left
;
775 clipRect32
.top
= cliprc
->top
;
776 clipRect32
.right
= cliprc
->right
;
777 clipRect32
.bottom
= cliprc
->bottom
;
779 ret
= ScrollDC( HDC_32(hdc
), dx
, dy
, rect
? &rect32
: NULL
,
780 cliprc
? &clipRect32
: NULL
, HRGN_32(hrgnUpdate
),
784 rcUpdate
->left
= rcUpdate32
.left
;
785 rcUpdate
->top
= rcUpdate32
.top
;
786 rcUpdate
->right
= rcUpdate32
.right
;
787 rcUpdate
->bottom
= rcUpdate32
.bottom
;
793 /***********************************************************************
794 * GetSystemDebugState (USER.231)
796 WORD WINAPI
GetSystemDebugState16(void)
798 return 0; /* FIXME */
802 /***********************************************************************
803 * EqualRect (USER.244)
805 BOOL16 WINAPI
EqualRect16( const RECT16
* rect1
, const RECT16
* rect2
)
807 return ((rect1
->left
== rect2
->left
) && (rect1
->right
== rect2
->right
) &&
808 (rect1
->top
== rect2
->top
) && (rect1
->bottom
== rect2
->bottom
));
812 /***********************************************************************
813 * ExitWindowsExec (USER.246)
815 BOOL16 WINAPI
ExitWindowsExec16( LPCSTR lpszExe
, LPCSTR lpszParams
)
817 TRACE("Should run the following in DOS-mode: \"%s %s\"\n",
818 lpszExe
, lpszParams
);
819 return ExitWindowsEx( EWX_LOGOFF
, 0xffffffff );
823 /***********************************************************************
824 * GetCursor (USER.247)
826 HCURSOR16 WINAPI
GetCursor16(void)
828 return HCURSOR_16(GetCursor());
832 /**********************************************************************
833 * GetAsyncKeyState (USER.249)
835 INT16 WINAPI
GetAsyncKeyState16( INT16 key
)
837 return GetAsyncKeyState( key
);
841 /**********************************************************************
842 * GetMenuState (USER.250)
844 UINT16 WINAPI
GetMenuState16( HMENU16 hMenu
, UINT16 wItemID
, UINT16 wFlags
)
846 return GetMenuState( HMENU_32(hMenu
), wItemID
, wFlags
);
850 /**********************************************************************
851 * GetMenuItemCount (USER.263)
853 INT16 WINAPI
GetMenuItemCount16( HMENU16 hMenu
)
855 return GetMenuItemCount( HMENU_32(hMenu
) );
859 /**********************************************************************
860 * GetMenuItemID (USER.264)
862 UINT16 WINAPI
GetMenuItemID16( HMENU16 hMenu
, INT16 nPos
)
864 return GetMenuItemID( HMENU_32(hMenu
), nPos
);
868 /***********************************************************************
869 * GlobalAddAtom (USER.268)
871 ATOM WINAPI
GlobalAddAtom16(LPCSTR lpString
)
873 return GlobalAddAtomA(lpString
);
876 /***********************************************************************
877 * GlobalDeleteAtom (USER.269)
879 ATOM WINAPI
GlobalDeleteAtom16(ATOM nAtom
)
881 return GlobalDeleteAtom(nAtom
);
884 /***********************************************************************
885 * GlobalFindAtom (USER.270)
887 ATOM WINAPI
GlobalFindAtom16(LPCSTR lpString
)
889 return GlobalFindAtomA(lpString
);
892 /***********************************************************************
893 * GlobalGetAtomName (USER.271)
895 UINT16 WINAPI
GlobalGetAtomName16(ATOM nAtom
, LPSTR lpBuffer
, INT16 nSize
)
897 return GlobalGetAtomNameA(nAtom
, lpBuffer
, nSize
);
901 /***********************************************************************
902 * ControlPanelInfo (USER.273)
904 void WINAPI
ControlPanelInfo16( INT16 nInfoType
, WORD wData
, LPSTR lpBuffer
)
906 FIXME("(%d, %04x, %p): stub.\n", nInfoType
, wData
, lpBuffer
);
910 /***********************************************************************
911 * GetSysColorBrush (USER.281)
913 HBRUSH16 WINAPI
GetSysColorBrush16( INT16 index
)
915 return HBRUSH_16( GetSysColorBrush(index
) );
919 /***********************************************************************
920 * SelectPalette (USER.282)
922 HPALETTE16 WINAPI
SelectPalette16( HDC16 hdc
, HPALETTE16 hpal
, BOOL16 bForceBackground
)
924 return HPALETTE_16( SelectPalette( HDC_32(hdc
), HPALETTE_32(hpal
), bForceBackground
));
927 /***********************************************************************
928 * RealizePalette (USER.283)
930 UINT16 WINAPI
RealizePalette16( HDC16 hdc
)
932 return UserRealizePalette( HDC_32(hdc
) );
936 /***********************************************************************
937 * GetFreeSystemResources (USER.284)
939 WORD WINAPI
GetFreeSystemResources16( WORD resType
)
941 STACK16FRAME
* stack16
= MapSL((SEGPTR
)NtCurrentTeb()->WOW32Reserved
);
942 HANDLE16 oldDS
= stack16
->ds
;
943 HINSTANCE16 gdi_inst
;
945 int userPercent
, gdiPercent
;
947 if ((gdi_inst
= LoadLibrary16( "GDI" )) < 32) return 0;
948 gdi_heap
= gdi_inst
| 7;
952 case GFSR_USERRESOURCES
:
953 stack16
->ds
= USER_HeapSel
;
954 userPercent
= (int)LocalCountFree16() * 100 / LocalHeapSize16();
959 case GFSR_GDIRESOURCES
:
960 stack16
->ds
= gdi_inst
;
961 gdiPercent
= (int)LocalCountFree16() * 100 / LocalHeapSize16();
966 case GFSR_SYSTEMRESOURCES
:
967 stack16
->ds
= USER_HeapSel
;
968 userPercent
= (int)LocalCountFree16() * 100 / LocalHeapSize16();
969 stack16
->ds
= gdi_inst
;
970 gdiPercent
= (int)LocalCountFree16() * 100 / LocalHeapSize16();
975 userPercent
= gdiPercent
= 0;
978 FreeLibrary16( gdi_inst
);
979 TRACE("<- userPercent %d, gdiPercent %d\n", userPercent
, gdiPercent
);
980 return (WORD
)min( userPercent
, gdiPercent
);
984 /***********************************************************************
985 * GetClipCursor (USER.309)
987 void WINAPI
GetClipCursor16( RECT16
*rect
)
992 GetClipCursor( &rect32
);
993 rect
->left
= rect32
.left
;
994 rect
->top
= rect32
.top
;
995 rect
->right
= rect32
.right
;
996 rect
->bottom
= rect32
.bottom
;
1001 /***********************************************************************
1002 * SignalProc (USER.314)
1004 void WINAPI
SignalProc16( HANDLE16 hModule
, UINT16 code
,
1005 UINT16 uExitFn
, HINSTANCE16 hInstance
, HQUEUE16 hQueue
)
1007 if (code
== USIG16_DLL_UNLOAD
)
1009 /* HOOK_FreeModuleHooks( hModule ); */
1010 CLASS_FreeModuleClasses( hModule
);
1011 CURSORICON_FreeModuleIcons( hModule
);
1016 /***********************************************************************
1017 * SetEventHook (USER.321)
1019 * Used by Turbo Debugger for Windows
1021 FARPROC16 WINAPI
SetEventHook16(FARPROC16 lpfnEventHook
)
1023 FIXME("(lpfnEventHook=%p): stub\n", lpfnEventHook
);
1028 /**********************************************************************
1029 * EnableHardwareInput (USER.331)
1031 BOOL16 WINAPI
EnableHardwareInput16(BOOL16 bEnable
)
1033 FIXME("(%d) - stub\n", bEnable
);
1038 /***********************************************************************
1039 * IsUserIdle (USER.333)
1041 BOOL16 WINAPI
IsUserIdle16(void)
1043 if ( GetAsyncKeyState( VK_LBUTTON
) & 0x8000 )
1045 if ( GetAsyncKeyState( VK_RBUTTON
) & 0x8000 )
1047 if ( GetAsyncKeyState( VK_MBUTTON
) & 0x8000 )
1049 /* Should check for screen saver activation here ... */
1054 /**********************************************************************
1055 * LoadDIBIconHandler (USER.357)
1057 * RT_ICON resource loader, installed by USER_SignalProc when module
1060 HGLOBAL16 WINAPI
LoadDIBIconHandler16( HGLOBAL16 hMemObj
, HMODULE16 hModule
, HRSRC16 hRsrc
)
1062 /* If hResource is zero we must allocate a new memory block, if it's
1063 * non-zero but GlobalLock() returns NULL then it was discarded and
1064 * we have to recommit some memory, otherwise we just need to check
1065 * the block size. See LoadProc() in 16-bit SDK for more.
1067 FIXME( "%x %x %x: stub, not supported anymore\n", hMemObj
, hModule
, hRsrc
);
1071 /**********************************************************************
1072 * LoadDIBCursorHandler (USER.356)
1074 * RT_CURSOR resource loader. Same as above.
1076 HGLOBAL16 WINAPI
LoadDIBCursorHandler16( HGLOBAL16 hMemObj
, HMODULE16 hModule
, HRSRC16 hRsrc
)
1078 FIXME( "%x %x %x: stub, not supported anymore\n", hMemObj
, hModule
, hRsrc
);
1083 /**********************************************************************
1086 BOOL16 WINAPI
IsMenu16( HMENU16 hmenu
)
1088 return IsMenu( HMENU_32(hmenu
) );
1092 /***********************************************************************
1095 BOOL16 WINAPI
DCHook16( HDC16 hdc
, WORD code
, DWORD data
, LPARAM lParam
)
1097 FIXME( "hDC = %x, %i: stub\n", hdc
, code
);
1102 /***********************************************************************
1103 * SubtractRect (USER.373)
1105 BOOL16 WINAPI
SubtractRect16( LPRECT16 dest
, const RECT16
*src1
,
1106 const RECT16
*src2
)
1110 if (IsRectEmpty16( src1
))
1112 SetRectEmpty16( dest
);
1116 if (IntersectRect16( &tmp
, src1
, src2
))
1118 if (EqualRect16( &tmp
, dest
))
1120 SetRectEmpty16( dest
);
1123 if ((tmp
.top
== dest
->top
) && (tmp
.bottom
== dest
->bottom
))
1125 if (tmp
.left
== dest
->left
) dest
->left
= tmp
.right
;
1126 else if (tmp
.right
== dest
->right
) dest
->right
= tmp
.left
;
1128 else if ((tmp
.left
== dest
->left
) && (tmp
.right
== dest
->right
))
1130 if (tmp
.top
== dest
->top
) dest
->top
= tmp
.bottom
;
1131 else if (tmp
.bottom
== dest
->bottom
) dest
->bottom
= tmp
.top
;
1138 /**********************************************************************
1139 * SetMenuContextHelpId (USER.384)
1141 BOOL16 WINAPI
SetMenuContextHelpId16( HMENU16 hMenu
, DWORD dwContextHelpID
)
1143 return SetMenuContextHelpId( HMENU_32(hMenu
), dwContextHelpID
);
1147 /**********************************************************************
1148 * GetMenuContextHelpId (USER.385)
1150 DWORD WINAPI
GetMenuContextHelpId16( HMENU16 hMenu
)
1152 return GetMenuContextHelpId( HMENU_32(hMenu
) );
1156 /***********************************************************************
1157 * LoadImage (USER.389)
1160 HANDLE16 WINAPI
LoadImage16(HINSTANCE16 hinst
, LPCSTR name
, UINT16 type
,
1161 INT16 desiredx
, INT16 desiredy
, UINT16 loadflags
)
1163 return HANDLE_16(LoadImageA(HINSTANCE_32(hinst
), name
, type
, desiredx
,
1164 desiredy
, loadflags
));
1167 /******************************************************************************
1168 * CopyImage (USER.390) Creates new image and copies attributes to it
1171 HICON16 WINAPI
CopyImage16(HANDLE16 hnd
, UINT16 type
, INT16 desiredx
,
1172 INT16 desiredy
, UINT16 flags
)
1174 return HICON_16(CopyImage(HANDLE_32(hnd
), (UINT
)type
, (INT
)desiredx
,
1175 (INT
)desiredy
, (UINT
)flags
));
1178 /**********************************************************************
1179 * DrawIconEx (USER.394)
1181 BOOL16 WINAPI
DrawIconEx16(HDC16 hdc
, INT16 xLeft
, INT16 yTop
, HICON16 hIcon
,
1182 INT16 cxWidth
, INT16 cyWidth
, UINT16 istep
,
1183 HBRUSH16 hbr
, UINT16 flags
)
1185 return DrawIconEx(HDC_32(hdc
), xLeft
, yTop
, HICON_32(hIcon
), cxWidth
, cyWidth
,
1186 istep
, HBRUSH_32(hbr
), flags
);
1189 /**********************************************************************
1190 * GetIconInfo (USER.395)
1192 BOOL16 WINAPI
GetIconInfo16(HICON16 hIcon
, LPICONINFO16 iconinfo
)
1195 BOOL16 ret
= GetIconInfo(HICON_32(hIcon
), &ii32
);
1197 iconinfo
->fIcon
= ii32
.fIcon
;
1198 iconinfo
->xHotspot
= ii32
.xHotspot
;
1199 iconinfo
->yHotspot
= ii32
.yHotspot
;
1200 iconinfo
->hbmMask
= HBITMAP_16(ii32
.hbmMask
);
1201 iconinfo
->hbmColor
= HBITMAP_16(ii32
.hbmColor
);
1206 /***********************************************************************
1207 * FinalUserInit (USER.400)
1209 void WINAPI
FinalUserInit16( void )
1211 /* FIXME: Should chain to FinalGdiInit */
1215 /***********************************************************************
1216 * CreateCursor (USER.406)
1218 HCURSOR16 WINAPI
CreateCursor16(HINSTANCE16 hInstance
,
1219 INT16 xHotSpot
, INT16 yHotSpot
,
1220 INT16 nWidth
, INT16 nHeight
,
1221 LPCVOID lpANDbits
, LPCVOID lpXORbits
)
1223 CURSORICONINFO info
;
1225 info
.ptHotSpot
.x
= xHotSpot
;
1226 info
.ptHotSpot
.y
= yHotSpot
;
1227 info
.nWidth
= nWidth
;
1228 info
.nHeight
= nHeight
;
1229 info
.nWidthBytes
= 0;
1231 info
.bBitsPerPixel
= 1;
1233 return CreateCursorIconIndirect16(hInstance
, &info
, lpANDbits
, lpXORbits
);
1237 /***********************************************************************
1238 * InitThreadInput (USER.409)
1240 HQUEUE16 WINAPI
InitThreadInput16( WORD unknown
, WORD flags
)
1242 /* nothing to do here */
1247 /*******************************************************************
1248 * InsertMenu (USER.410)
1250 BOOL16 WINAPI
InsertMenu16( HMENU16 hMenu
, UINT16 pos
, UINT16 flags
,
1251 UINT16 id
, SEGPTR data
)
1253 UINT pos32
= (UINT
)pos
;
1254 if ((pos
== (UINT16
)-1) && (flags
& MF_BYPOSITION
)) pos32
= (UINT
)-1;
1255 if (IS_MENU_STRING_ITEM(flags
) && data
)
1256 return InsertMenuA( HMENU_32(hMenu
), pos32
, flags
, id
, MapSL(data
) );
1257 return InsertMenuA( HMENU_32(hMenu
), pos32
, flags
, id
, (LPSTR
)data
);
1261 /*******************************************************************
1262 * AppendMenu (USER.411)
1264 BOOL16 WINAPI
AppendMenu16(HMENU16 hMenu
, UINT16 flags
, UINT16 id
, SEGPTR data
)
1266 return InsertMenu16( hMenu
, -1, flags
| MF_BYPOSITION
, id
, data
);
1270 /**********************************************************************
1271 * RemoveMenu (USER.412)
1273 BOOL16 WINAPI
RemoveMenu16( HMENU16 hMenu
, UINT16 nPos
, UINT16 wFlags
)
1275 return RemoveMenu( HMENU_32(hMenu
), nPos
, wFlags
);
1279 /**********************************************************************
1280 * DeleteMenu (USER.413)
1282 BOOL16 WINAPI
DeleteMenu16( HMENU16 hMenu
, UINT16 nPos
, UINT16 wFlags
)
1284 return DeleteMenu( HMENU_32(hMenu
), nPos
, wFlags
);
1288 /*******************************************************************
1289 * ModifyMenu (USER.414)
1291 BOOL16 WINAPI
ModifyMenu16( HMENU16 hMenu
, UINT16 pos
, UINT16 flags
,
1292 UINT16 id
, SEGPTR data
)
1294 if (IS_MENU_STRING_ITEM(flags
))
1295 return ModifyMenuA( HMENU_32(hMenu
), pos
, flags
, id
, MapSL(data
) );
1296 return ModifyMenuA( HMENU_32(hMenu
), pos
, flags
, id
, (LPSTR
)data
);
1300 /**********************************************************************
1301 * CreatePopupMenu (USER.415)
1303 HMENU16 WINAPI
CreatePopupMenu16(void)
1305 return HMENU_16( CreatePopupMenu() );
1309 /**********************************************************************
1310 * SetMenuItemBitmaps (USER.418)
1312 BOOL16 WINAPI
SetMenuItemBitmaps16( HMENU16 hMenu
, UINT16 nPos
, UINT16 wFlags
,
1313 HBITMAP16 hNewUnCheck
, HBITMAP16 hNewCheck
)
1315 return SetMenuItemBitmaps( HMENU_32(hMenu
), nPos
, wFlags
,
1316 HBITMAP_32(hNewUnCheck
), HBITMAP_32(hNewCheck
) );
1320 /***********************************************************************
1321 * lstrcmp (USER.430)
1323 INT16 WINAPI
lstrcmp16( LPCSTR str1
, LPCSTR str2
)
1325 return strcmp( str1
, str2
);
1329 /***********************************************************************
1330 * AnsiUpper (USER.431)
1332 SEGPTR WINAPI
AnsiUpper16( SEGPTR strOrChar
)
1334 /* uppercase only one char if strOrChar < 0x10000 */
1335 if (HIWORD(strOrChar
))
1337 CharUpperA( MapSL(strOrChar
) );
1340 else return (SEGPTR
)CharUpperA( (LPSTR
)strOrChar
);
1344 /***********************************************************************
1345 * AnsiLower (USER.432)
1347 SEGPTR WINAPI
AnsiLower16( SEGPTR strOrChar
)
1349 /* lowercase only one char if strOrChar < 0x10000 */
1350 if (HIWORD(strOrChar
))
1352 CharLowerA( MapSL(strOrChar
) );
1355 else return (SEGPTR
)CharLowerA( (LPSTR
)strOrChar
);
1359 /***********************************************************************
1360 * AnsiUpperBuff (USER.437)
1362 UINT16 WINAPI
AnsiUpperBuff16( LPSTR str
, UINT16 len
)
1364 CharUpperBuffA( str
, len
? len
: 65536 );
1369 /***********************************************************************
1370 * AnsiLowerBuff (USER.438)
1372 UINT16 WINAPI
AnsiLowerBuff16( LPSTR str
, UINT16 len
)
1374 CharLowerBuffA( str
, len
? len
: 65536 );
1379 /*******************************************************************
1380 * InsertMenuItem (USER.441)
1384 BOOL16 WINAPI
InsertMenuItem16( HMENU16 hmenu
, UINT16 pos
, BOOL16 byposition
,
1385 const MENUITEMINFO16
*mii
)
1389 miia
.cbSize
= sizeof(miia
);
1390 miia
.fMask
= mii
->fMask
;
1391 miia
.dwTypeData
= (LPSTR
)mii
->dwTypeData
;
1392 miia
.fType
= mii
->fType
;
1393 miia
.fState
= mii
->fState
;
1394 miia
.wID
= mii
->wID
;
1395 miia
.hSubMenu
= HMENU_32(mii
->hSubMenu
);
1396 miia
.hbmpChecked
= HBITMAP_32(mii
->hbmpChecked
);
1397 miia
.hbmpUnchecked
= HBITMAP_32(mii
->hbmpUnchecked
);
1398 miia
.dwItemData
= mii
->dwItemData
;
1399 miia
.cch
= mii
->cch
;
1400 if (IS_MENU_STRING_ITEM(miia
.fType
))
1401 miia
.dwTypeData
= MapSL(mii
->dwTypeData
);
1402 return InsertMenuItemA( HMENU_32(hmenu
), pos
, byposition
, &miia
);
1406 /**********************************************************************
1407 * DrawState (USER.449)
1409 BOOL16 WINAPI
DrawState16( HDC16 hdc
, HBRUSH16 hbr
, DRAWSTATEPROC16 func
, LPARAM ldata
,
1410 WPARAM16 wdata
, INT16 x
, INT16 y
, INT16 cx
, INT16 cy
, UINT16 flags
)
1412 struct draw_state_info info
;
1413 UINT opcode
= flags
& 0xf;
1415 if (opcode
== DST_TEXT
|| opcode
== DST_PREFIXTEXT
)
1417 /* make sure DrawStateA doesn't try to use ldata as a pointer */
1418 if (!wdata
) wdata
= strlen( MapSL(ldata
) );
1422 if (!GetTextExtentPoint32A( HDC_32(hdc
), MapSL(ldata
), wdata
, &s
)) return FALSE
;
1429 return DrawStateA( HDC_32(hdc
), HBRUSH_32(hbr
), draw_state_callback
,
1430 (LPARAM
)&info
, wdata
, x
, y
, cx
, cy
, flags
);
1434 /**********************************************************************
1435 * CreateIconFromResourceEx (USER.450)
1437 * FIXME: not sure about exact parameter types
1439 HICON16 WINAPI
CreateIconFromResourceEx16(LPBYTE bits
, UINT16 cbSize
,
1440 BOOL16 bIcon
, DWORD dwVersion
,
1441 INT16 width
, INT16 height
,
1444 return HICON_16(CreateIconFromResourceEx(bits
, cbSize
, bIcon
, dwVersion
,
1445 width
, height
, cFlag
));
1449 /***********************************************************************
1450 * AdjustWindowRectEx (USER.454)
1452 BOOL16 WINAPI
AdjustWindowRectEx16( LPRECT16 rect
, DWORD style
, BOOL16 menu
, DWORD exStyle
)
1457 rect32
.left
= rect
->left
;
1458 rect32
.top
= rect
->top
;
1459 rect32
.right
= rect
->right
;
1460 rect32
.bottom
= rect
->bottom
;
1461 ret
= AdjustWindowRectEx( &rect32
, style
, menu
, exStyle
);
1462 rect
->left
= rect32
.left
;
1463 rect
->top
= rect32
.top
;
1464 rect
->right
= rect32
.right
;
1465 rect
->bottom
= rect32
.bottom
;
1470 /***********************************************************************
1471 * DestroyIcon (USER.457)
1473 BOOL16 WINAPI
DestroyIcon16(HICON16 hIcon
)
1475 return DestroyIcon32(hIcon
, 0);
1478 /***********************************************************************
1479 * DestroyCursor (USER.458)
1481 BOOL16 WINAPI
DestroyCursor16(HCURSOR16 hCursor
)
1483 return DestroyIcon32(hCursor
, 0);
1486 /*******************************************************************
1487 * DRAG_QueryUpdate16
1489 * Recursively find a child that contains spDragInfo->pt point
1490 * and send WM_QUERYDROPOBJECT. Helper for DragObject16.
1492 static BOOL
DRAG_QueryUpdate16( HWND hQueryWnd
, SEGPTR spDragInfo
)
1497 LPDRAGINFO16 ptrDragInfo
= MapSL(spDragInfo
);
1501 if (!IsWindowEnabled(hQueryWnd
)) return FALSE
;
1503 old_pt
.x
= ptrDragInfo
->pt
.x
;
1504 old_pt
.y
= ptrDragInfo
->pt
.y
;
1506 ScreenToClient( hQueryWnd
, &pt
);
1507 child
= ChildWindowFromPointEx( hQueryWnd
, pt
, CWP_SKIPINVISIBLE
);
1508 if (!child
) return FALSE
;
1510 if (child
!= hQueryWnd
)
1513 if (DRAG_QueryUpdate16( child
, spDragInfo
)) return TRUE
;
1517 GetClientRect( hQueryWnd
, &tempRect
);
1518 wParam
= !PtInRect( &tempRect
, pt
);
1521 ptrDragInfo
->pt
.x
= pt
.x
;
1522 ptrDragInfo
->pt
.y
= pt
.y
;
1523 ptrDragInfo
->hScope
= HWND_16(hQueryWnd
);
1525 bResult
= SendMessage16( HWND_16(hQueryWnd
), WM_QUERYDROPOBJECT
, wParam
, spDragInfo
);
1529 ptrDragInfo
->pt
.x
= old_pt
.x
;
1530 ptrDragInfo
->pt
.y
= old_pt
.y
;
1536 /******************************************************************************
1537 * DragObject (USER.464)
1539 DWORD WINAPI
DragObject16( HWND16 hwndScope
, HWND16 hWnd
, UINT16 wObj
,
1540 HANDLE16 hOfStruct
, WORD szList
, HCURSOR16 hCursor
)
1543 LPDRAGINFO16 lpDragInfo
;
1545 HCURSOR hOldCursor
=0, hBummer
=0;
1546 HGLOBAL16 hDragInfo
= GlobalAlloc16( GMEM_SHARE
| GMEM_ZEROINIT
, 2*sizeof(DRAGINFO16
));
1547 HCURSOR hCurrentCursor
= 0;
1548 HWND16 hCurrentWnd
= 0;
1550 lpDragInfo
= (LPDRAGINFO16
) GlobalLock16(hDragInfo
);
1551 spDragInfo
= K32WOWGlobalLock16(hDragInfo
);
1553 if( !lpDragInfo
|| !spDragInfo
) return 0L;
1555 if (!(hBummer
= LoadCursorA(0, MAKEINTRESOURCEA(OCR_NO
))))
1557 GlobalFree16(hDragInfo
);
1561 if(hCursor
) hOldCursor
= SetCursor(HCURSOR_32(hCursor
));
1563 lpDragInfo
->hWnd
= hWnd
;
1564 lpDragInfo
->hScope
= 0;
1565 lpDragInfo
->wFlags
= wObj
;
1566 lpDragInfo
->hList
= szList
; /* near pointer! */
1567 lpDragInfo
->hOfStruct
= hOfStruct
;
1570 SetCapture( HWND_32(hWnd
) );
1575 GetMessageW( &msg
, 0, WM_MOUSEFIRST
, WM_MOUSELAST
);
1577 *(lpDragInfo
+1) = *lpDragInfo
;
1579 lpDragInfo
->pt
.x
= msg
.pt
.x
;
1580 lpDragInfo
->pt
.y
= msg
.pt
.y
;
1582 /* update DRAGINFO struct */
1583 if( DRAG_QueryUpdate16(WIN_Handle32(hwndScope
), spDragInfo
) > 0 )
1584 hCurrentCursor
= HCURSOR_32(hCursor
);
1587 hCurrentCursor
= hBummer
;
1588 lpDragInfo
->hScope
= 0;
1590 if( hCurrentCursor
)
1591 SetCursor(hCurrentCursor
);
1593 /* send WM_DRAGLOOP */
1594 SendMessage16( hWnd
, WM_DRAGLOOP
, (WPARAM16
)(hCurrentCursor
!= hBummer
),
1595 (LPARAM
) spDragInfo
);
1596 /* send WM_DRAGSELECT or WM_DRAGMOVE */
1597 if( hCurrentWnd
!= lpDragInfo
->hScope
)
1600 SendMessage16( hCurrentWnd
, WM_DRAGSELECT
, 0,
1601 (LPARAM
)MAKELONG(LOWORD(spDragInfo
)+sizeof(DRAGINFO16
),
1602 HIWORD(spDragInfo
)) );
1603 hCurrentWnd
= lpDragInfo
->hScope
;
1605 SendMessage16( hCurrentWnd
, WM_DRAGSELECT
, 1, (LPARAM
)spDragInfo
);
1609 SendMessage16( hCurrentWnd
, WM_DRAGMOVE
, 0, (LPARAM
)spDragInfo
);
1611 } while( msg
.message
!= WM_LBUTTONUP
&& msg
.message
!= WM_NCLBUTTONUP
);
1614 ShowCursor( FALSE
);
1616 if( hCursor
) SetCursor(hOldCursor
);
1618 if( hCurrentCursor
!= hBummer
)
1619 msg
.lParam
= SendMessage16( lpDragInfo
->hScope
, WM_DROPOBJECT
,
1620 (WPARAM16
)hWnd
, (LPARAM
)spDragInfo
);
1623 GlobalFree16(hDragInfo
);
1625 return (DWORD
)(msg
.lParam
);
1629 /***********************************************************************
1630 * DrawFocusRect (USER.466)
1632 void WINAPI
DrawFocusRect16( HDC16 hdc
, const RECT16
* rc
)
1636 rect32
.left
= rc
->left
;
1637 rect32
.top
= rc
->top
;
1638 rect32
.right
= rc
->right
;
1639 rect32
.bottom
= rc
->bottom
;
1640 DrawFocusRect( HDC_32(hdc
), &rect32
);
1644 /***********************************************************************
1645 * AnsiNext (USER.472)
1647 SEGPTR WINAPI
AnsiNext16(SEGPTR current
)
1649 char *ptr
= MapSL(current
);
1650 return current
+ (CharNextA(ptr
) - ptr
);
1654 /***********************************************************************
1655 * AnsiPrev (USER.473)
1657 SEGPTR WINAPI
AnsiPrev16( LPCSTR start
, SEGPTR current
)
1659 char *ptr
= MapSL(current
);
1660 return current
- (ptr
- CharPrevA( start
, ptr
));
1664 /***********************************************************************
1665 * FormatMessage (USER.606)
1667 DWORD WINAPI
FormatMessage16(
1669 SEGPTR lpSource
, /* [in] NOTE: not always a valid pointer */
1672 LPSTR lpBuffer
, /* [out] NOTE: *((HLOCAL16*)) for FORMAT_MESSAGE_ALLOCATE_BUFFER*/
1674 LPDWORD args
) /* [in] NOTE: va_list *args */
1677 /* This implementation is completely dependent on the format of the va_list on x86 CPUs */
1681 DWORD width
= dwFlags
& FORMAT_MESSAGE_MAX_WIDTH_MASK
;
1683 LPSTR allocstring
= NULL
;
1685 TRACE("(0x%lx,%lx,%d,0x%x,%p,%d,%p)\n",
1686 dwFlags
,lpSource
,dwMessageId
,dwLanguageId
,lpBuffer
,nSize
,args
);
1687 if ((dwFlags
& FORMAT_MESSAGE_FROM_SYSTEM
)
1688 && (dwFlags
& FORMAT_MESSAGE_FROM_HMODULE
)) return 0;
1689 if ((dwFlags
& FORMAT_MESSAGE_FROM_STRING
)
1690 &&((dwFlags
& FORMAT_MESSAGE_FROM_SYSTEM
)
1691 || (dwFlags
& FORMAT_MESSAGE_FROM_HMODULE
))) return 0;
1693 if (width
&& width
!= FORMAT_MESSAGE_MAX_WIDTH_MASK
)
1694 FIXME("line wrapping (%lu) not supported.\n", width
);
1696 if (dwFlags
& FORMAT_MESSAGE_FROM_STRING
)
1698 char *source
= MapSL(lpSource
);
1699 from
= HeapAlloc( GetProcessHeap(), 0, strlen(source
)+1 );
1700 strcpy( from
, source
);
1702 else if (dwFlags
& FORMAT_MESSAGE_FROM_SYSTEM
) {
1703 from
= HeapAlloc( GetProcessHeap(),0,200 );
1704 sprintf(from
,"Systemmessage, messageid = 0x%08x\n",dwMessageId
);
1706 else if (dwFlags
& FORMAT_MESSAGE_FROM_HMODULE
) {
1708 HINSTANCE16 hinst16
= ((HINSTANCE16
)lpSource
& 0xffff);
1710 dwMessageId
&= 0xFFFF;
1711 bufsize
=LoadString16(hinst16
,dwMessageId
,NULL
,0);
1713 from
= HeapAlloc( GetProcessHeap(), 0, bufsize
+1);
1714 LoadString16(hinst16
,dwMessageId
,from
,bufsize
+1);
1717 target
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, 100);
1721 #define ADD_TO_T(c) \
1723 if (t-target == talloced) {\
1724 target = HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,target,talloced*2);\
1725 t = target+talloced;\
1731 while (*f
&& !eos
) {
1734 char *fmtstr
,*x
,*lastf
;
1735 DWORD
*argliststart
;
1745 case '1':case '2':case '3':case '4':case '5':
1746 case '6':case '7':case '8':case '9':
1749 case '0':case '1':case '2':case '3':
1750 case '4':case '5':case '6':case '7':
1753 insertnr
=insertnr
*10+*f
-'0';
1762 if (NULL
!=(x
=strchr(f
,'!'))) {
1764 fmtstr
=HeapAlloc(GetProcessHeap(),0,strlen(f
)+2);
1765 sprintf(fmtstr
,"%%%s",f
);
1768 fmtstr
=HeapAlloc(GetProcessHeap(),0,strlen(f
)+2);
1769 sprintf(fmtstr
,"%%%s",f
);
1770 f
+=strlen(f
); /*at \0*/
1776 fmtstr
=HeapAlloc( GetProcessHeap(), 0, 3 );
1777 strcpy( fmtstr
, "%s" );
1782 LPSTR b
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sz
= 100);
1784 argliststart
=args
+insertnr
-1;
1786 /* CMF - This makes a BIG assumption about va_list */
1787 while ((ret
= vsnprintf(b
, sz
, fmtstr
, (va_list) argliststart
) < 0) || (ret
>= sz
)) {
1788 sz
= (ret
== -1 ? sz
+ 100 : ret
+ 1);
1789 b
= HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, b
, sz
);
1791 for (x
=b
; *x
; x
++) ADD_TO_T(*x
);
1792 HeapFree(GetProcessHeap(), 0, b
);
1794 /* NULL args - copy formatstr
1797 while ((lastf
<f
)&&(*lastf
)) {
1801 HeapFree(GetProcessHeap(),0,fmtstr
);
1803 case '0': /* Just stop processing format string */
1807 case 'n': /* 16 bit version just outputs 'n' */
1812 } else { /* '\n' or '\r' gets mapped to "\r\n" */
1813 if(*f
== '\n' || *f
== '\r') {
1817 if(*f
++ == '\r' && *f
== '\n')
1827 talloced
= strlen(target
)+1;
1828 if (nSize
&& talloced
<nSize
) {
1829 target
= HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,target
,nSize
);
1831 TRACE("-- %s\n",debugstr_a(target
));
1832 if (dwFlags
& FORMAT_MESSAGE_ALLOCATE_BUFFER
) {
1833 /* nSize is the MINIMUM size */
1834 HLOCAL16 h
= LocalAlloc16(LPTR
,talloced
);
1835 SEGPTR ptr
= LocalLock16(h
);
1836 allocstring
= MapSL( ptr
);
1837 memcpy( allocstring
,target
,talloced
);
1839 *((HLOCAL16
*)lpBuffer
) = h
;
1841 lstrcpynA(lpBuffer
,target
,nSize
);
1842 HeapFree(GetProcessHeap(),0,target
);
1843 HeapFree(GetProcessHeap(),0,from
);
1844 return (dwFlags
& FORMAT_MESSAGE_ALLOCATE_BUFFER
) ?
1845 strlen(allocstring
):
1849 #endif /* __i386__ */
1854 /***********************************************************************
1855 * ChangeDisplaySettings (USER.620)
1857 LONG WINAPI
ChangeDisplaySettings16( LPDEVMODEA devmode
, DWORD flags
)
1859 return ChangeDisplaySettingsA( devmode
, flags
);
1863 /***********************************************************************
1864 * EnumDisplaySettings (USER.621)
1866 BOOL16 WINAPI
EnumDisplaySettings16( LPCSTR name
, DWORD n
, LPDEVMODEA devmode
)
1868 return EnumDisplaySettingsA( name
, n
, devmode
);
1871 /**********************************************************************
1872 * DrawFrameControl (USER.656)
1874 BOOL16 WINAPI
DrawFrameControl16( HDC16 hdc
, LPRECT16 rc
, UINT16 uType
, UINT16 uState
)
1879 rect32
.left
= rc
->left
;
1880 rect32
.top
= rc
->top
;
1881 rect32
.right
= rc
->right
;
1882 rect32
.bottom
= rc
->bottom
;
1883 ret
= DrawFrameControl( HDC_32(hdc
), &rect32
, uType
, uState
);
1884 rc
->left
= rect32
.left
;
1885 rc
->top
= rect32
.top
;
1886 rc
->right
= rect32
.right
;
1887 rc
->bottom
= rect32
.bottom
;
1891 /**********************************************************************
1892 * DrawEdge (USER.659)
1894 BOOL16 WINAPI
DrawEdge16( HDC16 hdc
, LPRECT16 rc
, UINT16 edge
, UINT16 flags
)
1899 rect32
.left
= rc
->left
;
1900 rect32
.top
= rc
->top
;
1901 rect32
.right
= rc
->right
;
1902 rect32
.bottom
= rc
->bottom
;
1903 ret
= DrawEdge( HDC_32(hdc
), &rect32
, edge
, flags
);
1904 rc
->left
= rect32
.left
;
1905 rc
->top
= rect32
.top
;
1906 rc
->right
= rect32
.right
;
1907 rc
->bottom
= rect32
.bottom
;
1911 /**********************************************************************
1912 * CheckMenuRadioItem (USER.666)
1914 BOOL16 WINAPI
CheckMenuRadioItem16(HMENU16 hMenu
, UINT16 first
, UINT16 last
,
1915 UINT16 check
, BOOL16 bypos
)
1917 return CheckMenuRadioItem( HMENU_32(hMenu
), first
, last
, check
, bypos
);