2 * Misc 16-bit USER functions
4 * Copyright 2002 Patrik Stridvall
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "wine/winuser16.h"
27 #include "user_private.h"
30 #include "cursoricon.h"
31 #include "wine/debug.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(user
);
35 /* handle to handle 16 conversions */
36 #define HANDLE_16(h32) (LOWORD(h32))
38 /* handle16 to handle conversions */
39 #define HANDLE_32(h16) ((HANDLE)(ULONG_PTR)(h16))
40 #define HINSTANCE_32(h16) ((HINSTANCE)(ULONG_PTR)(h16))
42 #define IS_MENU_STRING_ITEM(flags) \
43 (((flags) & (MF_STRING | MF_BITMAP | MF_OWNERDRAW | MF_SEPARATOR)) == MF_STRING)
45 WORD WINAPI
DestroyIcon32(HGLOBAL16
, UINT16
);
48 struct gray_string_info
50 GRAYSTRINGPROC16 proc
;
55 /* callback for 16-bit gray string proc with opaque pointer */
56 static BOOL CALLBACK
gray_string_callback( HDC hdc
, LPARAM param
, INT len
)
58 const struct gray_string_info
*info
= (struct gray_string_info
*)param
;
62 args
[3] = HDC_16(hdc
);
63 args
[2] = HIWORD(info
->param
);
64 args
[1] = LOWORD(info
->param
);
66 WOWCallback16Ex( (DWORD
)info
->proc
, WCB16_PASCAL
, sizeof(args
), args
, &ret
);
70 /* callback for 16-bit gray string proc with string pointer */
71 static BOOL CALLBACK
gray_string_callback_ptr( HDC hdc
, LPARAM param
, INT len
)
73 const struct gray_string_info
*info
;
74 char *str
= (char *)param
;
76 info
= (struct gray_string_info
*)(str
- offsetof( struct gray_string_info
, str
));
77 return gray_string_callback( hdc
, (LPARAM
)info
, len
);
80 struct draw_state_info
86 /* callback for 16-bit DrawState functions */
87 static BOOL CALLBACK
draw_state_callback( HDC hdc
, LPARAM lparam
, WPARAM wparam
, int cx
, int cy
)
89 const struct draw_state_info
*info
= (struct draw_state_info
*)lparam
;
93 args
[5] = HDC_16(hdc
);
94 args
[4] = HIWORD(info
->param
);
95 args
[3] = LOWORD(info
->param
);
99 WOWCallback16Ex( (DWORD
)info
->proc
, WCB16_PASCAL
, sizeof(args
), args
, &ret
);
104 /**********************************************************************
107 INT16 WINAPI
InitApp16( HINSTANCE16 hInstance
)
109 /* Create task message queue */
110 return (InitThreadInput16( 0, 0 ) != 0);
114 /***********************************************************************
115 * ExitWindows (USER.7)
117 BOOL16 WINAPI
ExitWindows16( DWORD dwReturnCode
, UINT16 wReserved
)
119 return ExitWindowsEx( EWX_LOGOFF
, 0xffffffff );
123 /***********************************************************************
124 * ClipCursor (USER.16)
126 BOOL16 WINAPI
ClipCursor16( const RECT16
*rect
)
130 if (!rect
) return ClipCursor( NULL
);
131 rect32
.left
= rect
->left
;
132 rect32
.top
= rect
->top
;
133 rect32
.right
= rect
->right
;
134 rect32
.bottom
= rect
->bottom
;
135 return ClipCursor( &rect32
);
139 /***********************************************************************
140 * GetCursorPos (USER.17)
142 BOOL16 WINAPI
GetCursorPos16( POINT16
*pt
)
153 /***********************************************************************
154 * SetCursor (USER.69)
156 HCURSOR16 WINAPI
SetCursor16(HCURSOR16 hCursor
)
158 return HCURSOR_16(SetCursor(HCURSOR_32(hCursor
)));
162 /***********************************************************************
163 * SetCursorPos (USER.70)
165 void WINAPI
SetCursorPos16( INT16 x
, INT16 y
)
167 SetCursorPos( x
, y
);
171 /***********************************************************************
172 * ShowCursor (USER.71)
174 INT16 WINAPI
ShowCursor16(BOOL16 bShow
)
176 return ShowCursor(bShow
);
180 /***********************************************************************
183 * The Win16 variant doesn't support special color brushes like
184 * the Win32 one, despite the fact that Win16, as well as Win32,
185 * supports special background brushes for a window class.
187 INT16 WINAPI
FillRect16( HDC16 hdc
, const RECT16
*rect
, HBRUSH16 hbrush
)
191 /* coordinates are logical so we cannot fast-check 'rect',
192 * it will be done later in the PatBlt().
195 if (!(prevBrush
= SelectObject( HDC_32(hdc
), HBRUSH_32(hbrush
) ))) return 0;
196 PatBlt( HDC_32(hdc
), rect
->left
, rect
->top
,
197 rect
->right
- rect
->left
, rect
->bottom
- rect
->top
, PATCOPY
);
198 SelectObject( HDC_32(hdc
), prevBrush
);
203 /***********************************************************************
204 * InvertRect (USER.82)
206 void WINAPI
InvertRect16( HDC16 hdc
, const RECT16
*rect
)
208 PatBlt( HDC_32(hdc
), rect
->left
, rect
->top
,
209 rect
->right
- rect
->left
, rect
->bottom
- rect
->top
, DSTINVERT
);
213 /***********************************************************************
214 * FrameRect (USER.83)
216 INT16 WINAPI
FrameRect16( HDC16 hdc
, const RECT16
*rect16
, HBRUSH16 hbrush
)
220 rect
.left
= rect16
->left
;
221 rect
.top
= rect16
->top
;
222 rect
.right
= rect16
->right
;
223 rect
.bottom
= rect16
->bottom
;
224 return FrameRect( HDC_32(hdc
), &rect
, HBRUSH_32(hbrush
) );
228 /***********************************************************************
231 BOOL16 WINAPI
DrawIcon16(HDC16 hdc
, INT16 x
, INT16 y
, HICON16 hIcon
)
233 return DrawIcon(HDC_32(hdc
), x
, y
, HICON_32(hIcon
));
237 /***********************************************************************
240 INT16 WINAPI
DrawText16( HDC16 hdc
, LPCSTR str
, INT16 count
, LPRECT16 rect
, UINT16 flags
)
248 rect32
.left
= rect
->left
;
249 rect32
.top
= rect
->top
;
250 rect32
.right
= rect
->right
;
251 rect32
.bottom
= rect
->bottom
;
252 ret
= DrawTextA( HDC_32(hdc
), str
, count
, &rect32
, flags
);
253 rect
->left
= rect32
.left
;
254 rect
->top
= rect32
.top
;
255 rect
->right
= rect32
.right
;
256 rect
->bottom
= rect32
.bottom
;
258 else ret
= DrawTextA( HDC_32(hdc
), str
, count
, NULL
, flags
);
263 /***********************************************************************
266 * See "Undocumented Windows". Used by W2.0 paint.exe.
268 DWORD WINAPI
IconSize16(void)
270 return MAKELONG(GetSystemMetrics(SM_CYICON
), GetSystemMetrics(SM_CXICON
));
274 /***********************************************************************
275 * AdjustWindowRect (USER.102)
277 BOOL16 WINAPI
AdjustWindowRect16( LPRECT16 rect
, DWORD style
, BOOL16 menu
)
279 return AdjustWindowRectEx16( rect
, style
, menu
, 0 );
283 /**************************************************************************
284 * CloseClipboard (USER.138)
286 BOOL16 WINAPI
CloseClipboard16(void)
288 return CloseClipboard();
292 /**************************************************************************
293 * EmptyClipboard (USER.139)
295 BOOL16 WINAPI
EmptyClipboard16(void)
297 return EmptyClipboard();
301 /**************************************************************************
302 * CountClipboardFormats (USER.143)
304 INT16 WINAPI
CountClipboardFormats16(void)
306 return CountClipboardFormats();
310 /**************************************************************************
311 * EnumClipboardFormats (USER.144)
313 UINT16 WINAPI
EnumClipboardFormats16( UINT16 id
)
315 return EnumClipboardFormats( id
);
319 /**************************************************************************
320 * RegisterClipboardFormat (USER.145)
322 UINT16 WINAPI
RegisterClipboardFormat16( LPCSTR name
)
324 return RegisterClipboardFormatA( name
);
328 /**************************************************************************
329 * GetClipboardFormatName (USER.146)
331 INT16 WINAPI
GetClipboardFormatName16( UINT16 id
, LPSTR buffer
, INT16 maxlen
)
333 return GetClipboardFormatNameA( id
, buffer
, maxlen
);
337 /**********************************************************************
338 * CreateMenu (USER.151)
340 HMENU16 WINAPI
CreateMenu16(void)
342 return HMENU_16( CreateMenu() );
346 /**********************************************************************
347 * DestroyMenu (USER.152)
349 BOOL16 WINAPI
DestroyMenu16( HMENU16 hMenu
)
351 return DestroyMenu( HMENU_32(hMenu
) );
355 /*******************************************************************
356 * ChangeMenu (USER.153)
358 BOOL16 WINAPI
ChangeMenu16( HMENU16 hMenu
, UINT16 pos
, SEGPTR data
,
359 UINT16 id
, UINT16 flags
)
361 if (flags
& MF_APPEND
) return AppendMenu16( hMenu
, flags
& ~MF_APPEND
, id
, data
);
363 /* FIXME: Word passes the item id in 'pos' and 0 or 0xffff as id */
364 /* for MF_DELETE. We should check the parameters for all others */
365 /* MF_* actions also (anybody got a doc on ChangeMenu?). */
367 if (flags
& MF_DELETE
) return DeleteMenu16(hMenu
, pos
, flags
& ~MF_DELETE
);
368 if (flags
& MF_CHANGE
) return ModifyMenu16(hMenu
, pos
, flags
& ~MF_CHANGE
, id
, data
);
369 if (flags
& MF_REMOVE
) return RemoveMenu16(hMenu
, flags
& MF_BYPOSITION
? pos
: id
,
370 flags
& ~MF_REMOVE
);
371 /* Default: MF_INSERT */
372 return InsertMenu16( hMenu
, pos
, flags
, id
, data
);
376 /*******************************************************************
377 * CheckMenuItem (USER.154)
379 BOOL16 WINAPI
CheckMenuItem16( HMENU16 hMenu
, UINT16 id
, UINT16 flags
)
381 return CheckMenuItem( HMENU_32(hMenu
), id
, flags
);
385 /**********************************************************************
386 * EnableMenuItem (USER.155)
388 UINT16 WINAPI
EnableMenuItem16( HMENU16 hMenu
, UINT16 wItemID
, UINT16 wFlags
)
390 return EnableMenuItem( HMENU_32(hMenu
), wItemID
, wFlags
);
394 /**********************************************************************
395 * GetSubMenu (USER.159)
397 HMENU16 WINAPI
GetSubMenu16( HMENU16 hMenu
, INT16 nPos
)
399 return HMENU_16( GetSubMenu( HMENU_32(hMenu
), nPos
) );
403 /*******************************************************************
404 * GetMenuString (USER.161)
406 INT16 WINAPI
GetMenuString16( HMENU16 hMenu
, UINT16 wItemID
,
407 LPSTR str
, INT16 nMaxSiz
, UINT16 wFlags
)
409 return GetMenuStringA( HMENU_32(hMenu
), wItemID
, str
, nMaxSiz
, wFlags
);
413 /**********************************************************************
416 BOOL16 WINAPI
WinHelp16( HWND16 hWnd
, LPCSTR lpHelpFile
, UINT16 wCommand
,
422 /* We might call WinExec() */
423 ReleaseThunkLock(&mutex_count
);
425 ret
= WinHelpA(WIN_Handle32(hWnd
), lpHelpFile
, wCommand
, (DWORD
)MapSL(dwData
));
427 RestoreThunkLock(mutex_count
);
432 /***********************************************************************
433 * LoadCursor (USER.173)
435 HCURSOR16 WINAPI
LoadCursor16(HINSTANCE16 hInstance
, LPCSTR name
)
437 return HCURSOR_16(LoadCursorA(HINSTANCE_32(hInstance
), name
));
441 /***********************************************************************
442 * LoadIcon (USER.174)
444 HICON16 WINAPI
LoadIcon16(HINSTANCE16 hInstance
, LPCSTR name
)
446 return HICON_16(LoadIconA(HINSTANCE_32(hInstance
), name
));
449 /**********************************************************************
450 * LoadBitmap (USER.175)
452 HBITMAP16 WINAPI
LoadBitmap16(HINSTANCE16 hInstance
, LPCSTR name
)
454 return HBITMAP_16(LoadBitmapA(HINSTANCE_32(hInstance
), name
));
458 /***********************************************************************
459 * GetSystemMetrics (USER.179)
461 INT16 WINAPI
GetSystemMetrics16( INT16 index
)
463 return GetSystemMetrics( index
);
467 /*************************************************************************
468 * GetSysColor (USER.180)
470 COLORREF WINAPI
GetSysColor16( INT16 index
)
472 return GetSysColor( index
);
476 /*************************************************************************
477 * SetSysColors (USER.181)
479 VOID WINAPI
SetSysColors16( INT16 count
, const INT16
*list16
, const COLORREF
*values
)
483 if ((list
= HeapAlloc( GetProcessHeap(), 0, count
* sizeof(*list
) )))
485 for (i
= 0; i
< count
; i
++) list
[i
] = list16
[i
];
486 SetSysColors( count
, list
, values
);
487 HeapFree( GetProcessHeap(), 0, list
);
492 /***********************************************************************
493 * GrayString (USER.185)
495 BOOL16 WINAPI
GrayString16( HDC16 hdc
, HBRUSH16 hbr
, GRAYSTRINGPROC16 gsprc
,
496 LPARAM lParam
, INT16 cch
, INT16 x
, INT16 y
,
501 if (!gsprc
) return GrayStringA( HDC_32(hdc
), HBRUSH_32(hbr
), NULL
,
502 (LPARAM
)MapSL(lParam
), cch
, x
, y
, cx
, cy
);
504 if (cch
== -1 || (cch
&& cx
&& cy
))
506 /* lParam can be treated as an opaque pointer */
507 struct gray_string_info info
;
511 ret
= GrayStringA( HDC_32(hdc
), HBRUSH_32(hbr
), gray_string_callback
,
512 (LPARAM
)&info
, cch
, x
, y
, cx
, cy
);
514 else /* here we need some string conversions */
516 char *str16
= MapSL(lParam
);
517 struct gray_string_info
*info
;
519 if (!cch
) cch
= strlen(str16
);
520 if (!(info
= HeapAlloc( GetProcessHeap(), 0, sizeof(*info
) + cch
))) return FALSE
;
522 info
->param
= lParam
;
523 memcpy( info
->str
, str16
, cch
);
524 ret
= GrayStringA( HDC_32(hdc
), HBRUSH_32(hbr
), gray_string_callback_ptr
,
525 (LPARAM
)info
->str
, cch
, x
, y
, cx
, cy
);
526 HeapFree( GetProcessHeap(), 0, info
);
532 /**************************************************************************
533 * IsClipboardFormatAvailable (USER.193)
535 BOOL16 WINAPI
IsClipboardFormatAvailable16( UINT16 wFormat
)
537 return IsClipboardFormatAvailable( wFormat
);
541 /***********************************************************************
542 * TabbedTextOut (USER.196)
544 LONG WINAPI
TabbedTextOut16( HDC16 hdc
, INT16 x
, INT16 y
, LPCSTR lpstr
,
545 INT16 count
, INT16 nb_tabs
, const INT16
*tabs16
, INT16 tab_org
)
548 INT i
, *tabs
= HeapAlloc( GetProcessHeap(), 0, nb_tabs
* sizeof(tabs
) );
550 for (i
= 0; i
< nb_tabs
; i
++) tabs
[i
] = tabs16
[i
];
551 ret
= TabbedTextOutA( HDC_32(hdc
), x
, y
, lpstr
, count
, nb_tabs
, tabs
, tab_org
);
552 HeapFree( GetProcessHeap(), 0, tabs
);
557 /***********************************************************************
558 * GetTabbedTextExtent (USER.197)
560 DWORD WINAPI
GetTabbedTextExtent16( HDC16 hdc
, LPCSTR lpstr
, INT16 count
,
561 INT16 nb_tabs
, const INT16
*tabs16
)
564 INT i
, *tabs
= HeapAlloc( GetProcessHeap(), 0, nb_tabs
* sizeof(tabs
) );
566 for (i
= 0; i
< nb_tabs
; i
++) tabs
[i
] = tabs16
[i
];
567 ret
= GetTabbedTextExtentA( HDC_32(hdc
), lpstr
, count
, nb_tabs
, tabs
);
568 HeapFree( GetProcessHeap(), 0, tabs
);
573 /*************************************************************************
574 * ScrollDC (USER.221)
576 BOOL16 WINAPI
ScrollDC16( HDC16 hdc
, INT16 dx
, INT16 dy
, const RECT16
*rect
,
577 const RECT16
*cliprc
, HRGN16 hrgnUpdate
,
580 RECT rect32
, clipRect32
, rcUpdate32
;
585 rect32
.left
= rect
->left
;
586 rect32
.top
= rect
->top
;
587 rect32
.right
= rect
->right
;
588 rect32
.bottom
= rect
->bottom
;
592 clipRect32
.left
= cliprc
->left
;
593 clipRect32
.top
= cliprc
->top
;
594 clipRect32
.right
= cliprc
->right
;
595 clipRect32
.bottom
= cliprc
->bottom
;
597 ret
= ScrollDC( HDC_32(hdc
), dx
, dy
, rect
? &rect32
: NULL
,
598 cliprc
? &clipRect32
: NULL
, HRGN_32(hrgnUpdate
),
602 rcUpdate
->left
= rcUpdate32
.left
;
603 rcUpdate
->top
= rcUpdate32
.top
;
604 rcUpdate
->right
= rcUpdate32
.right
;
605 rcUpdate
->bottom
= rcUpdate32
.bottom
;
611 /***********************************************************************
612 * GetSystemDebugState (USER.231)
614 WORD WINAPI
GetSystemDebugState16(void)
616 return 0; /* FIXME */
620 /***********************************************************************
621 * ExitWindowsExec (USER.246)
623 BOOL16 WINAPI
ExitWindowsExec16( LPCSTR lpszExe
, LPCSTR lpszParams
)
625 TRACE("Should run the following in DOS-mode: \"%s %s\"\n",
626 lpszExe
, lpszParams
);
627 return ExitWindowsEx( EWX_LOGOFF
, 0xffffffff );
631 /***********************************************************************
632 * GetCursor (USER.247)
634 HCURSOR16 WINAPI
GetCursor16(void)
636 return HCURSOR_16(GetCursor());
640 /**********************************************************************
641 * GetAsyncKeyState (USER.249)
643 INT16 WINAPI
GetAsyncKeyState16( INT16 key
)
645 return GetAsyncKeyState( key
);
649 /**********************************************************************
650 * GetMenuState (USER.250)
652 UINT16 WINAPI
GetMenuState16( HMENU16 hMenu
, UINT16 wItemID
, UINT16 wFlags
)
654 return GetMenuState( HMENU_32(hMenu
), wItemID
, wFlags
);
658 /**********************************************************************
659 * GetMenuItemCount (USER.263)
661 INT16 WINAPI
GetMenuItemCount16( HMENU16 hMenu
)
663 return GetMenuItemCount( HMENU_32(hMenu
) );
667 /**********************************************************************
668 * GetMenuItemID (USER.264)
670 UINT16 WINAPI
GetMenuItemID16( HMENU16 hMenu
, INT16 nPos
)
672 return GetMenuItemID( HMENU_32(hMenu
), nPos
);
676 /***********************************************************************
677 * GlobalAddAtom (USER.268)
679 ATOM WINAPI
GlobalAddAtom16(LPCSTR lpString
)
681 return GlobalAddAtomA(lpString
);
684 /***********************************************************************
685 * GlobalDeleteAtom (USER.269)
687 ATOM WINAPI
GlobalDeleteAtom16(ATOM nAtom
)
689 return GlobalDeleteAtom(nAtom
);
692 /***********************************************************************
693 * GlobalFindAtom (USER.270)
695 ATOM WINAPI
GlobalFindAtom16(LPCSTR lpString
)
697 return GlobalFindAtomA(lpString
);
700 /***********************************************************************
701 * GlobalGetAtomName (USER.271)
703 UINT16 WINAPI
GlobalGetAtomName16(ATOM nAtom
, LPSTR lpBuffer
, INT16 nSize
)
705 return GlobalGetAtomNameA(nAtom
, lpBuffer
, nSize
);
709 /***********************************************************************
710 * GetSysColorBrush (USER.281)
712 HBRUSH16 WINAPI
GetSysColorBrush16( INT16 index
)
714 return HBRUSH_16( GetSysColorBrush(index
) );
718 /***********************************************************************
719 * SelectPalette (USER.282)
721 HPALETTE16 WINAPI
SelectPalette16( HDC16 hdc
, HPALETTE16 hpal
, BOOL16 bForceBackground
)
723 return HPALETTE_16( SelectPalette( HDC_32(hdc
), HPALETTE_32(hpal
), bForceBackground
));
726 /***********************************************************************
727 * RealizePalette (USER.283)
729 UINT16 WINAPI
RealizePalette16( HDC16 hdc
)
731 return UserRealizePalette( HDC_32(hdc
) );
735 /***********************************************************************
736 * GetClipCursor (USER.309)
738 void WINAPI
GetClipCursor16( RECT16
*rect
)
743 GetClipCursor( &rect32
);
744 rect
->left
= rect32
.left
;
745 rect
->top
= rect32
.top
;
746 rect
->right
= rect32
.right
;
747 rect
->bottom
= rect32
.bottom
;
752 /***********************************************************************
753 * SignalProc (USER.314)
755 void WINAPI
SignalProc16( HANDLE16 hModule
, UINT16 code
,
756 UINT16 uExitFn
, HINSTANCE16 hInstance
, HQUEUE16 hQueue
)
758 if (code
== USIG16_DLL_UNLOAD
)
760 /* HOOK_FreeModuleHooks( hModule ); */
761 CLASS_FreeModuleClasses( hModule
);
762 CURSORICON_FreeModuleIcons( hModule
);
767 /***********************************************************************
768 * SetEventHook (USER.321)
770 * Used by Turbo Debugger for Windows
772 FARPROC16 WINAPI
SetEventHook16(FARPROC16 lpfnEventHook
)
774 FIXME("(lpfnEventHook=%p): stub\n", lpfnEventHook
);
779 /**********************************************************************
780 * EnableHardwareInput (USER.331)
782 BOOL16 WINAPI
EnableHardwareInput16(BOOL16 bEnable
)
784 FIXME("(%d) - stub\n", bEnable
);
789 /***********************************************************************
790 * IsUserIdle (USER.333)
792 BOOL16 WINAPI
IsUserIdle16(void)
794 if ( GetAsyncKeyState( VK_LBUTTON
) & 0x8000 )
796 if ( GetAsyncKeyState( VK_RBUTTON
) & 0x8000 )
798 if ( GetAsyncKeyState( VK_MBUTTON
) & 0x8000 )
800 /* Should check for screen saver activation here ... */
805 /**********************************************************************
808 BOOL16 WINAPI
IsMenu16( HMENU16 hmenu
)
810 return IsMenu( HMENU_32(hmenu
) );
814 /**********************************************************************
815 * SetMenuContextHelpId (USER.384)
817 BOOL16 WINAPI
SetMenuContextHelpId16( HMENU16 hMenu
, DWORD dwContextHelpID
)
819 return SetMenuContextHelpId( HMENU_32(hMenu
), dwContextHelpID
);
823 /**********************************************************************
824 * GetMenuContextHelpId (USER.385)
826 DWORD WINAPI
GetMenuContextHelpId16( HMENU16 hMenu
)
828 return GetMenuContextHelpId( HMENU_32(hMenu
) );
832 /***********************************************************************
833 * LoadImage (USER.389)
836 HANDLE16 WINAPI
LoadImage16(HINSTANCE16 hinst
, LPCSTR name
, UINT16 type
,
837 INT16 desiredx
, INT16 desiredy
, UINT16 loadflags
)
839 return HANDLE_16(LoadImageA(HINSTANCE_32(hinst
), name
, type
, desiredx
,
840 desiredy
, loadflags
));
843 /******************************************************************************
844 * CopyImage (USER.390) Creates new image and copies attributes to it
847 HICON16 WINAPI
CopyImage16(HANDLE16 hnd
, UINT16 type
, INT16 desiredx
,
848 INT16 desiredy
, UINT16 flags
)
850 return HICON_16(CopyImage(HANDLE_32(hnd
), (UINT
)type
, (INT
)desiredx
,
851 (INT
)desiredy
, (UINT
)flags
));
854 /**********************************************************************
855 * DrawIconEx (USER.394)
857 BOOL16 WINAPI
DrawIconEx16(HDC16 hdc
, INT16 xLeft
, INT16 yTop
, HICON16 hIcon
,
858 INT16 cxWidth
, INT16 cyWidth
, UINT16 istep
,
859 HBRUSH16 hbr
, UINT16 flags
)
861 return DrawIconEx(HDC_32(hdc
), xLeft
, yTop
, HICON_32(hIcon
), cxWidth
, cyWidth
,
862 istep
, HBRUSH_32(hbr
), flags
);
865 /**********************************************************************
866 * GetIconInfo (USER.395)
868 BOOL16 WINAPI
GetIconInfo16(HICON16 hIcon
, LPICONINFO16 iconinfo
)
871 BOOL16 ret
= GetIconInfo(HICON_32(hIcon
), &ii32
);
873 iconinfo
->fIcon
= ii32
.fIcon
;
874 iconinfo
->xHotspot
= ii32
.xHotspot
;
875 iconinfo
->yHotspot
= ii32
.yHotspot
;
876 iconinfo
->hbmMask
= HBITMAP_16(ii32
.hbmMask
);
877 iconinfo
->hbmColor
= HBITMAP_16(ii32
.hbmColor
);
882 /***********************************************************************
883 * FinalUserInit (USER.400)
885 void WINAPI
FinalUserInit16( void )
887 /* FIXME: Should chain to FinalGdiInit */
891 /***********************************************************************
892 * CreateCursor (USER.406)
894 HCURSOR16 WINAPI
CreateCursor16(HINSTANCE16 hInstance
,
895 INT16 xHotSpot
, INT16 yHotSpot
,
896 INT16 nWidth
, INT16 nHeight
,
897 LPCVOID lpANDbits
, LPCVOID lpXORbits
)
901 info
.ptHotSpot
.x
= xHotSpot
;
902 info
.ptHotSpot
.y
= yHotSpot
;
903 info
.nWidth
= nWidth
;
904 info
.nHeight
= nHeight
;
905 info
.nWidthBytes
= 0;
907 info
.bBitsPerPixel
= 1;
909 return CreateCursorIconIndirect16(hInstance
, &info
, lpANDbits
, lpXORbits
);
913 /*******************************************************************
914 * InsertMenu (USER.410)
916 BOOL16 WINAPI
InsertMenu16( HMENU16 hMenu
, UINT16 pos
, UINT16 flags
,
917 UINT16 id
, SEGPTR data
)
919 UINT pos32
= (UINT
)pos
;
920 if ((pos
== (UINT16
)-1) && (flags
& MF_BYPOSITION
)) pos32
= (UINT
)-1;
921 if (IS_MENU_STRING_ITEM(flags
) && data
)
922 return InsertMenuA( HMENU_32(hMenu
), pos32
, flags
, id
, MapSL(data
) );
923 return InsertMenuA( HMENU_32(hMenu
), pos32
, flags
, id
, (LPSTR
)data
);
927 /*******************************************************************
928 * AppendMenu (USER.411)
930 BOOL16 WINAPI
AppendMenu16(HMENU16 hMenu
, UINT16 flags
, UINT16 id
, SEGPTR data
)
932 return InsertMenu16( hMenu
, -1, flags
| MF_BYPOSITION
, id
, data
);
936 /**********************************************************************
937 * RemoveMenu (USER.412)
939 BOOL16 WINAPI
RemoveMenu16( HMENU16 hMenu
, UINT16 nPos
, UINT16 wFlags
)
941 return RemoveMenu( HMENU_32(hMenu
), nPos
, wFlags
);
945 /**********************************************************************
946 * DeleteMenu (USER.413)
948 BOOL16 WINAPI
DeleteMenu16( HMENU16 hMenu
, UINT16 nPos
, UINT16 wFlags
)
950 return DeleteMenu( HMENU_32(hMenu
), nPos
, wFlags
);
954 /*******************************************************************
955 * ModifyMenu (USER.414)
957 BOOL16 WINAPI
ModifyMenu16( HMENU16 hMenu
, UINT16 pos
, UINT16 flags
,
958 UINT16 id
, SEGPTR data
)
960 if (IS_MENU_STRING_ITEM(flags
))
961 return ModifyMenuA( HMENU_32(hMenu
), pos
, flags
, id
, MapSL(data
) );
962 return ModifyMenuA( HMENU_32(hMenu
), pos
, flags
, id
, (LPSTR
)data
);
966 /**********************************************************************
967 * CreatePopupMenu (USER.415)
969 HMENU16 WINAPI
CreatePopupMenu16(void)
971 return HMENU_16( CreatePopupMenu() );
975 /**********************************************************************
976 * SetMenuItemBitmaps (USER.418)
978 BOOL16 WINAPI
SetMenuItemBitmaps16( HMENU16 hMenu
, UINT16 nPos
, UINT16 wFlags
,
979 HBITMAP16 hNewUnCheck
, HBITMAP16 hNewCheck
)
981 return SetMenuItemBitmaps( HMENU_32(hMenu
), nPos
, wFlags
,
982 HBITMAP_32(hNewUnCheck
), HBITMAP_32(hNewCheck
) );
986 /*******************************************************************
987 * InsertMenuItem (USER.441)
991 BOOL16 WINAPI
InsertMenuItem16( HMENU16 hmenu
, UINT16 pos
, BOOL16 byposition
,
992 const MENUITEMINFO16
*mii
)
996 miia
.cbSize
= sizeof(miia
);
997 miia
.fMask
= mii
->fMask
;
998 miia
.dwTypeData
= (LPSTR
)mii
->dwTypeData
;
999 miia
.fType
= mii
->fType
;
1000 miia
.fState
= mii
->fState
;
1001 miia
.wID
= mii
->wID
;
1002 miia
.hSubMenu
= HMENU_32(mii
->hSubMenu
);
1003 miia
.hbmpChecked
= HBITMAP_32(mii
->hbmpChecked
);
1004 miia
.hbmpUnchecked
= HBITMAP_32(mii
->hbmpUnchecked
);
1005 miia
.dwItemData
= mii
->dwItemData
;
1006 miia
.cch
= mii
->cch
;
1007 if (IS_MENU_STRING_ITEM(miia
.fType
))
1008 miia
.dwTypeData
= MapSL(mii
->dwTypeData
);
1009 return InsertMenuItemA( HMENU_32(hmenu
), pos
, byposition
, &miia
);
1013 /**********************************************************************
1014 * DrawState (USER.449)
1016 BOOL16 WINAPI
DrawState16( HDC16 hdc
, HBRUSH16 hbr
, DRAWSTATEPROC16 func
, LPARAM ldata
,
1017 WPARAM16 wdata
, INT16 x
, INT16 y
, INT16 cx
, INT16 cy
, UINT16 flags
)
1019 struct draw_state_info info
;
1020 UINT opcode
= flags
& 0xf;
1022 if (opcode
== DST_TEXT
|| opcode
== DST_PREFIXTEXT
)
1024 /* make sure DrawStateA doesn't try to use ldata as a pointer */
1025 if (!wdata
) wdata
= strlen( MapSL(ldata
) );
1029 if (!GetTextExtentPoint32A( HDC_32(hdc
), MapSL(ldata
), wdata
, &s
)) return FALSE
;
1036 return DrawStateA( HDC_32(hdc
), HBRUSH_32(hbr
), draw_state_callback
,
1037 (LPARAM
)&info
, wdata
, x
, y
, cx
, cy
, flags
);
1041 /**********************************************************************
1042 * CreateIconFromResourceEx (USER.450)
1044 * FIXME: not sure about exact parameter types
1046 HICON16 WINAPI
CreateIconFromResourceEx16(LPBYTE bits
, UINT16 cbSize
,
1047 BOOL16 bIcon
, DWORD dwVersion
,
1048 INT16 width
, INT16 height
,
1051 return HICON_16(CreateIconFromResourceEx(bits
, cbSize
, bIcon
, dwVersion
,
1052 width
, height
, cFlag
));
1056 /***********************************************************************
1057 * AdjustWindowRectEx (USER.454)
1059 BOOL16 WINAPI
AdjustWindowRectEx16( LPRECT16 rect
, DWORD style
, BOOL16 menu
, DWORD exStyle
)
1064 rect32
.left
= rect
->left
;
1065 rect32
.top
= rect
->top
;
1066 rect32
.right
= rect
->right
;
1067 rect32
.bottom
= rect
->bottom
;
1068 ret
= AdjustWindowRectEx( &rect32
, style
, menu
, exStyle
);
1069 rect
->left
= rect32
.left
;
1070 rect
->top
= rect32
.top
;
1071 rect
->right
= rect32
.right
;
1072 rect
->bottom
= rect32
.bottom
;
1077 /***********************************************************************
1078 * DestroyIcon (USER.457)
1080 BOOL16 WINAPI
DestroyIcon16(HICON16 hIcon
)
1082 return DestroyIcon32(hIcon
, 0);
1085 /***********************************************************************
1086 * DestroyCursor (USER.458)
1088 BOOL16 WINAPI
DestroyCursor16(HCURSOR16 hCursor
)
1090 return DestroyIcon32(hCursor
, 0);
1093 /*******************************************************************
1094 * DRAG_QueryUpdate16
1096 * Recursively find a child that contains spDragInfo->pt point
1097 * and send WM_QUERYDROPOBJECT. Helper for DragObject16.
1099 static BOOL
DRAG_QueryUpdate16( HWND hQueryWnd
, SEGPTR spDragInfo
)
1104 LPDRAGINFO16 ptrDragInfo
= MapSL(spDragInfo
);
1108 if (!IsWindowEnabled(hQueryWnd
)) return FALSE
;
1110 old_pt
.x
= ptrDragInfo
->pt
.x
;
1111 old_pt
.y
= ptrDragInfo
->pt
.y
;
1113 ScreenToClient( hQueryWnd
, &pt
);
1114 child
= ChildWindowFromPointEx( hQueryWnd
, pt
, CWP_SKIPINVISIBLE
);
1115 if (!child
) return FALSE
;
1117 if (child
!= hQueryWnd
)
1120 if (DRAG_QueryUpdate16( child
, spDragInfo
)) return TRUE
;
1124 GetClientRect( hQueryWnd
, &tempRect
);
1125 wParam
= !PtInRect( &tempRect
, pt
);
1128 ptrDragInfo
->pt
.x
= pt
.x
;
1129 ptrDragInfo
->pt
.y
= pt
.y
;
1130 ptrDragInfo
->hScope
= HWND_16(hQueryWnd
);
1132 bResult
= SendMessage16( HWND_16(hQueryWnd
), WM_QUERYDROPOBJECT
, wParam
, spDragInfo
);
1136 ptrDragInfo
->pt
.x
= old_pt
.x
;
1137 ptrDragInfo
->pt
.y
= old_pt
.y
;
1143 /******************************************************************************
1144 * DragObject (USER.464)
1146 DWORD WINAPI
DragObject16( HWND16 hwndScope
, HWND16 hWnd
, UINT16 wObj
,
1147 HANDLE16 hOfStruct
, WORD szList
, HCURSOR16 hCursor
)
1150 LPDRAGINFO16 lpDragInfo
;
1152 HCURSOR hOldCursor
=0, hBummer
=0;
1153 HGLOBAL16 hDragInfo
= GlobalAlloc16( GMEM_SHARE
| GMEM_ZEROINIT
, 2*sizeof(DRAGINFO16
));
1154 HCURSOR hCurrentCursor
= 0;
1155 HWND16 hCurrentWnd
= 0;
1157 lpDragInfo
= (LPDRAGINFO16
) GlobalLock16(hDragInfo
);
1158 spDragInfo
= K32WOWGlobalLock16(hDragInfo
);
1160 if( !lpDragInfo
|| !spDragInfo
) return 0L;
1162 if (!(hBummer
= LoadCursorA(0, MAKEINTRESOURCEA(OCR_NO
))))
1164 GlobalFree16(hDragInfo
);
1168 if(hCursor
) hOldCursor
= SetCursor(HCURSOR_32(hCursor
));
1170 lpDragInfo
->hWnd
= hWnd
;
1171 lpDragInfo
->hScope
= 0;
1172 lpDragInfo
->wFlags
= wObj
;
1173 lpDragInfo
->hList
= szList
; /* near pointer! */
1174 lpDragInfo
->hOfStruct
= hOfStruct
;
1177 SetCapture( HWND_32(hWnd
) );
1182 GetMessageW( &msg
, 0, WM_MOUSEFIRST
, WM_MOUSELAST
);
1184 *(lpDragInfo
+1) = *lpDragInfo
;
1186 lpDragInfo
->pt
.x
= msg
.pt
.x
;
1187 lpDragInfo
->pt
.y
= msg
.pt
.y
;
1189 /* update DRAGINFO struct */
1190 if( DRAG_QueryUpdate16(WIN_Handle32(hwndScope
), spDragInfo
) > 0 )
1191 hCurrentCursor
= HCURSOR_32(hCursor
);
1194 hCurrentCursor
= hBummer
;
1195 lpDragInfo
->hScope
= 0;
1197 if( hCurrentCursor
)
1198 SetCursor(hCurrentCursor
);
1200 /* send WM_DRAGLOOP */
1201 SendMessage16( hWnd
, WM_DRAGLOOP
, (WPARAM16
)(hCurrentCursor
!= hBummer
),
1202 (LPARAM
) spDragInfo
);
1203 /* send WM_DRAGSELECT or WM_DRAGMOVE */
1204 if( hCurrentWnd
!= lpDragInfo
->hScope
)
1207 SendMessage16( hCurrentWnd
, WM_DRAGSELECT
, 0,
1208 (LPARAM
)MAKELONG(LOWORD(spDragInfo
)+sizeof(DRAGINFO16
),
1209 HIWORD(spDragInfo
)) );
1210 hCurrentWnd
= lpDragInfo
->hScope
;
1212 SendMessage16( hCurrentWnd
, WM_DRAGSELECT
, 1, (LPARAM
)spDragInfo
);
1216 SendMessage16( hCurrentWnd
, WM_DRAGMOVE
, 0, (LPARAM
)spDragInfo
);
1218 } while( msg
.message
!= WM_LBUTTONUP
&& msg
.message
!= WM_NCLBUTTONUP
);
1221 ShowCursor( FALSE
);
1223 if( hCursor
) SetCursor(hOldCursor
);
1225 if( hCurrentCursor
!= hBummer
)
1226 msg
.lParam
= SendMessage16( lpDragInfo
->hScope
, WM_DROPOBJECT
,
1227 (WPARAM16
)hWnd
, (LPARAM
)spDragInfo
);
1230 GlobalFree16(hDragInfo
);
1232 return (DWORD
)(msg
.lParam
);
1236 /***********************************************************************
1237 * DrawFocusRect (USER.466)
1239 void WINAPI
DrawFocusRect16( HDC16 hdc
, const RECT16
* rc
)
1243 rect32
.left
= rc
->left
;
1244 rect32
.top
= rc
->top
;
1245 rect32
.right
= rc
->right
;
1246 rect32
.bottom
= rc
->bottom
;
1247 DrawFocusRect( HDC_32(hdc
), &rect32
);
1251 /***********************************************************************
1252 * ChangeDisplaySettings (USER.620)
1254 LONG WINAPI
ChangeDisplaySettings16( LPDEVMODEA devmode
, DWORD flags
)
1256 return ChangeDisplaySettingsA( devmode
, flags
);
1260 /***********************************************************************
1261 * EnumDisplaySettings (USER.621)
1263 BOOL16 WINAPI
EnumDisplaySettings16( LPCSTR name
, DWORD n
, LPDEVMODEA devmode
)
1265 return EnumDisplaySettingsA( name
, n
, devmode
);
1268 /**********************************************************************
1269 * DrawFrameControl (USER.656)
1271 BOOL16 WINAPI
DrawFrameControl16( HDC16 hdc
, LPRECT16 rc
, UINT16 uType
, UINT16 uState
)
1276 rect32
.left
= rc
->left
;
1277 rect32
.top
= rc
->top
;
1278 rect32
.right
= rc
->right
;
1279 rect32
.bottom
= rc
->bottom
;
1280 ret
= DrawFrameControl( HDC_32(hdc
), &rect32
, uType
, uState
);
1281 rc
->left
= rect32
.left
;
1282 rc
->top
= rect32
.top
;
1283 rc
->right
= rect32
.right
;
1284 rc
->bottom
= rect32
.bottom
;
1288 /**********************************************************************
1289 * DrawEdge (USER.659)
1291 BOOL16 WINAPI
DrawEdge16( HDC16 hdc
, LPRECT16 rc
, UINT16 edge
, UINT16 flags
)
1296 rect32
.left
= rc
->left
;
1297 rect32
.top
= rc
->top
;
1298 rect32
.right
= rc
->right
;
1299 rect32
.bottom
= rc
->bottom
;
1300 ret
= DrawEdge( HDC_32(hdc
), &rect32
, edge
, flags
);
1301 rc
->left
= rect32
.left
;
1302 rc
->top
= rect32
.top
;
1303 rc
->right
= rect32
.right
;
1304 rc
->bottom
= rect32
.bottom
;
1308 /**********************************************************************
1309 * CheckMenuRadioItem (USER.666)
1311 BOOL16 WINAPI
CheckMenuRadioItem16(HMENU16 hMenu
, UINT16 first
, UINT16 last
,
1312 UINT16 check
, BOOL16 bypos
)
1314 return CheckMenuRadioItem( HMENU_32(hMenu
), first
, last
, check
, bypos
);