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
);
59 WORD USER_HeapSel
= 0; /* USER heap selector */
61 struct gray_string_info
63 GRAYSTRINGPROC16 proc
;
68 /* callback for 16-bit gray string proc with opaque pointer */
69 static BOOL CALLBACK
gray_string_callback( HDC hdc
, LPARAM param
, INT len
)
71 const struct gray_string_info
*info
= (struct gray_string_info
*)param
;
75 args
[3] = HDC_16(hdc
);
76 args
[2] = HIWORD(info
->param
);
77 args
[1] = LOWORD(info
->param
);
79 WOWCallback16Ex( (DWORD
)info
->proc
, WCB16_PASCAL
, sizeof(args
), args
, &ret
);
83 /* callback for 16-bit gray string proc with string pointer */
84 static BOOL CALLBACK
gray_string_callback_ptr( HDC hdc
, LPARAM param
, INT len
)
86 const struct gray_string_info
*info
;
87 char *str
= (char *)param
;
89 info
= (struct gray_string_info
*)(str
- offsetof( struct gray_string_info
, str
));
90 return gray_string_callback( hdc
, (LPARAM
)info
, len
);
93 struct draw_state_info
99 /* callback for 16-bit DrawState functions */
100 static BOOL CALLBACK
draw_state_callback( HDC hdc
, LPARAM lparam
, WPARAM wparam
, int cx
, int cy
)
102 const struct draw_state_info
*info
= (struct draw_state_info
*)lparam
;
106 args
[5] = HDC_16(hdc
);
107 args
[4] = HIWORD(info
->param
);
108 args
[3] = LOWORD(info
->param
);
112 WOWCallback16Ex( (DWORD
)info
->proc
, WCB16_PASCAL
, sizeof(args
), args
, &ret
);
117 /**********************************************************************
120 INT16 WINAPI
InitApp16( HINSTANCE16 hInstance
)
122 /* Create task message queue */
123 return (InitThreadInput16( 0, 0 ) != 0);
127 /***********************************************************************
128 * ExitWindows (USER.7)
130 BOOL16 WINAPI
ExitWindows16( DWORD dwReturnCode
, UINT16 wReserved
)
132 return ExitWindowsEx( EWX_LOGOFF
, 0xffffffff );
136 /***********************************************************************
137 * GetTimerResolution (USER.14)
139 LONG WINAPI
GetTimerResolution16(void)
145 /***********************************************************************
146 * ClipCursor (USER.16)
148 BOOL16 WINAPI
ClipCursor16( const RECT16
*rect
)
152 if (!rect
) return ClipCursor( NULL
);
153 rect32
.left
= rect
->left
;
154 rect32
.top
= rect
->top
;
155 rect32
.right
= rect
->right
;
156 rect32
.bottom
= rect
->bottom
;
157 return ClipCursor( &rect32
);
161 /***********************************************************************
162 * GetCursorPos (USER.17)
164 BOOL16 WINAPI
GetCursorPos16( POINT16
*pt
)
175 /***********************************************************************
176 * SetCursor (USER.69)
178 HCURSOR16 WINAPI
SetCursor16(HCURSOR16 hCursor
)
180 return HCURSOR_16(SetCursor(HCURSOR_32(hCursor
)));
184 /***********************************************************************
185 * SetCursorPos (USER.70)
187 void WINAPI
SetCursorPos16( INT16 x
, INT16 y
)
189 SetCursorPos( x
, y
);
193 /***********************************************************************
194 * ShowCursor (USER.71)
196 INT16 WINAPI
ShowCursor16(BOOL16 bShow
)
198 return ShowCursor(bShow
);
202 /***********************************************************************
205 void WINAPI
SetRect16( LPRECT16 rect
, INT16 left
, INT16 top
, INT16 right
, INT16 bottom
)
210 rect
->bottom
= bottom
;
214 /***********************************************************************
215 * SetRectEmpty (USER.73)
217 void WINAPI
SetRectEmpty16( LPRECT16 rect
)
219 rect
->left
= rect
->right
= rect
->top
= rect
->bottom
= 0;
223 /***********************************************************************
226 BOOL16 WINAPI
CopyRect16( RECT16
*dest
, const RECT16
*src
)
233 /***********************************************************************
234 * IsRectEmpty (USER.75)
236 * Bug compat: Windows checks for 0 or negative width/height.
238 BOOL16 WINAPI
IsRectEmpty16( const RECT16
*rect
)
240 return ((rect
->left
>= rect
->right
) || (rect
->top
>= rect
->bottom
));
244 /***********************************************************************
247 BOOL16 WINAPI
PtInRect16( const RECT16
*rect
, POINT16 pt
)
249 return ((pt
.x
>= rect
->left
) && (pt
.x
< rect
->right
) &&
250 (pt
.y
>= rect
->top
) && (pt
.y
< rect
->bottom
));
254 /***********************************************************************
255 * OffsetRect (USER.77)
257 void WINAPI
OffsetRect16( LPRECT16 rect
, INT16 x
, INT16 y
)
266 /***********************************************************************
267 * InflateRect (USER.78)
269 void WINAPI
InflateRect16( LPRECT16 rect
, INT16 x
, INT16 y
)
278 /***********************************************************************
279 * IntersectRect (USER.79)
281 BOOL16 WINAPI
IntersectRect16( LPRECT16 dest
, const RECT16
*src1
,
284 if (IsRectEmpty16(src1
) || IsRectEmpty16(src2
) ||
285 (src1
->left
>= src2
->right
) || (src2
->left
>= src1
->right
) ||
286 (src1
->top
>= src2
->bottom
) || (src2
->top
>= src1
->bottom
))
288 SetRectEmpty16( dest
);
291 dest
->left
= max( src1
->left
, src2
->left
);
292 dest
->right
= min( src1
->right
, src2
->right
);
293 dest
->top
= max( src1
->top
, src2
->top
);
294 dest
->bottom
= min( src1
->bottom
, src2
->bottom
);
299 /***********************************************************************
300 * UnionRect (USER.80)
302 BOOL16 WINAPI
UnionRect16( LPRECT16 dest
, const RECT16
*src1
,
305 if (IsRectEmpty16(src1
))
307 if (IsRectEmpty16(src2
))
309 SetRectEmpty16( dest
);
316 if (IsRectEmpty16(src2
)) *dest
= *src1
;
319 dest
->left
= min( src1
->left
, src2
->left
);
320 dest
->right
= max( src1
->right
, src2
->right
);
321 dest
->top
= min( src1
->top
, src2
->top
);
322 dest
->bottom
= max( src1
->bottom
, src2
->bottom
);
329 /***********************************************************************
332 * The Win16 variant doesn't support special color brushes like
333 * the Win32 one, despite the fact that Win16, as well as Win32,
334 * supports special background brushes for a window class.
336 INT16 WINAPI
FillRect16( HDC16 hdc
, const RECT16
*rect
, HBRUSH16 hbrush
)
340 /* coordinates are logical so we cannot fast-check 'rect',
341 * it will be done later in the PatBlt().
344 if (!(prevBrush
= SelectObject( HDC_32(hdc
), HBRUSH_32(hbrush
) ))) return 0;
345 PatBlt( HDC_32(hdc
), rect
->left
, rect
->top
,
346 rect
->right
- rect
->left
, rect
->bottom
- rect
->top
, PATCOPY
);
347 SelectObject( HDC_32(hdc
), prevBrush
);
352 /***********************************************************************
353 * InvertRect (USER.82)
355 void WINAPI
InvertRect16( HDC16 hdc
, const RECT16
*rect
)
357 PatBlt( HDC_32(hdc
), rect
->left
, rect
->top
,
358 rect
->right
- rect
->left
, rect
->bottom
- rect
->top
, DSTINVERT
);
362 /***********************************************************************
363 * FrameRect (USER.83)
365 INT16 WINAPI
FrameRect16( HDC16 hdc
, const RECT16
*rect16
, HBRUSH16 hbrush
)
369 rect
.left
= rect16
->left
;
370 rect
.top
= rect16
->top
;
371 rect
.right
= rect16
->right
;
372 rect
.bottom
= rect16
->bottom
;
373 return FrameRect( HDC_32(hdc
), &rect
, HBRUSH_32(hbrush
) );
377 /***********************************************************************
380 BOOL16 WINAPI
DrawIcon16(HDC16 hdc
, INT16 x
, INT16 y
, HICON16 hIcon
)
382 return DrawIcon(HDC_32(hdc
), x
, y
, HICON_32(hIcon
));
386 /***********************************************************************
389 INT16 WINAPI
DrawText16( HDC16 hdc
, LPCSTR str
, INT16 count
, LPRECT16 rect
, UINT16 flags
)
397 rect32
.left
= rect
->left
;
398 rect32
.top
= rect
->top
;
399 rect32
.right
= rect
->right
;
400 rect32
.bottom
= rect
->bottom
;
401 ret
= DrawTextA( HDC_32(hdc
), str
, count
, &rect32
, flags
);
402 rect
->left
= rect32
.left
;
403 rect
->top
= rect32
.top
;
404 rect
->right
= rect32
.right
;
405 rect
->bottom
= rect32
.bottom
;
407 else ret
= DrawTextA( HDC_32(hdc
), str
, count
, NULL
, flags
);
412 /***********************************************************************
415 * See "Undocumented Windows". Used by W2.0 paint.exe.
417 DWORD WINAPI
IconSize16(void)
419 return MAKELONG(GetSystemMetrics(SM_CYICON
), GetSystemMetrics(SM_CXICON
));
423 /***********************************************************************
424 * AdjustWindowRect (USER.102)
426 BOOL16 WINAPI
AdjustWindowRect16( LPRECT16 rect
, DWORD style
, BOOL16 menu
)
428 return AdjustWindowRectEx16( rect
, style
, menu
, 0 );
432 /***********************************************************************
433 * MessageBeep (USER.104)
435 void WINAPI
MessageBeep16( UINT16 i
)
441 /**************************************************************************
442 * CloseClipboard (USER.138)
444 BOOL16 WINAPI
CloseClipboard16(void)
446 return CloseClipboard();
450 /**************************************************************************
451 * EmptyClipboard (USER.139)
453 BOOL16 WINAPI
EmptyClipboard16(void)
455 return EmptyClipboard();
459 /**************************************************************************
460 * CountClipboardFormats (USER.143)
462 INT16 WINAPI
CountClipboardFormats16(void)
464 return CountClipboardFormats();
468 /**************************************************************************
469 * EnumClipboardFormats (USER.144)
471 UINT16 WINAPI
EnumClipboardFormats16( UINT16 id
)
473 return EnumClipboardFormats( id
);
477 /**************************************************************************
478 * RegisterClipboardFormat (USER.145)
480 UINT16 WINAPI
RegisterClipboardFormat16( LPCSTR name
)
482 return RegisterClipboardFormatA( name
);
486 /**************************************************************************
487 * GetClipboardFormatName (USER.146)
489 INT16 WINAPI
GetClipboardFormatName16( UINT16 id
, LPSTR buffer
, INT16 maxlen
)
491 return GetClipboardFormatNameA( id
, buffer
, maxlen
);
495 /**********************************************************************
496 * CreateMenu (USER.151)
498 HMENU16 WINAPI
CreateMenu16(void)
500 return HMENU_16( CreateMenu() );
504 /**********************************************************************
505 * DestroyMenu (USER.152)
507 BOOL16 WINAPI
DestroyMenu16( HMENU16 hMenu
)
509 return DestroyMenu( HMENU_32(hMenu
) );
513 /*******************************************************************
514 * ChangeMenu (USER.153)
516 BOOL16 WINAPI
ChangeMenu16( HMENU16 hMenu
, UINT16 pos
, SEGPTR data
,
517 UINT16 id
, UINT16 flags
)
519 if (flags
& MF_APPEND
) return AppendMenu16( hMenu
, flags
& ~MF_APPEND
, id
, data
);
521 /* FIXME: Word passes the item id in 'pos' and 0 or 0xffff as id */
522 /* for MF_DELETE. We should check the parameters for all others */
523 /* MF_* actions also (anybody got a doc on ChangeMenu?). */
525 if (flags
& MF_DELETE
) return DeleteMenu16(hMenu
, pos
, flags
& ~MF_DELETE
);
526 if (flags
& MF_CHANGE
) return ModifyMenu16(hMenu
, pos
, flags
& ~MF_CHANGE
, id
, data
);
527 if (flags
& MF_REMOVE
) return RemoveMenu16(hMenu
, flags
& MF_BYPOSITION
? pos
: id
,
528 flags
& ~MF_REMOVE
);
529 /* Default: MF_INSERT */
530 return InsertMenu16( hMenu
, pos
, flags
, id
, data
);
534 /*******************************************************************
535 * CheckMenuItem (USER.154)
537 BOOL16 WINAPI
CheckMenuItem16( HMENU16 hMenu
, UINT16 id
, UINT16 flags
)
539 return CheckMenuItem( HMENU_32(hMenu
), id
, flags
);
543 /**********************************************************************
544 * EnableMenuItem (USER.155)
546 BOOL16 WINAPI
EnableMenuItem16( HMENU16 hMenu
, UINT16 wItemID
, UINT16 wFlags
)
548 return EnableMenuItem( HMENU_32(hMenu
), wItemID
, wFlags
);
552 /**********************************************************************
553 * GetSubMenu (USER.159)
555 HMENU16 WINAPI
GetSubMenu16( HMENU16 hMenu
, INT16 nPos
)
557 return HMENU_16( GetSubMenu( HMENU_32(hMenu
), nPos
) );
561 /*******************************************************************
562 * GetMenuString (USER.161)
564 INT16 WINAPI
GetMenuString16( HMENU16 hMenu
, UINT16 wItemID
,
565 LPSTR str
, INT16 nMaxSiz
, UINT16 wFlags
)
567 return GetMenuStringA( HMENU_32(hMenu
), wItemID
, str
, nMaxSiz
, wFlags
);
571 /**********************************************************************
574 BOOL16 WINAPI
WinHelp16( HWND16 hWnd
, LPCSTR lpHelpFile
, UINT16 wCommand
,
580 /* We might call WinExec() */
581 ReleaseThunkLock(&mutex_count
);
583 ret
= WinHelpA(WIN_Handle32(hWnd
), lpHelpFile
, wCommand
, (DWORD
)MapSL(dwData
));
585 RestoreThunkLock(mutex_count
);
590 /***********************************************************************
591 * LoadCursor (USER.173)
593 HCURSOR16 WINAPI
LoadCursor16(HINSTANCE16 hInstance
, LPCSTR name
)
595 return HCURSOR_16(LoadCursorA(HINSTANCE_32(hInstance
), name
));
599 /***********************************************************************
600 * LoadIcon (USER.174)
602 HICON16 WINAPI
LoadIcon16(HINSTANCE16 hInstance
, LPCSTR name
)
604 return HICON_16(LoadIconA(HINSTANCE_32(hInstance
), name
));
607 /**********************************************************************
608 * LoadBitmap (USER.175)
610 HBITMAP16 WINAPI
LoadBitmap16(HINSTANCE16 hInstance
, LPCSTR name
)
612 return HBITMAP_16(LoadBitmapA(HINSTANCE_32(hInstance
), name
));
615 /**********************************************************************
616 * LoadString (USER.176)
618 INT16 WINAPI
LoadString16( HINSTANCE16 instance
, UINT16 resource_id
, LPSTR buffer
, INT16 buflen
)
626 TRACE("inst=%04x id=%04x buff=%p len=%d\n", instance
, resource_id
, buffer
, buflen
);
628 hrsrc
= FindResource16( instance
, MAKEINTRESOURCEA((resource_id
>>4)+1), (LPSTR
)RT_STRING
);
629 if (!hrsrc
) return 0;
630 hmem
= LoadResource16( instance
, hrsrc
);
633 p
= LockResource16(hmem
);
634 string_num
= resource_id
& 0x000f;
635 while (string_num
--) p
+= *p
+ 1;
637 if (buffer
== NULL
) ret
= *p
;
640 ret
= min(buflen
- 1, *p
);
643 memcpy(buffer
, p
+ 1, ret
);
651 TRACE( "%s loaded\n", debugstr_a(buffer
));
653 FreeResource16( hmem
);
657 /**********************************************************************
658 * LoadAccelerators (USER.177)
660 HACCEL16 WINAPI
LoadAccelerators16(HINSTANCE16 instance
, LPCSTR lpTableName
)
667 TRACE("%04x %s\n", instance
, debugstr_a(lpTableName
) );
669 if (!(hRsrc
= FindResource16( instance
, lpTableName
, (LPSTR
)RT_ACCELERATOR
)) ||
670 !(hMem
= LoadResource16(instance
,hRsrc
)))
672 WARN("couldn't find %04x %s\n", instance
, debugstr_a(lpTableName
));
675 if ((table16
= LockResource16( hMem
)))
677 DWORD i
, count
= SizeofResource16( instance
, hRsrc
) / sizeof(*table16
);
678 ACCEL
*table
= HeapAlloc( GetProcessHeap(), 0, count
* sizeof(*table
) );
681 for (i
= 0; i
< count
; i
++)
683 table
[i
].fVirt
= table16
[i
].fVirt
& 0x7f;
684 table
[i
].key
= table16
[i
].key
;
685 table
[i
].cmd
= table16
[i
].cmd
;
687 ret
= CreateAcceleratorTableA( table
, count
);
688 HeapFree( GetProcessHeap(), 0, table
);
691 FreeResource16( hMem
);
692 return HACCEL_16(ret
);
695 /***********************************************************************
696 * GetSystemMetrics (USER.179)
698 INT16 WINAPI
GetSystemMetrics16( INT16 index
)
700 return GetSystemMetrics( index
);
704 /*************************************************************************
705 * GetSysColor (USER.180)
707 COLORREF WINAPI
GetSysColor16( INT16 index
)
709 return GetSysColor( index
);
713 /*************************************************************************
714 * SetSysColors (USER.181)
716 VOID WINAPI
SetSysColors16( INT16 count
, const INT16
*list16
, const COLORREF
*values
)
720 if ((list
= HeapAlloc( GetProcessHeap(), 0, count
* sizeof(*list
) )))
722 for (i
= 0; i
< count
; i
++) list
[i
] = list16
[i
];
723 SetSysColors( count
, list
, values
);
724 HeapFree( GetProcessHeap(), 0, list
);
729 /***********************************************************************
730 * GrayString (USER.185)
732 BOOL16 WINAPI
GrayString16( HDC16 hdc
, HBRUSH16 hbr
, GRAYSTRINGPROC16 gsprc
,
733 LPARAM lParam
, INT16 cch
, INT16 x
, INT16 y
,
738 if (!gsprc
) return GrayStringA( HDC_32(hdc
), HBRUSH_32(hbr
), NULL
,
739 (LPARAM
)MapSL(lParam
), cch
, x
, y
, cx
, cy
);
741 if (cch
== -1 || (cch
&& cx
&& cy
))
743 /* lParam can be treated as an opaque pointer */
744 struct gray_string_info info
;
748 ret
= GrayStringA( HDC_32(hdc
), HBRUSH_32(hbr
), gray_string_callback
,
749 (LPARAM
)&info
, cch
, x
, y
, cx
, cy
);
751 else /* here we need some string conversions */
753 char *str16
= MapSL(lParam
);
754 struct gray_string_info
*info
;
756 if (!cch
) cch
= strlen(str16
);
757 if (!(info
= HeapAlloc( GetProcessHeap(), 0, sizeof(*info
) + cch
))) return FALSE
;
759 info
->param
= lParam
;
760 memcpy( info
->str
, str16
, cch
);
761 ret
= GrayStringA( HDC_32(hdc
), HBRUSH_32(hbr
), gray_string_callback_ptr
,
762 (LPARAM
)info
->str
, cch
, x
, y
, cx
, cy
);
763 HeapFree( GetProcessHeap(), 0, info
);
769 /***********************************************************************
770 * SwapMouseButton (USER.186)
772 BOOL16 WINAPI
SwapMouseButton16( BOOL16 fSwap
)
774 return SwapMouseButton( fSwap
);
778 /**************************************************************************
779 * IsClipboardFormatAvailable (USER.193)
781 BOOL16 WINAPI
IsClipboardFormatAvailable16( UINT16 wFormat
)
783 return IsClipboardFormatAvailable( wFormat
);
787 /***********************************************************************
788 * TabbedTextOut (USER.196)
790 LONG WINAPI
TabbedTextOut16( HDC16 hdc
, INT16 x
, INT16 y
, LPCSTR lpstr
,
791 INT16 count
, INT16 nb_tabs
, const INT16
*tabs16
, INT16 tab_org
)
794 INT i
, *tabs
= HeapAlloc( GetProcessHeap(), 0, nb_tabs
* sizeof(tabs
) );
796 for (i
= 0; i
< nb_tabs
; i
++) tabs
[i
] = tabs16
[i
];
797 ret
= TabbedTextOutA( HDC_32(hdc
), x
, y
, lpstr
, count
, nb_tabs
, tabs
, tab_org
);
798 HeapFree( GetProcessHeap(), 0, tabs
);
803 /***********************************************************************
804 * GetTabbedTextExtent (USER.197)
806 DWORD WINAPI
GetTabbedTextExtent16( HDC16 hdc
, LPCSTR lpstr
, INT16 count
,
807 INT16 nb_tabs
, const INT16
*tabs16
)
810 INT i
, *tabs
= HeapAlloc( GetProcessHeap(), 0, nb_tabs
* sizeof(tabs
) );
812 for (i
= 0; i
< nb_tabs
; i
++) tabs
[i
] = tabs16
[i
];
813 ret
= GetTabbedTextExtentA( HDC_32(hdc
), lpstr
, count
, nb_tabs
, tabs
);
814 HeapFree( GetProcessHeap(), 0, tabs
);
819 /***********************************************************************
820 * UserSeeUserDo (USER.216)
822 DWORD WINAPI
UserSeeUserDo16(WORD wReqType
, WORD wParam1
, WORD wParam2
, WORD wParam3
)
824 STACK16FRAME
* stack16
= MapSL((SEGPTR
)NtCurrentTeb()->WOW32Reserved
);
825 HANDLE16 oldDS
= stack16
->ds
;
826 DWORD ret
= (DWORD
)-1;
828 stack16
->ds
= USER_HeapSel
;
831 case USUD_LOCALALLOC
:
832 ret
= LocalAlloc16(wParam1
, wParam3
);
835 ret
= LocalFree16(wParam1
);
837 case USUD_LOCALCOMPACT
:
838 ret
= LocalCompact16(wParam3
);
843 case USUD_FIRSTCLASS
:
844 FIXME("return a pointer to the first window class.\n");
847 WARN("wReqType %04x (unknown)\n", wReqType
);
854 /*************************************************************************
855 * ScrollDC (USER.221)
857 BOOL16 WINAPI
ScrollDC16( HDC16 hdc
, INT16 dx
, INT16 dy
, const RECT16
*rect
,
858 const RECT16
*cliprc
, HRGN16 hrgnUpdate
,
861 RECT rect32
, clipRect32
, rcUpdate32
;
866 rect32
.left
= rect
->left
;
867 rect32
.top
= rect
->top
;
868 rect32
.right
= rect
->right
;
869 rect32
.bottom
= rect
->bottom
;
873 clipRect32
.left
= cliprc
->left
;
874 clipRect32
.top
= cliprc
->top
;
875 clipRect32
.right
= cliprc
->right
;
876 clipRect32
.bottom
= cliprc
->bottom
;
878 ret
= ScrollDC( HDC_32(hdc
), dx
, dy
, rect
? &rect32
: NULL
,
879 cliprc
? &clipRect32
: NULL
, HRGN_32(hrgnUpdate
),
883 rcUpdate
->left
= rcUpdate32
.left
;
884 rcUpdate
->top
= rcUpdate32
.top
;
885 rcUpdate
->right
= rcUpdate32
.right
;
886 rcUpdate
->bottom
= rcUpdate32
.bottom
;
892 /***********************************************************************
893 * GetSystemDebugState (USER.231)
895 WORD WINAPI
GetSystemDebugState16(void)
897 return 0; /* FIXME */
901 /***********************************************************************
902 * EqualRect (USER.244)
904 BOOL16 WINAPI
EqualRect16( const RECT16
* rect1
, const RECT16
* rect2
)
906 return ((rect1
->left
== rect2
->left
) && (rect1
->right
== rect2
->right
) &&
907 (rect1
->top
== rect2
->top
) && (rect1
->bottom
== rect2
->bottom
));
911 /***********************************************************************
912 * ExitWindowsExec (USER.246)
914 BOOL16 WINAPI
ExitWindowsExec16( LPCSTR lpszExe
, LPCSTR lpszParams
)
916 TRACE("Should run the following in DOS-mode: \"%s %s\"\n",
917 lpszExe
, lpszParams
);
918 return ExitWindowsEx( EWX_LOGOFF
, 0xffffffff );
922 /***********************************************************************
923 * GetCursor (USER.247)
925 HCURSOR16 WINAPI
GetCursor16(void)
927 return HCURSOR_16(GetCursor());
931 /**********************************************************************
932 * GetAsyncKeyState (USER.249)
934 INT16 WINAPI
GetAsyncKeyState16( INT16 key
)
936 return GetAsyncKeyState( key
);
940 /**********************************************************************
941 * GetMenuState (USER.250)
943 UINT16 WINAPI
GetMenuState16( HMENU16 hMenu
, UINT16 wItemID
, UINT16 wFlags
)
945 return GetMenuState( HMENU_32(hMenu
), wItemID
, wFlags
);
949 /**********************************************************************
950 * GetMenuItemCount (USER.263)
952 INT16 WINAPI
GetMenuItemCount16( HMENU16 hMenu
)
954 return GetMenuItemCount( HMENU_32(hMenu
) );
958 /**********************************************************************
959 * GetMenuItemID (USER.264)
961 UINT16 WINAPI
GetMenuItemID16( HMENU16 hMenu
, INT16 nPos
)
963 return GetMenuItemID( HMENU_32(hMenu
), nPos
);
967 /***********************************************************************
968 * GlobalAddAtom (USER.268)
970 ATOM WINAPI
GlobalAddAtom16(LPCSTR lpString
)
972 return GlobalAddAtomA(lpString
);
975 /***********************************************************************
976 * GlobalDeleteAtom (USER.269)
978 ATOM WINAPI
GlobalDeleteAtom16(ATOM nAtom
)
980 return GlobalDeleteAtom(nAtom
);
983 /***********************************************************************
984 * GlobalFindAtom (USER.270)
986 ATOM WINAPI
GlobalFindAtom16(LPCSTR lpString
)
988 return GlobalFindAtomA(lpString
);
991 /***********************************************************************
992 * GlobalGetAtomName (USER.271)
994 UINT16 WINAPI
GlobalGetAtomName16(ATOM nAtom
, LPSTR lpBuffer
, INT16 nSize
)
996 return GlobalGetAtomNameA(nAtom
, lpBuffer
, nSize
);
1000 /***********************************************************************
1001 * ControlPanelInfo (USER.273)
1003 void WINAPI
ControlPanelInfo16( INT16 nInfoType
, WORD wData
, LPSTR lpBuffer
)
1005 FIXME("(%d, %04x, %p): stub.\n", nInfoType
, wData
, lpBuffer
);
1009 /***********************************************************************
1010 * OldSetDeskPattern (USER.279)
1012 BOOL16 WINAPI
SetDeskPattern16(void)
1014 return SystemParametersInfoA( SPI_SETDESKPATTERN
, -1, NULL
, FALSE
);
1018 /***********************************************************************
1019 * GetSysColorBrush (USER.281)
1021 HBRUSH16 WINAPI
GetSysColorBrush16( INT16 index
)
1023 return HBRUSH_16( GetSysColorBrush(index
) );
1027 /***********************************************************************
1028 * SelectPalette (USER.282)
1030 HPALETTE16 WINAPI
SelectPalette16( HDC16 hdc
, HPALETTE16 hpal
, BOOL16 bForceBackground
)
1032 return HPALETTE_16( SelectPalette( HDC_32(hdc
), HPALETTE_32(hpal
), bForceBackground
));
1035 /***********************************************************************
1036 * RealizePalette (USER.283)
1038 UINT16 WINAPI
RealizePalette16( HDC16 hdc
)
1040 return UserRealizePalette( HDC_32(hdc
) );
1044 /***********************************************************************
1045 * GetFreeSystemResources (USER.284)
1047 WORD WINAPI
GetFreeSystemResources16( WORD resType
)
1049 STACK16FRAME
* stack16
= MapSL((SEGPTR
)NtCurrentTeb()->WOW32Reserved
);
1050 HANDLE16 oldDS
= stack16
->ds
;
1051 HINSTANCE16 gdi_inst
;
1052 int userPercent
, gdiPercent
;
1054 if ((gdi_inst
= LoadLibrary16( "GDI" )) < 32) return 0;
1058 case GFSR_USERRESOURCES
:
1059 stack16
->ds
= USER_HeapSel
;
1060 userPercent
= (int)LocalCountFree16() * 100 / LocalHeapSize16();
1062 stack16
->ds
= oldDS
;
1065 case GFSR_GDIRESOURCES
:
1066 stack16
->ds
= gdi_inst
;
1067 gdiPercent
= (int)LocalCountFree16() * 100 / LocalHeapSize16();
1069 stack16
->ds
= oldDS
;
1072 case GFSR_SYSTEMRESOURCES
:
1073 stack16
->ds
= USER_HeapSel
;
1074 userPercent
= (int)LocalCountFree16() * 100 / LocalHeapSize16();
1075 stack16
->ds
= gdi_inst
;
1076 gdiPercent
= (int)LocalCountFree16() * 100 / LocalHeapSize16();
1077 stack16
->ds
= oldDS
;
1081 userPercent
= gdiPercent
= 0;
1084 FreeLibrary16( gdi_inst
);
1085 TRACE("<- userPercent %d, gdiPercent %d\n", userPercent
, gdiPercent
);
1086 return (WORD
)min( userPercent
, gdiPercent
);
1090 /***********************************************************************
1091 * SetDeskWallPaper (USER.285)
1093 BOOL16 WINAPI
SetDeskWallPaper16( LPCSTR filename
)
1095 return SetDeskWallPaper( filename
);
1099 /***********************************************************************
1100 * keybd_event (USER.289)
1102 void WINAPI
keybd_event16( CONTEXT86
*context
)
1106 if (HIBYTE(context
->Eax
) & 0x80) dwFlags
|= KEYEVENTF_KEYUP
;
1107 if (HIBYTE(context
->Ebx
) & 0x01) dwFlags
|= KEYEVENTF_EXTENDEDKEY
;
1109 keybd_event( LOBYTE(context
->Eax
), LOBYTE(context
->Ebx
),
1110 dwFlags
, MAKELONG(LOWORD(context
->Esi
), LOWORD(context
->Edi
)) );
1114 /***********************************************************************
1115 * mouse_event (USER.299)
1117 void WINAPI
mouse_event16( CONTEXT86
*context
)
1119 mouse_event( LOWORD(context
->Eax
), LOWORD(context
->Ebx
), LOWORD(context
->Ecx
),
1120 LOWORD(context
->Edx
), MAKELONG(context
->Esi
, context
->Edi
) );
1124 /***********************************************************************
1125 * GetClipCursor (USER.309)
1127 void WINAPI
GetClipCursor16( RECT16
*rect
)
1132 GetClipCursor( &rect32
);
1133 rect
->left
= rect32
.left
;
1134 rect
->top
= rect32
.top
;
1135 rect
->right
= rect32
.right
;
1136 rect
->bottom
= rect32
.bottom
;
1141 /***********************************************************************
1142 * SignalProc (USER.314)
1144 void WINAPI
SignalProc16( HANDLE16 hModule
, UINT16 code
,
1145 UINT16 uExitFn
, HINSTANCE16 hInstance
, HQUEUE16 hQueue
)
1147 if (code
== USIG16_DLL_UNLOAD
)
1149 /* HOOK_FreeModuleHooks( hModule ); */
1150 CLASS_FreeModuleClasses( hModule
);
1151 CURSORICON_FreeModuleIcons( hModule
);
1156 /***********************************************************************
1157 * SetEventHook (USER.321)
1159 * Used by Turbo Debugger for Windows
1161 FARPROC16 WINAPI
SetEventHook16(FARPROC16 lpfnEventHook
)
1163 FIXME("(lpfnEventHook=%p): stub\n", lpfnEventHook
);
1168 /**********************************************************************
1169 * EnableHardwareInput (USER.331)
1171 BOOL16 WINAPI
EnableHardwareInput16(BOOL16 bEnable
)
1173 FIXME("(%d) - stub\n", bEnable
);
1178 /***********************************************************************
1179 * GetMouseEventProc (USER.337)
1181 FARPROC16 WINAPI
GetMouseEventProc16(void)
1183 HMODULE16 hmodule
= GetModuleHandle16("USER");
1184 return GetProcAddress16( hmodule
, "mouse_event" );
1188 /***********************************************************************
1189 * IsUserIdle (USER.333)
1191 BOOL16 WINAPI
IsUserIdle16(void)
1193 if ( GetAsyncKeyState( VK_LBUTTON
) & 0x8000 )
1195 if ( GetAsyncKeyState( VK_RBUTTON
) & 0x8000 )
1197 if ( GetAsyncKeyState( VK_MBUTTON
) & 0x8000 )
1199 /* Should check for screen saver activation here ... */
1204 /**********************************************************************
1205 * LoadDIBIconHandler (USER.357)
1207 * RT_ICON resource loader, installed by USER_SignalProc when module
1210 HGLOBAL16 WINAPI
LoadDIBIconHandler16( HGLOBAL16 hMemObj
, HMODULE16 hModule
, HRSRC16 hRsrc
)
1212 /* If hResource is zero we must allocate a new memory block, if it's
1213 * non-zero but GlobalLock() returns NULL then it was discarded and
1214 * we have to recommit some memory, otherwise we just need to check
1215 * the block size. See LoadProc() in 16-bit SDK for more.
1217 FIXME( "%x %x %x: stub, not supported anymore\n", hMemObj
, hModule
, hRsrc
);
1221 /**********************************************************************
1222 * LoadDIBCursorHandler (USER.356)
1224 * RT_CURSOR resource loader. Same as above.
1226 HGLOBAL16 WINAPI
LoadDIBCursorHandler16( HGLOBAL16 hMemObj
, HMODULE16 hModule
, HRSRC16 hRsrc
)
1228 FIXME( "%x %x %x: stub, not supported anymore\n", hMemObj
, hModule
, hRsrc
);
1233 /**********************************************************************
1236 BOOL16 WINAPI
IsMenu16( HMENU16 hmenu
)
1238 return IsMenu( HMENU_32(hmenu
) );
1242 /***********************************************************************
1245 BOOL16 WINAPI
DCHook16( HDC16 hdc
, WORD code
, DWORD data
, LPARAM lParam
)
1247 FIXME( "hDC = %x, %i: stub\n", hdc
, code
);
1252 /***********************************************************************
1253 * SubtractRect (USER.373)
1255 BOOL16 WINAPI
SubtractRect16( LPRECT16 dest
, const RECT16
*src1
,
1256 const RECT16
*src2
)
1260 if (IsRectEmpty16( src1
))
1262 SetRectEmpty16( dest
);
1266 if (IntersectRect16( &tmp
, src1
, src2
))
1268 if (EqualRect16( &tmp
, dest
))
1270 SetRectEmpty16( dest
);
1273 if ((tmp
.top
== dest
->top
) && (tmp
.bottom
== dest
->bottom
))
1275 if (tmp
.left
== dest
->left
) dest
->left
= tmp
.right
;
1276 else if (tmp
.right
== dest
->right
) dest
->right
= tmp
.left
;
1278 else if ((tmp
.left
== dest
->left
) && (tmp
.right
== dest
->right
))
1280 if (tmp
.top
== dest
->top
) dest
->top
= tmp
.bottom
;
1281 else if (tmp
.bottom
== dest
->bottom
) dest
->bottom
= tmp
.top
;
1288 /**********************************************************************
1289 * DllEntryPoint (USER.374)
1291 BOOL WINAPI
DllEntryPoint( DWORD reason
, HINSTANCE16 inst
, WORD ds
,
1292 WORD heap
, DWORD reserved1
, WORD reserved2
)
1294 if (reason
!= DLL_PROCESS_ATTACH
) return TRUE
;
1295 if (USER_HeapSel
) return TRUE
; /* already called */
1302 /**********************************************************************
1303 * SetMenuContextHelpId (USER.384)
1305 BOOL16 WINAPI
SetMenuContextHelpId16( HMENU16 hMenu
, DWORD dwContextHelpID
)
1307 return SetMenuContextHelpId( HMENU_32(hMenu
), dwContextHelpID
);
1311 /**********************************************************************
1312 * GetMenuContextHelpId (USER.385)
1314 DWORD WINAPI
GetMenuContextHelpId16( HMENU16 hMenu
)
1316 return GetMenuContextHelpId( HMENU_32(hMenu
) );
1320 /***********************************************************************
1321 * LoadImage (USER.389)
1324 HANDLE16 WINAPI
LoadImage16(HINSTANCE16 hinst
, LPCSTR name
, UINT16 type
,
1325 INT16 desiredx
, INT16 desiredy
, UINT16 loadflags
)
1327 return HANDLE_16(LoadImageA(HINSTANCE_32(hinst
), name
, type
, desiredx
,
1328 desiredy
, loadflags
));
1331 /******************************************************************************
1332 * CopyImage (USER.390) Creates new image and copies attributes to it
1335 HICON16 WINAPI
CopyImage16(HANDLE16 hnd
, UINT16 type
, INT16 desiredx
,
1336 INT16 desiredy
, UINT16 flags
)
1338 return HICON_16(CopyImage(HANDLE_32(hnd
), (UINT
)type
, (INT
)desiredx
,
1339 (INT
)desiredy
, (UINT
)flags
));
1342 /**********************************************************************
1343 * DrawIconEx (USER.394)
1345 BOOL16 WINAPI
DrawIconEx16(HDC16 hdc
, INT16 xLeft
, INT16 yTop
, HICON16 hIcon
,
1346 INT16 cxWidth
, INT16 cyWidth
, UINT16 istep
,
1347 HBRUSH16 hbr
, UINT16 flags
)
1349 return DrawIconEx(HDC_32(hdc
), xLeft
, yTop
, HICON_32(hIcon
), cxWidth
, cyWidth
,
1350 istep
, HBRUSH_32(hbr
), flags
);
1353 /**********************************************************************
1354 * GetIconInfo (USER.395)
1356 BOOL16 WINAPI
GetIconInfo16(HICON16 hIcon
, LPICONINFO16 iconinfo
)
1359 BOOL16 ret
= GetIconInfo(HICON_32(hIcon
), &ii32
);
1361 iconinfo
->fIcon
= ii32
.fIcon
;
1362 iconinfo
->xHotspot
= ii32
.xHotspot
;
1363 iconinfo
->yHotspot
= ii32
.yHotspot
;
1364 iconinfo
->hbmMask
= HBITMAP_16(ii32
.hbmMask
);
1365 iconinfo
->hbmColor
= HBITMAP_16(ii32
.hbmColor
);
1370 /***********************************************************************
1371 * FinalUserInit (USER.400)
1373 void WINAPI
FinalUserInit16( void )
1375 /* FIXME: Should chain to FinalGdiInit */
1379 /***********************************************************************
1380 * CreateCursor (USER.406)
1382 HCURSOR16 WINAPI
CreateCursor16(HINSTANCE16 hInstance
,
1383 INT16 xHotSpot
, INT16 yHotSpot
,
1384 INT16 nWidth
, INT16 nHeight
,
1385 LPCVOID lpANDbits
, LPCVOID lpXORbits
)
1387 CURSORICONINFO info
;
1389 info
.ptHotSpot
.x
= xHotSpot
;
1390 info
.ptHotSpot
.y
= yHotSpot
;
1391 info
.nWidth
= nWidth
;
1392 info
.nHeight
= nHeight
;
1393 info
.nWidthBytes
= 0;
1395 info
.bBitsPerPixel
= 1;
1397 return CreateCursorIconIndirect16(hInstance
, &info
, lpANDbits
, lpXORbits
);
1401 /***********************************************************************
1402 * InitThreadInput (USER.409)
1404 HQUEUE16 WINAPI
InitThreadInput16( WORD unknown
, WORD flags
)
1406 /* nothing to do here */
1411 /*******************************************************************
1412 * InsertMenu (USER.410)
1414 BOOL16 WINAPI
InsertMenu16( HMENU16 hMenu
, UINT16 pos
, UINT16 flags
,
1415 UINT16 id
, SEGPTR data
)
1417 UINT pos32
= (UINT
)pos
;
1418 if ((pos
== (UINT16
)-1) && (flags
& MF_BYPOSITION
)) pos32
= (UINT
)-1;
1419 if (IS_MENU_STRING_ITEM(flags
) && data
)
1420 return InsertMenuA( HMENU_32(hMenu
), pos32
, flags
, id
, MapSL(data
) );
1421 return InsertMenuA( HMENU_32(hMenu
), pos32
, flags
, id
, (LPSTR
)data
);
1425 /*******************************************************************
1426 * AppendMenu (USER.411)
1428 BOOL16 WINAPI
AppendMenu16(HMENU16 hMenu
, UINT16 flags
, UINT16 id
, SEGPTR data
)
1430 return InsertMenu16( hMenu
, -1, flags
| MF_BYPOSITION
, id
, data
);
1434 /**********************************************************************
1435 * RemoveMenu (USER.412)
1437 BOOL16 WINAPI
RemoveMenu16( HMENU16 hMenu
, UINT16 nPos
, UINT16 wFlags
)
1439 return RemoveMenu( HMENU_32(hMenu
), nPos
, wFlags
);
1443 /**********************************************************************
1444 * DeleteMenu (USER.413)
1446 BOOL16 WINAPI
DeleteMenu16( HMENU16 hMenu
, UINT16 nPos
, UINT16 wFlags
)
1448 return DeleteMenu( HMENU_32(hMenu
), nPos
, wFlags
);
1452 /*******************************************************************
1453 * ModifyMenu (USER.414)
1455 BOOL16 WINAPI
ModifyMenu16( HMENU16 hMenu
, UINT16 pos
, UINT16 flags
,
1456 UINT16 id
, SEGPTR data
)
1458 if (IS_MENU_STRING_ITEM(flags
))
1459 return ModifyMenuA( HMENU_32(hMenu
), pos
, flags
, id
, MapSL(data
) );
1460 return ModifyMenuA( HMENU_32(hMenu
), pos
, flags
, id
, (LPSTR
)data
);
1464 /**********************************************************************
1465 * CreatePopupMenu (USER.415)
1467 HMENU16 WINAPI
CreatePopupMenu16(void)
1469 return HMENU_16( CreatePopupMenu() );
1473 /**********************************************************************
1474 * SetMenuItemBitmaps (USER.418)
1476 BOOL16 WINAPI
SetMenuItemBitmaps16( HMENU16 hMenu
, UINT16 nPos
, UINT16 wFlags
,
1477 HBITMAP16 hNewUnCheck
, HBITMAP16 hNewCheck
)
1479 return SetMenuItemBitmaps( HMENU_32(hMenu
), nPos
, wFlags
,
1480 HBITMAP_32(hNewUnCheck
), HBITMAP_32(hNewCheck
) );
1484 /***********************************************************************
1485 * lstrcmp (USER.430)
1487 INT16 WINAPI
lstrcmp16( LPCSTR str1
, LPCSTR str2
)
1489 return strcmp( str1
, str2
);
1493 /***********************************************************************
1494 * AnsiUpper (USER.431)
1496 SEGPTR WINAPI
AnsiUpper16( SEGPTR strOrChar
)
1498 /* uppercase only one char if strOrChar < 0x10000 */
1499 if (HIWORD(strOrChar
))
1501 CharUpperA( MapSL(strOrChar
) );
1504 else return (SEGPTR
)CharUpperA( (LPSTR
)strOrChar
);
1508 /***********************************************************************
1509 * AnsiLower (USER.432)
1511 SEGPTR WINAPI
AnsiLower16( SEGPTR strOrChar
)
1513 /* lowercase only one char if strOrChar < 0x10000 */
1514 if (HIWORD(strOrChar
))
1516 CharLowerA( MapSL(strOrChar
) );
1519 else return (SEGPTR
)CharLowerA( (LPSTR
)strOrChar
);
1523 /***********************************************************************
1524 * AnsiUpperBuff (USER.437)
1526 UINT16 WINAPI
AnsiUpperBuff16( LPSTR str
, UINT16 len
)
1528 CharUpperBuffA( str
, len
? len
: 65536 );
1533 /***********************************************************************
1534 * AnsiLowerBuff (USER.438)
1536 UINT16 WINAPI
AnsiLowerBuff16( LPSTR str
, UINT16 len
)
1538 CharLowerBuffA( str
, len
? len
: 65536 );
1543 /*******************************************************************
1544 * InsertMenuItem (USER.441)
1548 BOOL16 WINAPI
InsertMenuItem16( HMENU16 hmenu
, UINT16 pos
, BOOL16 byposition
,
1549 const MENUITEMINFO16
*mii
)
1553 miia
.cbSize
= sizeof(miia
);
1554 miia
.fMask
= mii
->fMask
;
1555 miia
.dwTypeData
= (LPSTR
)mii
->dwTypeData
;
1556 miia
.fType
= mii
->fType
;
1557 miia
.fState
= mii
->fState
;
1558 miia
.wID
= mii
->wID
;
1559 miia
.hSubMenu
= HMENU_32(mii
->hSubMenu
);
1560 miia
.hbmpChecked
= HBITMAP_32(mii
->hbmpChecked
);
1561 miia
.hbmpUnchecked
= HBITMAP_32(mii
->hbmpUnchecked
);
1562 miia
.dwItemData
= mii
->dwItemData
;
1563 miia
.cch
= mii
->cch
;
1564 if (IS_MENU_STRING_ITEM(miia
.fType
))
1565 miia
.dwTypeData
= MapSL(mii
->dwTypeData
);
1566 return InsertMenuItemA( HMENU_32(hmenu
), pos
, byposition
, &miia
);
1570 /**********************************************************************
1571 * DrawState (USER.449)
1573 BOOL16 WINAPI
DrawState16( HDC16 hdc
, HBRUSH16 hbr
, DRAWSTATEPROC16 func
, LPARAM ldata
,
1574 WPARAM16 wdata
, INT16 x
, INT16 y
, INT16 cx
, INT16 cy
, UINT16 flags
)
1576 struct draw_state_info info
;
1577 UINT opcode
= flags
& 0xf;
1579 if (opcode
== DST_TEXT
|| opcode
== DST_PREFIXTEXT
)
1581 /* make sure DrawStateA doesn't try to use ldata as a pointer */
1582 if (!wdata
) wdata
= strlen( MapSL(ldata
) );
1586 if (!GetTextExtentPoint32A( HDC_32(hdc
), MapSL(ldata
), wdata
, &s
)) return FALSE
;
1593 return DrawStateA( HDC_32(hdc
), HBRUSH_32(hbr
), draw_state_callback
,
1594 (LPARAM
)&info
, wdata
, x
, y
, cx
, cy
, flags
);
1598 /**********************************************************************
1599 * CreateIconFromResourceEx (USER.450)
1601 * FIXME: not sure about exact parameter types
1603 HICON16 WINAPI
CreateIconFromResourceEx16(LPBYTE bits
, UINT16 cbSize
,
1604 BOOL16 bIcon
, DWORD dwVersion
,
1605 INT16 width
, INT16 height
,
1608 return HICON_16(CreateIconFromResourceEx(bits
, cbSize
, bIcon
, dwVersion
,
1609 width
, height
, cFlag
));
1613 /***********************************************************************
1614 * AdjustWindowRectEx (USER.454)
1616 BOOL16 WINAPI
AdjustWindowRectEx16( LPRECT16 rect
, DWORD style
, BOOL16 menu
, DWORD exStyle
)
1621 rect32
.left
= rect
->left
;
1622 rect32
.top
= rect
->top
;
1623 rect32
.right
= rect
->right
;
1624 rect32
.bottom
= rect
->bottom
;
1625 ret
= AdjustWindowRectEx( &rect32
, style
, menu
, exStyle
);
1626 rect
->left
= rect32
.left
;
1627 rect
->top
= rect32
.top
;
1628 rect
->right
= rect32
.right
;
1629 rect
->bottom
= rect32
.bottom
;
1634 /***********************************************************************
1635 * DestroyIcon (USER.457)
1637 BOOL16 WINAPI
DestroyIcon16(HICON16 hIcon
)
1639 return DestroyIcon32(hIcon
, 0);
1642 /***********************************************************************
1643 * DestroyCursor (USER.458)
1645 BOOL16 WINAPI
DestroyCursor16(HCURSOR16 hCursor
)
1647 return DestroyIcon32(hCursor
, 0);
1650 /*******************************************************************
1651 * DRAG_QueryUpdate16
1653 * Recursively find a child that contains spDragInfo->pt point
1654 * and send WM_QUERYDROPOBJECT. Helper for DragObject16.
1656 static BOOL
DRAG_QueryUpdate16( HWND hQueryWnd
, SEGPTR spDragInfo
)
1661 LPDRAGINFO16 ptrDragInfo
= MapSL(spDragInfo
);
1665 if (!IsWindowEnabled(hQueryWnd
)) return FALSE
;
1667 old_pt
.x
= ptrDragInfo
->pt
.x
;
1668 old_pt
.y
= ptrDragInfo
->pt
.y
;
1670 ScreenToClient( hQueryWnd
, &pt
);
1671 child
= ChildWindowFromPointEx( hQueryWnd
, pt
, CWP_SKIPINVISIBLE
);
1672 if (!child
) return FALSE
;
1674 if (child
!= hQueryWnd
)
1677 if (DRAG_QueryUpdate16( child
, spDragInfo
)) return TRUE
;
1681 GetClientRect( hQueryWnd
, &tempRect
);
1682 wParam
= !PtInRect( &tempRect
, pt
);
1685 ptrDragInfo
->pt
.x
= pt
.x
;
1686 ptrDragInfo
->pt
.y
= pt
.y
;
1687 ptrDragInfo
->hScope
= HWND_16(hQueryWnd
);
1689 bResult
= SendMessage16( HWND_16(hQueryWnd
), WM_QUERYDROPOBJECT
, wParam
, spDragInfo
);
1693 ptrDragInfo
->pt
.x
= old_pt
.x
;
1694 ptrDragInfo
->pt
.y
= old_pt
.y
;
1700 /******************************************************************************
1701 * DragObject (USER.464)
1703 DWORD WINAPI
DragObject16( HWND16 hwndScope
, HWND16 hWnd
, UINT16 wObj
,
1704 HANDLE16 hOfStruct
, WORD szList
, HCURSOR16 hCursor
)
1707 LPDRAGINFO16 lpDragInfo
;
1709 HCURSOR hOldCursor
=0, hBummer
=0;
1710 HGLOBAL16 hDragInfo
= GlobalAlloc16( GMEM_SHARE
| GMEM_ZEROINIT
, 2*sizeof(DRAGINFO16
));
1711 HCURSOR hCurrentCursor
= 0;
1712 HWND16 hCurrentWnd
= 0;
1714 lpDragInfo
= (LPDRAGINFO16
) GlobalLock16(hDragInfo
);
1715 spDragInfo
= WOWGlobalLock16(hDragInfo
);
1717 if( !lpDragInfo
|| !spDragInfo
) return 0L;
1719 if (!(hBummer
= LoadCursorA(0, MAKEINTRESOURCEA(OCR_NO
))))
1721 GlobalFree16(hDragInfo
);
1725 if(hCursor
) hOldCursor
= SetCursor(HCURSOR_32(hCursor
));
1727 lpDragInfo
->hWnd
= hWnd
;
1728 lpDragInfo
->hScope
= 0;
1729 lpDragInfo
->wFlags
= wObj
;
1730 lpDragInfo
->hList
= szList
; /* near pointer! */
1731 lpDragInfo
->hOfStruct
= hOfStruct
;
1734 SetCapture( HWND_32(hWnd
) );
1739 GetMessageW( &msg
, 0, WM_MOUSEFIRST
, WM_MOUSELAST
);
1741 *(lpDragInfo
+1) = *lpDragInfo
;
1743 lpDragInfo
->pt
.x
= msg
.pt
.x
;
1744 lpDragInfo
->pt
.y
= msg
.pt
.y
;
1746 /* update DRAGINFO struct */
1747 if( DRAG_QueryUpdate16(WIN_Handle32(hwndScope
), spDragInfo
) > 0 )
1748 hCurrentCursor
= HCURSOR_32(hCursor
);
1751 hCurrentCursor
= hBummer
;
1752 lpDragInfo
->hScope
= 0;
1754 if( hCurrentCursor
)
1755 SetCursor(hCurrentCursor
);
1757 /* send WM_DRAGLOOP */
1758 SendMessage16( hWnd
, WM_DRAGLOOP
, (WPARAM16
)(hCurrentCursor
!= hBummer
),
1759 (LPARAM
) spDragInfo
);
1760 /* send WM_DRAGSELECT or WM_DRAGMOVE */
1761 if( hCurrentWnd
!= lpDragInfo
->hScope
)
1764 SendMessage16( hCurrentWnd
, WM_DRAGSELECT
, 0,
1765 (LPARAM
)MAKELONG(LOWORD(spDragInfo
)+sizeof(DRAGINFO16
),
1766 HIWORD(spDragInfo
)) );
1767 hCurrentWnd
= lpDragInfo
->hScope
;
1769 SendMessage16( hCurrentWnd
, WM_DRAGSELECT
, 1, (LPARAM
)spDragInfo
);
1773 SendMessage16( hCurrentWnd
, WM_DRAGMOVE
, 0, (LPARAM
)spDragInfo
);
1775 } while( msg
.message
!= WM_LBUTTONUP
&& msg
.message
!= WM_NCLBUTTONUP
);
1778 ShowCursor( FALSE
);
1780 if( hCursor
) SetCursor(hOldCursor
);
1782 if( hCurrentCursor
!= hBummer
)
1783 msg
.lParam
= SendMessage16( lpDragInfo
->hScope
, WM_DROPOBJECT
,
1784 (WPARAM16
)hWnd
, (LPARAM
)spDragInfo
);
1787 GlobalFree16(hDragInfo
);
1789 return (DWORD
)(msg
.lParam
);
1793 /***********************************************************************
1794 * DrawFocusRect (USER.466)
1796 void WINAPI
DrawFocusRect16( HDC16 hdc
, const RECT16
* rc
)
1800 rect32
.left
= rc
->left
;
1801 rect32
.top
= rc
->top
;
1802 rect32
.right
= rc
->right
;
1803 rect32
.bottom
= rc
->bottom
;
1804 DrawFocusRect( HDC_32(hdc
), &rect32
);
1808 /***********************************************************************
1809 * AnsiNext (USER.472)
1811 SEGPTR WINAPI
AnsiNext16(SEGPTR current
)
1813 char *ptr
= MapSL(current
);
1814 return current
+ (CharNextA(ptr
) - ptr
);
1818 /***********************************************************************
1819 * AnsiPrev (USER.473)
1821 SEGPTR WINAPI
AnsiPrev16( LPCSTR start
, SEGPTR current
)
1823 char *ptr
= MapSL(current
);
1824 return current
- (ptr
- CharPrevA( start
, ptr
));
1828 /****************************************************************************
1829 * GetKeyboardLayoutName (USER.477)
1831 INT16 WINAPI
GetKeyboardLayoutName16( LPSTR name
)
1833 return GetKeyboardLayoutNameA( name
);
1837 /***********************************************************************
1838 * FormatMessage (USER.606)
1840 DWORD WINAPI
FormatMessage16(
1842 SEGPTR lpSource
, /* [in] NOTE: not always a valid pointer */
1845 LPSTR lpBuffer
, /* [out] NOTE: *((HLOCAL16*)) for FORMAT_MESSAGE_ALLOCATE_BUFFER*/
1847 LPDWORD args
) /* [in] NOTE: va_list *args */
1850 /* This implementation is completely dependent on the format of the va_list on x86 CPUs */
1854 DWORD width
= dwFlags
& FORMAT_MESSAGE_MAX_WIDTH_MASK
;
1856 LPSTR allocstring
= NULL
;
1858 TRACE("(0x%x,%x,%d,0x%x,%p,%d,%p)\n",
1859 dwFlags
,lpSource
,dwMessageId
,dwLanguageId
,lpBuffer
,nSize
,args
);
1860 if ((dwFlags
& FORMAT_MESSAGE_FROM_SYSTEM
)
1861 && (dwFlags
& FORMAT_MESSAGE_FROM_HMODULE
)) return 0;
1862 if ((dwFlags
& FORMAT_MESSAGE_FROM_STRING
)
1863 &&((dwFlags
& FORMAT_MESSAGE_FROM_SYSTEM
)
1864 || (dwFlags
& FORMAT_MESSAGE_FROM_HMODULE
))) return 0;
1866 if (width
&& width
!= FORMAT_MESSAGE_MAX_WIDTH_MASK
)
1867 FIXME("line wrapping (%u) not supported.\n", width
);
1869 if (dwFlags
& FORMAT_MESSAGE_FROM_STRING
)
1871 char *source
= MapSL(lpSource
);
1872 from
= HeapAlloc( GetProcessHeap(), 0, strlen(source
)+1 );
1873 strcpy( from
, source
);
1875 else if (dwFlags
& FORMAT_MESSAGE_FROM_SYSTEM
) {
1876 from
= HeapAlloc( GetProcessHeap(),0,200 );
1877 sprintf(from
,"Systemmessage, messageid = 0x%08x\n",dwMessageId
);
1879 else if (dwFlags
& FORMAT_MESSAGE_FROM_HMODULE
) {
1881 HINSTANCE16 hinst16
= ((HINSTANCE16
)lpSource
& 0xffff);
1883 dwMessageId
&= 0xFFFF;
1884 bufsize
=LoadString16(hinst16
,dwMessageId
,NULL
,0);
1886 from
= HeapAlloc( GetProcessHeap(), 0, bufsize
+1);
1887 LoadString16(hinst16
,dwMessageId
,from
,bufsize
+1);
1890 target
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, 100);
1894 #define ADD_TO_T(c) \
1896 if (t-target == talloced) {\
1897 target = HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,target,talloced*2);\
1898 t = target+talloced;\
1904 while (*f
&& !eos
) {
1907 char *fmtstr
,*x
,*lastf
;
1908 DWORD
*argliststart
;
1918 case '1':case '2':case '3':case '4':case '5':
1919 case '6':case '7':case '8':case '9':
1922 case '0':case '1':case '2':case '3':
1923 case '4':case '5':case '6':case '7':
1926 insertnr
=insertnr
*10+*f
-'0';
1935 if (NULL
!=(x
=strchr(f
,'!'))) {
1937 fmtstr
=HeapAlloc(GetProcessHeap(),0,strlen(f
)+2);
1938 sprintf(fmtstr
,"%%%s",f
);
1941 fmtstr
=HeapAlloc(GetProcessHeap(),0,strlen(f
)+2);
1942 sprintf(fmtstr
,"%%%s",f
);
1943 f
+=strlen(f
); /*at \0*/
1949 fmtstr
=HeapAlloc( GetProcessHeap(), 0, 3 );
1950 strcpy( fmtstr
, "%s" );
1955 LPSTR b
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sz
= 100);
1957 argliststart
=args
+insertnr
-1;
1959 /* CMF - This makes a BIG assumption about va_list */
1960 while ((ret
= vsnprintf(b
, sz
, fmtstr
, (va_list) argliststart
) < 0) || (ret
>= sz
)) {
1961 sz
= (ret
== -1 ? sz
+ 100 : ret
+ 1);
1962 b
= HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, b
, sz
);
1964 for (x
=b
; *x
; x
++) ADD_TO_T(*x
);
1965 HeapFree(GetProcessHeap(), 0, b
);
1967 /* NULL args - copy formatstr
1970 while ((lastf
<f
)&&(*lastf
)) {
1974 HeapFree(GetProcessHeap(),0,fmtstr
);
1976 case '0': /* Just stop processing format string */
1980 case 'n': /* 16 bit version just outputs 'n' */
1985 } else { /* '\n' or '\r' gets mapped to "\r\n" */
1986 if(*f
== '\n' || *f
== '\r') {
1990 if(*f
++ == '\r' && *f
== '\n')
2000 talloced
= strlen(target
)+1;
2001 if (nSize
&& talloced
<nSize
) {
2002 target
= HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,target
,nSize
);
2004 TRACE("-- %s\n",debugstr_a(target
));
2005 if (dwFlags
& FORMAT_MESSAGE_ALLOCATE_BUFFER
) {
2006 /* nSize is the MINIMUM size */
2007 HLOCAL16 h
= LocalAlloc16(LPTR
,talloced
);
2008 SEGPTR ptr
= LocalLock16(h
);
2009 allocstring
= MapSL( ptr
);
2010 memcpy( allocstring
,target
,talloced
);
2012 *((HLOCAL16
*)lpBuffer
) = h
;
2014 lstrcpynA(lpBuffer
,target
,nSize
);
2015 HeapFree(GetProcessHeap(),0,target
);
2016 HeapFree(GetProcessHeap(),0,from
);
2017 return (dwFlags
& FORMAT_MESSAGE_ALLOCATE_BUFFER
) ?
2018 strlen(allocstring
):
2022 #endif /* __i386__ */
2027 /***********************************************************************
2028 * ChangeDisplaySettings (USER.620)
2030 LONG WINAPI
ChangeDisplaySettings16( LPDEVMODEA devmode
, DWORD flags
)
2032 return ChangeDisplaySettingsA( devmode
, flags
);
2036 /***********************************************************************
2037 * EnumDisplaySettings (USER.621)
2039 BOOL16 WINAPI
EnumDisplaySettings16( LPCSTR name
, DWORD n
, LPDEVMODEA devmode
)
2041 return EnumDisplaySettingsA( name
, n
, devmode
);
2044 /**********************************************************************
2045 * DrawFrameControl (USER.656)
2047 BOOL16 WINAPI
DrawFrameControl16( HDC16 hdc
, LPRECT16 rc
, UINT16 uType
, UINT16 uState
)
2052 rect32
.left
= rc
->left
;
2053 rect32
.top
= rc
->top
;
2054 rect32
.right
= rc
->right
;
2055 rect32
.bottom
= rc
->bottom
;
2056 ret
= DrawFrameControl( HDC_32(hdc
), &rect32
, uType
, uState
);
2057 rc
->left
= rect32
.left
;
2058 rc
->top
= rect32
.top
;
2059 rc
->right
= rect32
.right
;
2060 rc
->bottom
= rect32
.bottom
;
2064 /**********************************************************************
2065 * DrawEdge (USER.659)
2067 BOOL16 WINAPI
DrawEdge16( HDC16 hdc
, LPRECT16 rc
, UINT16 edge
, UINT16 flags
)
2072 rect32
.left
= rc
->left
;
2073 rect32
.top
= rc
->top
;
2074 rect32
.right
= rc
->right
;
2075 rect32
.bottom
= rc
->bottom
;
2076 ret
= DrawEdge( HDC_32(hdc
), &rect32
, edge
, flags
);
2077 rc
->left
= rect32
.left
;
2078 rc
->top
= rect32
.top
;
2079 rc
->right
= rect32
.right
;
2080 rc
->bottom
= rect32
.bottom
;
2084 /**********************************************************************
2085 * CheckMenuRadioItem (USER.666)
2087 BOOL16 WINAPI
CheckMenuRadioItem16(HMENU16 hMenu
, UINT16 first
, UINT16 last
,
2088 UINT16 check
, BOOL16 bypos
)
2090 return CheckMenuRadioItem( HMENU_32(hMenu
), first
, last
, check
, bypos
);