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"
34 #include "wine/list.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))
41 #define HGDIOBJ_16(h32) (LOWORD(h32))
43 /* handle16 to handle conversions */
44 #define HANDLE_32(h16) ((HANDLE)(ULONG_PTR)(h16))
45 #define HGDIOBJ_32(h16) ((HGDIOBJ)(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 #define CID_RESOURCE 0x0001
58 #define CID_WIN32 0x0004
59 #define CID_NONSHARED 0x0008
61 WORD USER_HeapSel
= 0; /* USER heap selector */
63 static HINSTANCE16 gdi_inst
;
65 struct gray_string_info
67 GRAYSTRINGPROC16 proc
;
72 /* callback for 16-bit gray string proc with opaque pointer */
73 static BOOL CALLBACK
gray_string_callback( HDC hdc
, LPARAM param
, INT len
)
75 const struct gray_string_info
*info
= (struct gray_string_info
*)param
;
79 args
[3] = HDC_16(hdc
);
80 args
[2] = HIWORD(info
->param
);
81 args
[1] = LOWORD(info
->param
);
83 WOWCallback16Ex( (DWORD
)info
->proc
, WCB16_PASCAL
, sizeof(args
), args
, &ret
);
87 /* callback for 16-bit gray string proc with string pointer */
88 static BOOL CALLBACK
gray_string_callback_ptr( HDC hdc
, LPARAM param
, INT len
)
90 const struct gray_string_info
*info
;
91 char *str
= (char *)param
;
93 info
= (struct gray_string_info
*)(str
- offsetof( struct gray_string_info
, str
));
94 return gray_string_callback( hdc
, (LPARAM
)info
, len
);
97 struct draw_state_info
103 /* callback for 16-bit DrawState functions */
104 static BOOL CALLBACK
draw_state_callback( HDC hdc
, LPARAM lparam
, WPARAM wparam
, int cx
, int cy
)
106 const struct draw_state_info
*info
= (struct draw_state_info
*)lparam
;
110 args
[5] = HDC_16(hdc
);
111 args
[4] = HIWORD(info
->param
);
112 args
[3] = LOWORD(info
->param
);
116 WOWCallback16Ex( (DWORD
)info
->proc
, WCB16_PASCAL
, sizeof(args
), args
, &ret
);
120 /* This function is a copy of the one in objects/font.c */
121 static void logfont_32_to_16( const LOGFONTA
* font32
, LPLOGFONT16 font16
)
123 font16
->lfHeight
= font32
->lfHeight
;
124 font16
->lfWidth
= font32
->lfWidth
;
125 font16
->lfEscapement
= font32
->lfEscapement
;
126 font16
->lfOrientation
= font32
->lfOrientation
;
127 font16
->lfWeight
= font32
->lfWeight
;
128 font16
->lfItalic
= font32
->lfItalic
;
129 font16
->lfUnderline
= font32
->lfUnderline
;
130 font16
->lfStrikeOut
= font32
->lfStrikeOut
;
131 font16
->lfCharSet
= font32
->lfCharSet
;
132 font16
->lfOutPrecision
= font32
->lfOutPrecision
;
133 font16
->lfClipPrecision
= font32
->lfClipPrecision
;
134 font16
->lfQuality
= font32
->lfQuality
;
135 font16
->lfPitchAndFamily
= font32
->lfPitchAndFamily
;
136 lstrcpynA( font16
->lfFaceName
, font32
->lfFaceName
, LF_FACESIZE
);
139 static int get_bitmap_width_bytes( int width
, int bpp
)
144 return 2 * ((width
+15) / 16);
146 return 2 * ((width
+3) / 4);
151 return width
+ (width
& 1);
158 WARN("Unknown depth %d, please report.\n", bpp
);
163 /***********************************************************************
164 * Helper for wsprintf16
167 #define WPRINTF_LEFTALIGN 0x0001 /* Align output on the left ('-' prefix) */
168 #define WPRINTF_PREFIX_HEX 0x0002 /* Prefix hex with 0x ('#' prefix) */
169 #define WPRINTF_ZEROPAD 0x0004 /* Pad with zeros ('0' prefix) */
170 #define WPRINTF_LONG 0x0008 /* Long arg ('l' prefix) */
171 #define WPRINTF_SHORT 0x0010 /* Short arg ('h' prefix) */
172 #define WPRINTF_UPPER_HEX 0x0020 /* Upper-case hex ('X' specifier) */
192 static INT
parse_format( LPCSTR format
, WPRINTF_FORMAT
*res
)
199 if (*p
== '-') { res
->flags
|= WPRINTF_LEFTALIGN
; p
++; }
200 if (*p
== '#') { res
->flags
|= WPRINTF_PREFIX_HEX
; p
++; }
201 if (*p
== '0') { res
->flags
|= WPRINTF_ZEROPAD
; p
++; }
202 while ((*p
>= '0') && (*p
<= '9')) /* width field */
204 res
->width
= res
->width
* 10 + *p
- '0';
207 if (*p
== '.') /* precision field */
210 while ((*p
>= '0') && (*p
<= '9'))
212 res
->precision
= res
->precision
* 10 + *p
- '0';
216 if (*p
== 'l') { res
->flags
|= WPRINTF_LONG
; p
++; }
217 else if (*p
== 'h') { res
->flags
|= WPRINTF_SHORT
; p
++; }
221 case 'C': /* no Unicode in Win16 */
222 res
->type
= WPR_CHAR
;
226 res
->type
= WPR_STRING
;
230 res
->type
= WPR_SIGNED
;
233 res
->type
= WPR_UNSIGNED
;
237 res
->flags
|= WPRINTF_ZEROPAD
;
240 res
->flags
|= WPRINTF_UPPER_HEX
;
243 res
->type
= WPR_HEXA
;
245 default: /* unknown format char */
246 res
->type
= WPR_UNKNOWN
;
247 p
--; /* print format as normal char */
250 return (INT
)(p
- format
) + 1;
254 /**********************************************************************
255 * Management of the 16-bit cursors and icons
268 static struct list icon_cache
= LIST_INIT( icon_cache
);
270 static const WORD ICON_HOTSPOT
= 0x4242;
272 static HICON16
alloc_icon_handle( unsigned int size
)
274 HGLOBAL16 handle
= GlobalAlloc16( GMEM_MOVEABLE
, size
+ sizeof(ULONG_PTR
) );
275 char *ptr
= GlobalLock16( handle
);
276 memset( ptr
+ size
, 0, sizeof(ULONG_PTR
) );
277 GlobalUnlock16( handle
);
278 FarSetOwner16( handle
, 0 );
282 static CURSORICONINFO
*get_icon_ptr( HICON16 handle
)
284 return GlobalLock16( handle
);
287 static void release_icon_ptr( HICON16 handle
, CURSORICONINFO
*ptr
)
289 GlobalUnlock16( handle
);
292 static HICON
store_icon_32( HICON16 icon16
, HICON icon
)
295 CURSORICONINFO
*ptr
= get_icon_ptr( icon16
);
299 unsigned int and_size
= ptr
->nHeight
* get_bitmap_width_bytes( ptr
->nWidth
, 1 );
300 unsigned int xor_size
= ptr
->nHeight
* get_bitmap_width_bytes( ptr
->nWidth
, ptr
->bBitsPerPixel
);
301 if (GlobalSize16( icon16
) >= sizeof(*ptr
) + sizeof(ULONG_PTR
) + and_size
+ xor_size
)
303 memcpy( &ret
, (char *)(ptr
+ 1) + and_size
+ xor_size
, sizeof(ret
) );
304 memcpy( (char *)(ptr
+ 1) + and_size
+ xor_size
, &icon
, sizeof(icon
) );
305 wow_handlers32
.set_icon_param( icon
, icon16
);
307 release_icon_ptr( icon16
, ptr
);
312 static int free_icon_handle( HICON16 handle
)
316 if ((icon32
= store_icon_32( handle
, 0 ))) DestroyIcon( icon32
);
317 return GlobalFree16( handle
);
320 /* retrieve the 32-bit counterpart of a 16-bit icon, creating it if needed */
321 HICON
get_icon_32( HICON16 icon16
)
324 CURSORICONINFO
*ptr
= get_icon_ptr( icon16
);
328 unsigned int and_size
= ptr
->nHeight
* get_bitmap_width_bytes( ptr
->nWidth
, 1 );
329 unsigned int xor_size
= ptr
->nHeight
* get_bitmap_width_bytes( ptr
->nWidth
, ptr
->bBitsPerPixel
);
330 if (GlobalSize16( icon16
) >= sizeof(*ptr
) + sizeof(ULONG_PTR
) + xor_size
+ and_size
)
332 memcpy( &ret
, (char *)(ptr
+ 1) + xor_size
+ and_size
, sizeof(ret
) );
337 iinfo
.fIcon
= (ptr
->ptHotSpot
.x
== ICON_HOTSPOT
) && (ptr
->ptHotSpot
.y
== ICON_HOTSPOT
);
338 iinfo
.xHotspot
= ptr
->ptHotSpot
.x
;
339 iinfo
.yHotspot
= ptr
->ptHotSpot
.y
;
340 iinfo
.hbmMask
= CreateBitmap( ptr
->nWidth
, ptr
->nHeight
, 1, 1, ptr
+ 1 );
341 iinfo
.hbmColor
= CreateBitmap( ptr
->nWidth
, ptr
->nHeight
, ptr
->bPlanes
, ptr
->bBitsPerPixel
,
342 (char *)(ptr
+ 1) + and_size
);
343 ret
= CreateIconIndirect( &iinfo
);
344 DeleteObject( iinfo
.hbmMask
);
345 DeleteObject( iinfo
.hbmColor
);
346 memcpy( (char *)(ptr
+ 1) + xor_size
+ and_size
, &ret
, sizeof(ret
) );
347 wow_handlers32
.set_icon_param( ret
, icon16
);
350 release_icon_ptr( icon16
, ptr
);
355 /* retrieve the 16-bit counterpart of a 32-bit icon, creating it if needed */
356 HICON16
get_icon_16( HICON icon
)
358 HICON16 ret
= wow_handlers32
.get_icon_param( icon
);
364 UINT and_size
, xor_size
;
365 void *xor_bits
= NULL
, *and_bits
;
366 CURSORICONINFO cinfo
;
368 if (!(GetIconInfo( icon
, &info
))) return 0;
369 GetObjectW( info
.hbmMask
, sizeof(bm
), &bm
);
370 and_size
= bm
.bmHeight
* bm
.bmWidthBytes
;
371 if (!(and_bits
= HeapAlloc( GetProcessHeap(), 0, and_size
))) goto done
;
372 GetBitmapBits( info
.hbmMask
, and_size
, and_bits
);
375 GetObjectW( info
.hbmColor
, sizeof(bm
), &bm
);
376 xor_size
= bm
.bmHeight
* bm
.bmWidthBytes
;
377 if (!(xor_bits
= HeapAlloc( GetProcessHeap(), 0, xor_size
))) goto done
;
378 GetBitmapBits( info
.hbmColor
, xor_size
, xor_bits
);
383 xor_bits
= (char *)and_bits
+ and_size
/ 2;
387 cinfo
.ptHotSpot
.x
= info
.xHotspot
;
388 cinfo
.ptHotSpot
.y
= info
.yHotspot
;
390 else cinfo
.ptHotSpot
.x
= cinfo
.ptHotSpot
.y
= ICON_HOTSPOT
;
392 cinfo
.nWidth
= bm
.bmWidth
;
393 cinfo
.nHeight
= bm
.bmHeight
;
394 cinfo
.nWidthBytes
= bm
.bmWidthBytes
;
395 cinfo
.bPlanes
= bm
.bmPlanes
;
396 cinfo
.bBitsPerPixel
= bm
.bmBitsPixel
;
398 if ((ret
= CreateCursorIconIndirect16( 0, &cinfo
, and_bits
, xor_bits
)))
399 store_icon_32( ret
, icon
);
404 HeapFree( GetProcessHeap(), 0, xor_bits
);
405 DeleteObject( info
.hbmColor
);
407 HeapFree( GetProcessHeap(), 0, and_bits
);
408 DeleteObject( info
.hbmMask
);
413 static void add_shared_icon( HINSTANCE16 inst
, HRSRC16 rsrc
, HRSRC16 group
, HICON16 icon
)
415 struct cache_entry
*cache
= HeapAlloc( GetProcessHeap(), 0, sizeof(*cache
) );
420 cache
->group
= group
;
423 list_add_tail( &icon_cache
, &cache
->entry
);
426 static HICON16
find_shared_icon( HINSTANCE16 inst
, HRSRC16 rsrc
)
428 struct cache_entry
*cache
;
430 LIST_FOR_EACH_ENTRY( cache
, &icon_cache
, struct cache_entry
, entry
)
432 if (cache
->inst
!= inst
|| cache
->rsrc
!= rsrc
) continue;
439 static int release_shared_icon( HICON16 icon
)
441 struct cache_entry
*cache
;
443 LIST_FOR_EACH_ENTRY( cache
, &icon_cache
, struct cache_entry
, entry
)
445 if (cache
->icon
!= icon
) continue;
446 if (!cache
->count
) return 0;
447 return --cache
->count
;
452 static void free_module_icons( HINSTANCE16 inst
)
454 struct cache_entry
*cache
, *next
;
456 LIST_FOR_EACH_ENTRY_SAFE( cache
, next
, &icon_cache
, struct cache_entry
, entry
)
458 if (cache
->inst
!= inst
) continue;
459 list_remove( &cache
->entry
);
460 free_icon_handle( cache
->icon
);
461 HeapFree( GetProcessHeap(), 0, cache
);
465 /**********************************************************************
466 * Management of the 16-bit clipboard formats
469 struct clipboard_format
476 static struct list clipboard_formats
= LIST_INIT( clipboard_formats
);
478 static void set_clipboard_format( UINT format
, HANDLE16 data
)
480 struct clipboard_format
*fmt
;
482 /* replace it if it exists already */
483 LIST_FOR_EACH_ENTRY( fmt
, &clipboard_formats
, struct clipboard_format
, entry
)
485 if (fmt
->format
!= format
) continue;
486 GlobalFree16( fmt
->data
);
491 if ((fmt
= HeapAlloc( GetProcessHeap(), 0, sizeof(*fmt
) )))
493 fmt
->format
= format
;
495 list_add_tail( &clipboard_formats
, &fmt
->entry
);
499 static void free_clipboard_formats(void)
503 while ((head
= list_head( &clipboard_formats
)))
505 struct clipboard_format
*fmt
= LIST_ENTRY( head
, struct clipboard_format
, entry
);
506 list_remove( &fmt
->entry
);
507 GlobalFree16( fmt
->data
);
508 HeapFree( GetProcessHeap(), 0, fmt
);
513 /***********************************************************************
514 * OldExitWindows (USER.2)
516 void WINAPI
OldExitWindows16(void)
522 /**********************************************************************
525 INT16 WINAPI
InitApp16( HINSTANCE16 hInstance
)
527 /* Create task message queue */
528 return (InitThreadInput16( 0, 0 ) != 0);
532 /***********************************************************************
533 * ExitWindows (USER.7)
535 BOOL16 WINAPI
ExitWindows16( DWORD dwReturnCode
, UINT16 wReserved
)
537 return ExitWindowsEx( EWX_LOGOFF
, 0xffffffff );
541 /***********************************************************************
542 * GetTimerResolution (USER.14)
544 LONG WINAPI
GetTimerResolution16(void)
550 /***********************************************************************
551 * ClipCursor (USER.16)
553 BOOL16 WINAPI
ClipCursor16( const RECT16
*rect
)
557 if (!rect
) return ClipCursor( NULL
);
558 rect32
.left
= rect
->left
;
559 rect32
.top
= rect
->top
;
560 rect32
.right
= rect
->right
;
561 rect32
.bottom
= rect
->bottom
;
562 return ClipCursor( &rect32
);
566 /***********************************************************************
567 * GetCursorPos (USER.17)
569 BOOL16 WINAPI
GetCursorPos16( POINT16
*pt
)
572 if (!pt
) return FALSE
;
580 /*******************************************************************
583 BOOL16 WINAPI
AnyPopup16(void)
589 /***********************************************************************
590 * SetCursor (USER.69)
592 HCURSOR16 WINAPI
SetCursor16(HCURSOR16 hCursor
)
594 return get_icon_16( SetCursor( get_icon_32(hCursor
) ));
598 /***********************************************************************
599 * SetCursorPos (USER.70)
601 void WINAPI
SetCursorPos16( INT16 x
, INT16 y
)
603 SetCursorPos( x
, y
);
607 /***********************************************************************
608 * ShowCursor (USER.71)
610 INT16 WINAPI
ShowCursor16(BOOL16 bShow
)
612 return ShowCursor(bShow
);
616 /***********************************************************************
619 void WINAPI
SetRect16( LPRECT16 rect
, INT16 left
, INT16 top
, INT16 right
, INT16 bottom
)
624 rect
->bottom
= bottom
;
628 /***********************************************************************
629 * SetRectEmpty (USER.73)
631 void WINAPI
SetRectEmpty16( LPRECT16 rect
)
633 rect
->left
= rect
->right
= rect
->top
= rect
->bottom
= 0;
637 /***********************************************************************
640 BOOL16 WINAPI
CopyRect16( RECT16
*dest
, const RECT16
*src
)
647 /***********************************************************************
648 * IsRectEmpty (USER.75)
650 * Bug compat: Windows checks for 0 or negative width/height.
652 BOOL16 WINAPI
IsRectEmpty16( const RECT16
*rect
)
654 return ((rect
->left
>= rect
->right
) || (rect
->top
>= rect
->bottom
));
658 /***********************************************************************
661 BOOL16 WINAPI
PtInRect16( const RECT16
*rect
, POINT16 pt
)
663 return ((pt
.x
>= rect
->left
) && (pt
.x
< rect
->right
) &&
664 (pt
.y
>= rect
->top
) && (pt
.y
< rect
->bottom
));
668 /***********************************************************************
669 * OffsetRect (USER.77)
671 void WINAPI
OffsetRect16( LPRECT16 rect
, INT16 x
, INT16 y
)
680 /***********************************************************************
681 * InflateRect (USER.78)
683 void WINAPI
InflateRect16( LPRECT16 rect
, INT16 x
, INT16 y
)
692 /***********************************************************************
693 * IntersectRect (USER.79)
695 BOOL16 WINAPI
IntersectRect16( LPRECT16 dest
, const RECT16
*src1
,
698 if (IsRectEmpty16(src1
) || IsRectEmpty16(src2
) ||
699 (src1
->left
>= src2
->right
) || (src2
->left
>= src1
->right
) ||
700 (src1
->top
>= src2
->bottom
) || (src2
->top
>= src1
->bottom
))
702 SetRectEmpty16( dest
);
705 dest
->left
= max( src1
->left
, src2
->left
);
706 dest
->right
= min( src1
->right
, src2
->right
);
707 dest
->top
= max( src1
->top
, src2
->top
);
708 dest
->bottom
= min( src1
->bottom
, src2
->bottom
);
713 /***********************************************************************
714 * UnionRect (USER.80)
716 BOOL16 WINAPI
UnionRect16( LPRECT16 dest
, const RECT16
*src1
,
719 if (IsRectEmpty16(src1
))
721 if (IsRectEmpty16(src2
))
723 SetRectEmpty16( dest
);
730 if (IsRectEmpty16(src2
)) *dest
= *src1
;
733 dest
->left
= min( src1
->left
, src2
->left
);
734 dest
->right
= max( src1
->right
, src2
->right
);
735 dest
->top
= min( src1
->top
, src2
->top
);
736 dest
->bottom
= max( src1
->bottom
, src2
->bottom
);
743 /***********************************************************************
746 * The Win16 variant doesn't support special color brushes like
747 * the Win32 one, despite the fact that Win16, as well as Win32,
748 * supports special background brushes for a window class.
750 INT16 WINAPI
FillRect16( HDC16 hdc
, const RECT16
*rect
, HBRUSH16 hbrush
)
754 /* coordinates are logical so we cannot fast-check 'rect',
755 * it will be done later in the PatBlt().
758 if (!(prevBrush
= SelectObject( HDC_32(hdc
), HBRUSH_32(hbrush
) ))) return 0;
759 PatBlt( HDC_32(hdc
), rect
->left
, rect
->top
,
760 rect
->right
- rect
->left
, rect
->bottom
- rect
->top
, PATCOPY
);
761 SelectObject( HDC_32(hdc
), prevBrush
);
766 /***********************************************************************
767 * InvertRect (USER.82)
769 void WINAPI
InvertRect16( HDC16 hdc
, const RECT16
*rect
)
771 PatBlt( HDC_32(hdc
), rect
->left
, rect
->top
,
772 rect
->right
- rect
->left
, rect
->bottom
- rect
->top
, DSTINVERT
);
776 /***********************************************************************
777 * FrameRect (USER.83)
779 INT16 WINAPI
FrameRect16( HDC16 hdc
, const RECT16
*rect16
, HBRUSH16 hbrush
)
783 rect
.left
= rect16
->left
;
784 rect
.top
= rect16
->top
;
785 rect
.right
= rect16
->right
;
786 rect
.bottom
= rect16
->bottom
;
787 return FrameRect( HDC_32(hdc
), &rect
, HBRUSH_32(hbrush
) );
791 /***********************************************************************
794 BOOL16 WINAPI
DrawIcon16(HDC16 hdc
, INT16 x
, INT16 y
, HICON16 hIcon
)
796 return DrawIcon(HDC_32(hdc
), x
, y
, get_icon_32(hIcon
) );
800 /***********************************************************************
803 INT16 WINAPI
DrawText16( HDC16 hdc
, LPCSTR str
, INT16 count
, LPRECT16 rect
, UINT16 flags
)
811 rect32
.left
= rect
->left
;
812 rect32
.top
= rect
->top
;
813 rect32
.right
= rect
->right
;
814 rect32
.bottom
= rect
->bottom
;
815 ret
= DrawTextA( HDC_32(hdc
), str
, count
, &rect32
, flags
);
816 rect
->left
= rect32
.left
;
817 rect
->top
= rect32
.top
;
818 rect
->right
= rect32
.right
;
819 rect
->bottom
= rect32
.bottom
;
821 else ret
= DrawTextA( HDC_32(hdc
), str
, count
, NULL
, flags
);
826 /***********************************************************************
829 * See "Undocumented Windows". Used by W2.0 paint.exe.
831 DWORD WINAPI
IconSize16(void)
833 return MAKELONG(GetSystemMetrics(SM_CYICON
), GetSystemMetrics(SM_CXICON
));
837 /***********************************************************************
838 * AdjustWindowRect (USER.102)
840 BOOL16 WINAPI
AdjustWindowRect16( LPRECT16 rect
, DWORD style
, BOOL16 menu
)
842 return AdjustWindowRectEx16( rect
, style
, menu
, 0 );
846 /***********************************************************************
847 * MessageBeep (USER.104)
849 void WINAPI
MessageBeep16( UINT16 i
)
855 /**************************************************************************
856 * CloseClipboard (USER.138)
858 BOOL16 WINAPI
CloseClipboard16(void)
860 BOOL ret
= CloseClipboard();
861 if (ret
) free_clipboard_formats();
866 /**************************************************************************
867 * EmptyClipboard (USER.139)
869 BOOL16 WINAPI
EmptyClipboard16(void)
871 BOOL ret
= EmptyClipboard();
872 if (ret
) free_clipboard_formats();
877 /**************************************************************************
878 * SetClipboardData (USER.141)
880 HANDLE16 WINAPI
SetClipboardData16( UINT16 format
, HANDLE16 data16
)
888 data32
= HGDIOBJ_32( data16
);
891 case CF_METAFILEPICT
:
894 METAFILEPICT
*pict32
;
895 METAFILEPICT16
*pict16
= GlobalLock16( data16
);
899 if (!(data32
= GlobalAlloc( GMEM_MOVEABLE
, sizeof(*pict32
) ))) return 0;
900 pict32
= GlobalLock( data32
);
901 pict32
->mm
= pict16
->mm
;
902 pict32
->xExt
= pict16
->xExt
;
903 pict32
->yExt
= pict16
->yExt
;
904 header
= GlobalLock16( pict16
->hMF
);
905 pict32
->hMF
= SetMetaFileBitsEx( header
->mtSize
* 2, (BYTE
*)header
);
906 GlobalUnlock16( pict16
->hMF
);
907 GlobalUnlock( data32
);
909 set_clipboard_format( format
, data16
);
914 FIXME( "enhmetafile not supported in 16-bit\n" );
918 if (format
>= CF_GDIOBJFIRST
&& format
<= CF_GDIOBJLAST
)
919 data32
= HGDIOBJ_32( data16
);
920 else if (format
>= CF_PRIVATEFIRST
&& format
<= CF_PRIVATELAST
)
921 data32
= HANDLE_32( data16
);
924 UINT size
= GlobalSize16( data16
);
925 void *ptr32
, *ptr16
= GlobalLock16( data16
);
928 if (!(data32
= GlobalAlloc( GMEM_MOVEABLE
, size
))) return 0;
929 ptr32
= GlobalLock( data32
);
930 memcpy( ptr32
, ptr16
, size
);
931 GlobalUnlock( data32
);
933 set_clipboard_format( format
, data16
);
938 if (!SetClipboardData( format
, data32
)) return 0;
943 /**************************************************************************
944 * GetClipboardData (USER.142)
946 HANDLE16 WINAPI
GetClipboardData16( UINT16 format
)
948 HANDLE data32
= GetClipboardData( format
);
953 if (!data32
) return 0;
959 data16
= HGDIOBJ_16( data32
);
962 case CF_METAFILEPICT
:
964 METAFILEPICT16
*pict16
;
965 METAFILEPICT
*pict32
= GlobalLock( data32
);
969 if (!(data16
= GlobalAlloc16( GMEM_MOVEABLE
, sizeof(*pict16
) ))) return 0;
970 pict16
= GlobalLock16( data16
);
971 pict16
->mm
= pict32
->mm
;
972 pict16
->xExt
= pict32
->xExt
;
973 pict16
->yExt
= pict32
->yExt
;
974 size
= GetMetaFileBitsEx( pict32
->hMF
, 0, NULL
);
975 pict16
->hMF
= GlobalAlloc16( GMEM_MOVEABLE
, size
);
976 ptr
= GlobalLock16( pict16
->hMF
);
977 GetMetaFileBitsEx( pict32
->hMF
, size
, ptr
);
978 GlobalUnlock16( pict16
->hMF
);
979 GlobalUnlock16( data16
);
980 set_clipboard_format( format
, data16
);
986 FIXME( "enhmetafile not supported in 16-bit\n" );
990 if (format
>= CF_GDIOBJFIRST
&& format
<= CF_GDIOBJLAST
)
991 data16
= HGDIOBJ_16( data32
);
992 else if (format
>= CF_PRIVATEFIRST
&& format
<= CF_PRIVATELAST
)
993 data16
= HANDLE_16( data32
);
996 void *ptr16
, *ptr32
= GlobalLock( data32
);
999 size
= GlobalSize( data32
);
1000 if (!(data16
= GlobalAlloc16( GMEM_MOVEABLE
, size
))) return 0;
1001 ptr16
= GlobalLock16( data16
);
1002 memcpy( ptr16
, ptr32
, size
);
1003 GlobalUnlock16( data16
);
1004 set_clipboard_format( format
, data16
);
1013 /**************************************************************************
1014 * CountClipboardFormats (USER.143)
1016 INT16 WINAPI
CountClipboardFormats16(void)
1018 return CountClipboardFormats();
1022 /**************************************************************************
1023 * EnumClipboardFormats (USER.144)
1025 UINT16 WINAPI
EnumClipboardFormats16( UINT16 id
)
1027 return EnumClipboardFormats( id
);
1031 /**************************************************************************
1032 * RegisterClipboardFormat (USER.145)
1034 UINT16 WINAPI
RegisterClipboardFormat16( LPCSTR name
)
1036 return RegisterClipboardFormatA( name
);
1040 /**************************************************************************
1041 * GetClipboardFormatName (USER.146)
1043 INT16 WINAPI
GetClipboardFormatName16( UINT16 id
, LPSTR buffer
, INT16 maxlen
)
1045 return GetClipboardFormatNameA( id
, buffer
, maxlen
);
1049 /**********************************************************************
1050 * LoadMenu (USER.150)
1052 HMENU16 WINAPI
LoadMenu16( HINSTANCE16 instance
, LPCSTR name
)
1058 if (HIWORD(name
) && name
[0] == '#') name
= ULongToPtr(atoi( name
+ 1 ));
1059 if (!name
) return 0;
1061 instance
= GetExePtr( instance
);
1062 if (!(hRsrc
= FindResource16( instance
, name
, (LPSTR
)RT_MENU
))) return 0;
1063 if (!(handle
= LoadResource16( instance
, hRsrc
))) return 0;
1064 hMenu
= LoadMenuIndirect16(LockResource16(handle
));
1065 FreeResource16( handle
);
1070 /**********************************************************************
1071 * CreateMenu (USER.151)
1073 HMENU16 WINAPI
CreateMenu16(void)
1075 return HMENU_16( CreateMenu() );
1079 /**********************************************************************
1080 * DestroyMenu (USER.152)
1082 BOOL16 WINAPI
DestroyMenu16( HMENU16 hMenu
)
1084 return DestroyMenu( HMENU_32(hMenu
) );
1088 /*******************************************************************
1089 * ChangeMenu (USER.153)
1091 BOOL16 WINAPI
ChangeMenu16( HMENU16 hMenu
, UINT16 pos
, SEGPTR data
,
1092 UINT16 id
, UINT16 flags
)
1094 if (flags
& MF_APPEND
) return AppendMenu16( hMenu
, flags
& ~MF_APPEND
, id
, data
);
1096 /* FIXME: Word passes the item id in 'pos' and 0 or 0xffff as id */
1097 /* for MF_DELETE. We should check the parameters for all others */
1098 /* MF_* actions also (anybody got a doc on ChangeMenu?). */
1100 if (flags
& MF_DELETE
) return DeleteMenu16(hMenu
, pos
, flags
& ~MF_DELETE
);
1101 if (flags
& MF_CHANGE
) return ModifyMenu16(hMenu
, pos
, flags
& ~MF_CHANGE
, id
, data
);
1102 if (flags
& MF_REMOVE
) return RemoveMenu16(hMenu
, flags
& MF_BYPOSITION
? pos
: id
,
1103 flags
& ~MF_REMOVE
);
1104 /* Default: MF_INSERT */
1105 return InsertMenu16( hMenu
, pos
, flags
, id
, data
);
1109 /*******************************************************************
1110 * CheckMenuItem (USER.154)
1112 BOOL16 WINAPI
CheckMenuItem16( HMENU16 hMenu
, UINT16 id
, UINT16 flags
)
1114 return CheckMenuItem( HMENU_32(hMenu
), id
, flags
);
1118 /**********************************************************************
1119 * EnableMenuItem (USER.155)
1121 BOOL16 WINAPI
EnableMenuItem16( HMENU16 hMenu
, UINT16 wItemID
, UINT16 wFlags
)
1123 return EnableMenuItem( HMENU_32(hMenu
), wItemID
, wFlags
);
1127 /**********************************************************************
1128 * GetSubMenu (USER.159)
1130 HMENU16 WINAPI
GetSubMenu16( HMENU16 hMenu
, INT16 nPos
)
1132 return HMENU_16( GetSubMenu( HMENU_32(hMenu
), nPos
) );
1136 /*******************************************************************
1137 * GetMenuString (USER.161)
1139 INT16 WINAPI
GetMenuString16( HMENU16 hMenu
, UINT16 wItemID
,
1140 LPSTR str
, INT16 nMaxSiz
, UINT16 wFlags
)
1142 return GetMenuStringA( HMENU_32(hMenu
), wItemID
, str
, nMaxSiz
, wFlags
);
1146 /**********************************************************************
1147 * WinHelp (USER.171)
1149 BOOL16 WINAPI
WinHelp16( HWND16 hWnd
, LPCSTR lpHelpFile
, UINT16 wCommand
,
1155 /* We might call WinExec() */
1156 ReleaseThunkLock(&mutex_count
);
1158 ret
= WinHelpA(WIN_Handle32(hWnd
), lpHelpFile
, wCommand
, (DWORD
)MapSL(dwData
));
1160 RestoreThunkLock(mutex_count
);
1165 /***********************************************************************
1166 * LoadCursor (USER.173)
1168 HCURSOR16 WINAPI
LoadCursor16(HINSTANCE16 hInstance
, LPCSTR name
)
1170 return LoadImage16( hInstance
, name
, IMAGE_CURSOR
, 0, 0, LR_SHARED
| LR_DEFAULTSIZE
);
1174 /***********************************************************************
1175 * LoadIcon (USER.174)
1177 HICON16 WINAPI
LoadIcon16(HINSTANCE16 hInstance
, LPCSTR name
)
1179 return LoadImage16( hInstance
, name
, IMAGE_ICON
, 0, 0, LR_SHARED
| LR_DEFAULTSIZE
);
1182 /**********************************************************************
1183 * LoadBitmap (USER.175)
1185 HBITMAP16 WINAPI
LoadBitmap16(HINSTANCE16 hInstance
, LPCSTR name
)
1187 return LoadImage16( hInstance
, name
, IMAGE_BITMAP
, 0, 0, 0 );
1190 /**********************************************************************
1191 * LoadString (USER.176)
1193 INT16 WINAPI
LoadString16( HINSTANCE16 instance
, UINT16 resource_id
, LPSTR buffer
, INT16 buflen
)
1201 TRACE("inst=%04x id=%04x buff=%p len=%d\n", instance
, resource_id
, buffer
, buflen
);
1203 hrsrc
= FindResource16( instance
, MAKEINTRESOURCEA((resource_id
>>4)+1), (LPSTR
)RT_STRING
);
1204 if (!hrsrc
) return 0;
1205 hmem
= LoadResource16( instance
, hrsrc
);
1206 if (!hmem
) return 0;
1208 p
= LockResource16(hmem
);
1209 string_num
= resource_id
& 0x000f;
1210 while (string_num
--) p
+= *p
+ 1;
1212 if (buffer
== NULL
) ret
= *p
;
1215 ret
= min(buflen
- 1, *p
);
1218 memcpy(buffer
, p
+ 1, ret
);
1221 else if (buflen
> 1)
1226 TRACE( "%s loaded\n", debugstr_a(buffer
));
1228 FreeResource16( hmem
);
1232 /**********************************************************************
1233 * LoadAccelerators (USER.177)
1235 HACCEL16 WINAPI
LoadAccelerators16(HINSTANCE16 instance
, LPCSTR lpTableName
)
1242 TRACE("%04x %s\n", instance
, debugstr_a(lpTableName
) );
1244 if (!(hRsrc
= FindResource16( instance
, lpTableName
, (LPSTR
)RT_ACCELERATOR
)) ||
1245 !(hMem
= LoadResource16(instance
,hRsrc
)))
1247 WARN("couldn't find %04x %s\n", instance
, debugstr_a(lpTableName
));
1250 if ((table16
= LockResource16( hMem
)))
1252 DWORD i
, count
= SizeofResource16( instance
, hRsrc
) / sizeof(*table16
);
1253 ACCEL
*table
= HeapAlloc( GetProcessHeap(), 0, count
* sizeof(*table
) );
1256 for (i
= 0; i
< count
; i
++)
1258 table
[i
].fVirt
= table16
[i
].fVirt
& 0x7f;
1259 table
[i
].key
= table16
[i
].key
;
1260 table
[i
].cmd
= table16
[i
].cmd
;
1262 ret
= CreateAcceleratorTableA( table
, count
);
1263 HeapFree( GetProcessHeap(), 0, table
);
1266 FreeResource16( hMem
);
1267 return HACCEL_16(ret
);
1270 /***********************************************************************
1271 * GetSystemMetrics (USER.179)
1273 INT16 WINAPI
GetSystemMetrics16( INT16 index
)
1275 return GetSystemMetrics( index
);
1279 /*************************************************************************
1280 * GetSysColor (USER.180)
1282 COLORREF WINAPI
GetSysColor16( INT16 index
)
1284 return GetSysColor( index
);
1288 /*************************************************************************
1289 * SetSysColors (USER.181)
1291 VOID WINAPI
SetSysColors16( INT16 count
, const INT16
*list16
, const COLORREF
*values
)
1295 if ((list
= HeapAlloc( GetProcessHeap(), 0, count
* sizeof(*list
) )))
1297 for (i
= 0; i
< count
; i
++) list
[i
] = list16
[i
];
1298 SetSysColors( count
, list
, values
);
1299 HeapFree( GetProcessHeap(), 0, list
);
1304 /***********************************************************************
1305 * GrayString (USER.185)
1307 BOOL16 WINAPI
GrayString16( HDC16 hdc
, HBRUSH16 hbr
, GRAYSTRINGPROC16 gsprc
,
1308 LPARAM lParam
, INT16 cch
, INT16 x
, INT16 y
,
1309 INT16 cx
, INT16 cy
)
1313 if (!gsprc
) return GrayStringA( HDC_32(hdc
), HBRUSH_32(hbr
), NULL
,
1314 (LPARAM
)MapSL(lParam
), cch
, x
, y
, cx
, cy
);
1316 if (cch
== -1 || (cch
&& cx
&& cy
))
1318 /* lParam can be treated as an opaque pointer */
1319 struct gray_string_info info
;
1322 info
.param
= lParam
;
1323 ret
= GrayStringA( HDC_32(hdc
), HBRUSH_32(hbr
), gray_string_callback
,
1324 (LPARAM
)&info
, cch
, x
, y
, cx
, cy
);
1326 else /* here we need some string conversions */
1328 char *str16
= MapSL(lParam
);
1329 struct gray_string_info
*info
;
1331 if (!cch
) cch
= strlen(str16
);
1332 info
= HeapAlloc( GetProcessHeap(), 0, FIELD_OFFSET( struct gray_string_info
, str
[cch
] ));
1333 if (!info
) return FALSE
;
1335 info
->param
= lParam
;
1336 memcpy( info
->str
, str16
, cch
);
1337 ret
= GrayStringA( HDC_32(hdc
), HBRUSH_32(hbr
), gray_string_callback_ptr
,
1338 (LPARAM
)info
->str
, cch
, x
, y
, cx
, cy
);
1339 HeapFree( GetProcessHeap(), 0, info
);
1345 /***********************************************************************
1346 * SwapMouseButton (USER.186)
1348 BOOL16 WINAPI
SwapMouseButton16( BOOL16 fSwap
)
1350 return SwapMouseButton( fSwap
);
1354 /**************************************************************************
1355 * IsClipboardFormatAvailable (USER.193)
1357 BOOL16 WINAPI
IsClipboardFormatAvailable16( UINT16 wFormat
)
1359 return IsClipboardFormatAvailable( wFormat
);
1363 /***********************************************************************
1364 * TabbedTextOut (USER.196)
1366 LONG WINAPI
TabbedTextOut16( HDC16 hdc
, INT16 x
, INT16 y
, LPCSTR lpstr
,
1367 INT16 count
, INT16 nb_tabs
, const INT16
*tabs16
, INT16 tab_org
)
1370 INT i
, *tabs
= HeapAlloc( GetProcessHeap(), 0, nb_tabs
* sizeof(*tabs
) );
1371 if (!tabs
) return 0;
1372 for (i
= 0; i
< nb_tabs
; i
++) tabs
[i
] = tabs16
[i
];
1373 ret
= TabbedTextOutA( HDC_32(hdc
), x
, y
, lpstr
, count
, nb_tabs
, tabs
, tab_org
);
1374 HeapFree( GetProcessHeap(), 0, tabs
);
1379 /***********************************************************************
1380 * GetTabbedTextExtent (USER.197)
1382 DWORD WINAPI
GetTabbedTextExtent16( HDC16 hdc
, LPCSTR lpstr
, INT16 count
,
1383 INT16 nb_tabs
, const INT16
*tabs16
)
1386 INT i
, *tabs
= HeapAlloc( GetProcessHeap(), 0, nb_tabs
* sizeof(*tabs
) );
1387 if (!tabs
) return 0;
1388 for (i
= 0; i
< nb_tabs
; i
++) tabs
[i
] = tabs16
[i
];
1389 ret
= GetTabbedTextExtentA( HDC_32(hdc
), lpstr
, count
, nb_tabs
, tabs
);
1390 HeapFree( GetProcessHeap(), 0, tabs
);
1395 /***********************************************************************
1396 * UserSeeUserDo (USER.216)
1398 DWORD WINAPI
UserSeeUserDo16(WORD wReqType
, WORD wParam1
, WORD wParam2
, WORD wParam3
)
1400 STACK16FRAME
* stack16
= MapSL((SEGPTR
)NtCurrentTeb()->WOW32Reserved
);
1401 HANDLE16 oldDS
= stack16
->ds
;
1402 DWORD ret
= (DWORD
)-1;
1404 stack16
->ds
= USER_HeapSel
;
1407 case USUD_LOCALALLOC
:
1408 ret
= LocalAlloc16(wParam1
, wParam3
);
1410 case USUD_LOCALFREE
:
1411 ret
= LocalFree16(wParam1
);
1413 case USUD_LOCALCOMPACT
:
1414 ret
= LocalCompact16(wParam3
);
1416 case USUD_LOCALHEAP
:
1419 case USUD_FIRSTCLASS
:
1420 FIXME("return a pointer to the first window class.\n");
1423 WARN("wReqType %04x (unknown)\n", wReqType
);
1425 stack16
->ds
= oldDS
;
1430 /***********************************************************************
1431 * LookupMenuHandle (USER.217)
1433 HMENU16 WINAPI
LookupMenuHandle16( HMENU16 hmenu
, INT16 id
)
1435 FIXME( "%04x %04x: stub\n", hmenu
, id
);
1440 static LPCSTR
parse_menu_resource( LPCSTR res
, HMENU hMenu
, BOOL oldFormat
)
1448 /* Windows 3.00 and later use a WORD for the flags, whereas 1.x and 2.x use a BYTE. */
1451 flags
= GET_BYTE(res
);
1452 res
+= sizeof(BYTE
);
1456 flags
= GET_WORD(res
);
1457 res
+= sizeof(WORD
);
1460 end_flag
= flags
& MF_END
;
1461 /* Remove MF_END because it has the same value as MF_HILITE */
1463 if (!(flags
& MF_POPUP
))
1466 res
+= sizeof(WORD
);
1469 res
+= strlen(str
) + 1;
1470 if (flags
& MF_POPUP
)
1472 HMENU hSubMenu
= CreatePopupMenu();
1473 if (!hSubMenu
) return NULL
;
1474 if (!(res
= parse_menu_resource( res
, hSubMenu
, oldFormat
))) return NULL
;
1475 AppendMenuA( hMenu
, flags
, (UINT_PTR
)hSubMenu
, str
);
1477 else /* Not a popup */
1479 AppendMenuA( hMenu
, flags
, id
, *str
? str
: NULL
);
1481 } while (!end_flag
);
1485 /**********************************************************************
1486 * LoadMenuIndirect (USER.220)
1488 HMENU16 WINAPI
LoadMenuIndirect16( LPCVOID
template )
1492 WORD version
, offset
;
1493 LPCSTR p
= template;
1495 TRACE("(%p)\n", template );
1497 /* Windows 1.x and 2.x menus have a slightly different menu format from 3.x menus */
1498 oldFormat
= (GetExeVersion16() < 0x0300);
1500 /* Windows 3.00 and later menu items are preceded by a MENUITEMTEMPLATEHEADER structure */
1503 version
= GET_WORD(p
);
1507 WARN("version must be 0 for Win16 >= 3.00 applications\n" );
1510 offset
= GET_WORD(p
);
1511 p
+= sizeof(WORD
) + offset
;
1514 if (!(hMenu
= CreateMenu())) return 0;
1515 if (!parse_menu_resource( p
, hMenu
, oldFormat
))
1517 DestroyMenu( hMenu
);
1520 return HMENU_16(hMenu
);
1524 /*************************************************************************
1525 * ScrollDC (USER.221)
1527 BOOL16 WINAPI
ScrollDC16( HDC16 hdc
, INT16 dx
, INT16 dy
, const RECT16
*rect
,
1528 const RECT16
*cliprc
, HRGN16 hrgnUpdate
,
1531 RECT rect32
, clipRect32
, rcUpdate32
;
1536 rect32
.left
= rect
->left
;
1537 rect32
.top
= rect
->top
;
1538 rect32
.right
= rect
->right
;
1539 rect32
.bottom
= rect
->bottom
;
1543 clipRect32
.left
= cliprc
->left
;
1544 clipRect32
.top
= cliprc
->top
;
1545 clipRect32
.right
= cliprc
->right
;
1546 clipRect32
.bottom
= cliprc
->bottom
;
1548 ret
= ScrollDC( HDC_32(hdc
), dx
, dy
, rect
? &rect32
: NULL
,
1549 cliprc
? &clipRect32
: NULL
, HRGN_32(hrgnUpdate
),
1553 rcUpdate
->left
= rcUpdate32
.left
;
1554 rcUpdate
->top
= rcUpdate32
.top
;
1555 rcUpdate
->right
= rcUpdate32
.right
;
1556 rcUpdate
->bottom
= rcUpdate32
.bottom
;
1562 /***********************************************************************
1563 * GetSystemDebugState (USER.231)
1565 WORD WINAPI
GetSystemDebugState16(void)
1567 return 0; /* FIXME */
1571 /***********************************************************************
1572 * EqualRect (USER.244)
1574 BOOL16 WINAPI
EqualRect16( const RECT16
* rect1
, const RECT16
* rect2
)
1576 return ((rect1
->left
== rect2
->left
) && (rect1
->right
== rect2
->right
) &&
1577 (rect1
->top
== rect2
->top
) && (rect1
->bottom
== rect2
->bottom
));
1581 /***********************************************************************
1582 * ExitWindowsExec (USER.246)
1584 BOOL16 WINAPI
ExitWindowsExec16( LPCSTR lpszExe
, LPCSTR lpszParams
)
1586 TRACE("Should run the following in DOS-mode: \"%s %s\"\n",
1587 lpszExe
, lpszParams
);
1588 return ExitWindowsEx( EWX_LOGOFF
, 0xffffffff );
1592 /***********************************************************************
1593 * GetCursor (USER.247)
1595 HCURSOR16 WINAPI
GetCursor16(void)
1597 return get_icon_16( GetCursor() );
1601 /**********************************************************************
1602 * GetAsyncKeyState (USER.249)
1604 INT16 WINAPI
GetAsyncKeyState16( INT16 key
)
1606 return GetAsyncKeyState( key
);
1610 /**********************************************************************
1611 * GetMenuState (USER.250)
1613 UINT16 WINAPI
GetMenuState16( HMENU16 hMenu
, UINT16 wItemID
, UINT16 wFlags
)
1615 return GetMenuState( HMENU_32(hMenu
), wItemID
, wFlags
);
1619 /**************************************************************************
1620 * SendDriverMessage (USER.251)
1622 LRESULT WINAPI
SendDriverMessage16(HDRVR16 hDriver
, UINT16 msg
, LPARAM lParam1
,
1625 FIXME("(%04x, %04x, %08lx, %08lx): stub\n", hDriver
, msg
, lParam1
, lParam2
);
1630 /**************************************************************************
1631 * OpenDriver (USER.252)
1633 HDRVR16 WINAPI
OpenDriver16(LPCSTR lpDriverName
, LPCSTR lpSectionName
, LPARAM lParam2
)
1635 FIXME( "(%s, %s, %08lx): stub\n", debugstr_a(lpDriverName
), debugstr_a(lpSectionName
), lParam2
);
1640 /**************************************************************************
1641 * CloseDriver (USER.253)
1643 LRESULT WINAPI
CloseDriver16(HDRVR16 hDrvr
, LPARAM lParam1
, LPARAM lParam2
)
1645 FIXME( "(%04x, %08lx, %08lx): stub\n", hDrvr
, lParam1
, lParam2
);
1650 /**************************************************************************
1651 * GetDriverModuleHandle (USER.254)
1653 HMODULE16 WINAPI
GetDriverModuleHandle16(HDRVR16 hDrvr
)
1655 FIXME("(%04x): stub\n", hDrvr
);
1660 /**************************************************************************
1661 * DefDriverProc (USER.255)
1663 LRESULT WINAPI
DefDriverProc16(DWORD dwDevID
, HDRVR16 hDriv
, UINT16 wMsg
,
1664 LPARAM lParam1
, LPARAM lParam2
)
1666 FIXME( "devID=0x%08x hDrv=0x%04x wMsg=%04x lP1=0x%08lx lP2=0x%08lx: stub\n",
1667 dwDevID
, hDriv
, wMsg
, lParam1
, lParam2
);
1672 /**************************************************************************
1673 * GetDriverInfo (USER.256)
1675 struct DRIVERINFOSTRUCT16
;
1676 BOOL16 WINAPI
GetDriverInfo16(HDRVR16 hDrvr
, struct DRIVERINFOSTRUCT16
*lpDrvInfo
)
1678 FIXME( "(%04x, %p): stub\n", hDrvr
, lpDrvInfo
);
1683 /**************************************************************************
1684 * GetNextDriver (USER.257)
1686 HDRVR16 WINAPI
GetNextDriver16(HDRVR16 hDrvr
, DWORD dwFlags
)
1688 FIXME( "(%04x, %08x): stub\n", hDrvr
, dwFlags
);
1693 /**********************************************************************
1694 * GetMenuItemCount (USER.263)
1696 INT16 WINAPI
GetMenuItemCount16( HMENU16 hMenu
)
1698 return GetMenuItemCount( HMENU_32(hMenu
) );
1702 /**********************************************************************
1703 * GetMenuItemID (USER.264)
1705 UINT16 WINAPI
GetMenuItemID16( HMENU16 hMenu
, INT16 nPos
)
1707 return GetMenuItemID( HMENU_32(hMenu
), nPos
);
1711 /***********************************************************************
1712 * GlobalAddAtom (USER.268)
1714 ATOM WINAPI
GlobalAddAtom16(LPCSTR lpString
)
1716 return GlobalAddAtomA(lpString
);
1719 /***********************************************************************
1720 * GlobalDeleteAtom (USER.269)
1722 ATOM WINAPI
GlobalDeleteAtom16(ATOM nAtom
)
1724 return GlobalDeleteAtom(nAtom
);
1727 /***********************************************************************
1728 * GlobalFindAtom (USER.270)
1730 ATOM WINAPI
GlobalFindAtom16(LPCSTR lpString
)
1732 return GlobalFindAtomA(lpString
);
1735 /***********************************************************************
1736 * GlobalGetAtomName (USER.271)
1738 UINT16 WINAPI
GlobalGetAtomName16(ATOM nAtom
, LPSTR lpBuffer
, INT16 nSize
)
1740 return GlobalGetAtomNameA(nAtom
, lpBuffer
, nSize
);
1744 /***********************************************************************
1745 * ControlPanelInfo (USER.273)
1747 void WINAPI
ControlPanelInfo16( INT16 nInfoType
, WORD wData
, LPSTR lpBuffer
)
1749 FIXME("(%d, %04x, %p): stub.\n", nInfoType
, wData
, lpBuffer
);
1753 /***********************************************************************
1754 * OldSetDeskPattern (USER.279)
1756 BOOL16 WINAPI
SetDeskPattern16(void)
1758 return SystemParametersInfoA( SPI_SETDESKPATTERN
, -1, NULL
, FALSE
);
1762 /***********************************************************************
1763 * GetSysColorBrush (USER.281)
1765 HBRUSH16 WINAPI
GetSysColorBrush16( INT16 index
)
1767 return HBRUSH_16( GetSysColorBrush(index
) );
1771 /***********************************************************************
1772 * SelectPalette (USER.282)
1774 HPALETTE16 WINAPI
SelectPalette16( HDC16 hdc
, HPALETTE16 hpal
, BOOL16 bForceBackground
)
1776 return HPALETTE_16( SelectPalette( HDC_32(hdc
), HPALETTE_32(hpal
), bForceBackground
));
1779 /***********************************************************************
1780 * RealizePalette (USER.283)
1782 UINT16 WINAPI
RealizePalette16( HDC16 hdc
)
1784 return UserRealizePalette( HDC_32(hdc
) );
1788 /***********************************************************************
1789 * GetFreeSystemResources (USER.284)
1791 WORD WINAPI
GetFreeSystemResources16( WORD resType
)
1793 STACK16FRAME
* stack16
= MapSL((SEGPTR
)NtCurrentTeb()->WOW32Reserved
);
1794 HANDLE16 oldDS
= stack16
->ds
;
1795 int userPercent
, gdiPercent
;
1799 case GFSR_USERRESOURCES
:
1800 stack16
->ds
= USER_HeapSel
;
1801 userPercent
= (int)LocalCountFree16() * 100 / LocalHeapSize16();
1803 stack16
->ds
= oldDS
;
1806 case GFSR_GDIRESOURCES
:
1807 stack16
->ds
= gdi_inst
;
1808 gdiPercent
= (int)LocalCountFree16() * 100 / LocalHeapSize16();
1810 stack16
->ds
= oldDS
;
1813 case GFSR_SYSTEMRESOURCES
:
1814 stack16
->ds
= USER_HeapSel
;
1815 userPercent
= (int)LocalCountFree16() * 100 / LocalHeapSize16();
1816 stack16
->ds
= gdi_inst
;
1817 gdiPercent
= (int)LocalCountFree16() * 100 / LocalHeapSize16();
1818 stack16
->ds
= oldDS
;
1822 userPercent
= gdiPercent
= 0;
1825 TRACE("<- userPercent %d, gdiPercent %d\n", userPercent
, gdiPercent
);
1826 return (WORD
)min( userPercent
, gdiPercent
);
1830 /***********************************************************************
1831 * SetDeskWallPaper (USER.285)
1833 BOOL16 WINAPI
SetDeskWallPaper16( LPCSTR filename
)
1835 return SetDeskWallPaper( filename
);
1839 /***********************************************************************
1840 * keybd_event (USER.289)
1842 void WINAPI
keybd_event16( CONTEXT
*context
)
1846 if (HIBYTE(context
->Eax
) & 0x80) dwFlags
|= KEYEVENTF_KEYUP
;
1847 if (HIBYTE(context
->Ebx
) & 0x01) dwFlags
|= KEYEVENTF_EXTENDEDKEY
;
1849 keybd_event( LOBYTE(context
->Eax
), LOBYTE(context
->Ebx
),
1850 dwFlags
, MAKELONG(LOWORD(context
->Esi
), LOWORD(context
->Edi
)) );
1854 /***********************************************************************
1855 * mouse_event (USER.299)
1857 void WINAPI
mouse_event16( CONTEXT
*context
)
1859 mouse_event( LOWORD(context
->Eax
), LOWORD(context
->Ebx
), LOWORD(context
->Ecx
),
1860 LOWORD(context
->Edx
), MAKELONG(context
->Esi
, context
->Edi
) );
1864 /***********************************************************************
1865 * GetClipCursor (USER.309)
1867 void WINAPI
GetClipCursor16( RECT16
*rect
)
1872 GetClipCursor( &rect32
);
1873 rect
->left
= rect32
.left
;
1874 rect
->top
= rect32
.top
;
1875 rect
->right
= rect32
.right
;
1876 rect
->bottom
= rect32
.bottom
;
1881 /***********************************************************************
1882 * SignalProc (USER.314)
1884 void WINAPI
SignalProc16( HANDLE16 hModule
, UINT16 code
,
1885 UINT16 uExitFn
, HINSTANCE16 hInstance
, HQUEUE16 hQueue
)
1887 if (code
== USIG16_DLL_UNLOAD
)
1889 hModule
= GetExePtr(hModule
);
1890 /* HOOK_FreeModuleHooks( hModule ); */
1891 free_module_classes( hModule
);
1892 free_module_icons( hModule
);
1897 /***********************************************************************
1898 * SetEventHook (USER.321)
1900 * Used by Turbo Debugger for Windows
1902 FARPROC16 WINAPI
SetEventHook16(FARPROC16 lpfnEventHook
)
1904 FIXME("(lpfnEventHook=%p): stub\n", lpfnEventHook
);
1909 /**********************************************************************
1910 * EnableHardwareInput (USER.331)
1912 BOOL16 WINAPI
EnableHardwareInput16(BOOL16 bEnable
)
1914 FIXME("(%d) - stub\n", bEnable
);
1919 /**********************************************************************
1920 * LoadCursorIconHandler (USER.336)
1922 * Supposed to load resources of Windows 2.x applications.
1924 HGLOBAL16 WINAPI
LoadCursorIconHandler16( HGLOBAL16 hResource
, HMODULE16 hModule
, HRSRC16 hRsrc
)
1926 FIXME("(%04x,%04x,%04x): old 2.x resources are not supported!\n", hResource
, hModule
, hRsrc
);
1931 /***********************************************************************
1932 * GetMouseEventProc (USER.337)
1934 FARPROC16 WINAPI
GetMouseEventProc16(void)
1936 HMODULE16 hmodule
= GetModuleHandle16("USER");
1937 return GetProcAddress16( hmodule
, "mouse_event" );
1941 /***********************************************************************
1942 * IsUserIdle (USER.333)
1944 BOOL16 WINAPI
IsUserIdle16(void)
1946 if ( GetAsyncKeyState( VK_LBUTTON
) & 0x8000 )
1948 if ( GetAsyncKeyState( VK_RBUTTON
) & 0x8000 )
1950 if ( GetAsyncKeyState( VK_MBUTTON
) & 0x8000 )
1952 /* Should check for screen saver activation here ... */
1957 /**********************************************************************
1958 * LoadDIBIconHandler (USER.357)
1960 * RT_ICON resource loader, installed by USER_SignalProc when module
1963 HGLOBAL16 WINAPI
LoadDIBIconHandler16( HGLOBAL16 hMemObj
, HMODULE16 hModule
, HRSRC16 hRsrc
)
1965 /* If hResource is zero we must allocate a new memory block, if it's
1966 * non-zero but GlobalLock() returns NULL then it was discarded and
1967 * we have to recommit some memory, otherwise we just need to check
1968 * the block size. See LoadProc() in 16-bit SDK for more.
1970 FIXME( "%x %x %x: stub, not supported anymore\n", hMemObj
, hModule
, hRsrc
);
1974 /**********************************************************************
1975 * LoadDIBCursorHandler (USER.356)
1977 * RT_CURSOR resource loader. Same as above.
1979 HGLOBAL16 WINAPI
LoadDIBCursorHandler16( HGLOBAL16 hMemObj
, HMODULE16 hModule
, HRSRC16 hRsrc
)
1981 FIXME( "%x %x %x: stub, not supported anymore\n", hMemObj
, hModule
, hRsrc
);
1986 /**********************************************************************
1989 BOOL16 WINAPI
IsMenu16( HMENU16 hmenu
)
1991 return IsMenu( HMENU_32(hmenu
) );
1995 /***********************************************************************
1998 BOOL16 WINAPI
DCHook16( HDC16 hdc
, WORD code
, DWORD data
, LPARAM lParam
)
2000 FIXME( "hDC = %x, %i: stub\n", hdc
, code
);
2005 /**********************************************************************
2006 * LookupIconIdFromDirectoryEx (USER.364)
2008 * FIXME: exact parameter sizes
2010 INT16 WINAPI
LookupIconIdFromDirectoryEx16( LPBYTE dir
, BOOL16 bIcon
,
2011 INT16 width
, INT16 height
, UINT16 cFlag
)
2013 return LookupIconIdFromDirectoryEx( dir
, bIcon
, width
, height
, cFlag
);
2017 /***********************************************************************
2018 * CopyIcon (USER.368)
2020 HICON16 WINAPI
CopyIcon16( HINSTANCE16 hInstance
, HICON16 hIcon
)
2022 CURSORICONINFO
*info
= get_icon_ptr( hIcon
);
2023 void *and_bits
= info
+ 1;
2024 void *xor_bits
= (BYTE
*)and_bits
+ info
->nHeight
* get_bitmap_width_bytes( info
->nWidth
, 1 );
2025 HGLOBAL16 ret
= CreateCursorIconIndirect16( hInstance
, info
, and_bits
, xor_bits
);
2026 release_icon_ptr( hIcon
, info
);
2031 /***********************************************************************
2032 * CopyCursor (USER.369)
2034 HCURSOR16 WINAPI
CopyCursor16( HINSTANCE16 hInstance
, HCURSOR16 hCursor
)
2036 CURSORICONINFO
*info
= get_icon_ptr( hCursor
);
2037 void *and_bits
= info
+ 1;
2038 void *xor_bits
= (BYTE
*)and_bits
+ info
->nHeight
* get_bitmap_width_bytes( info
->nWidth
, 1 );
2039 HGLOBAL16 ret
= CreateCursorIconIndirect16( hInstance
, info
, and_bits
, xor_bits
);
2040 release_icon_ptr( hCursor
, info
);
2045 /***********************************************************************
2046 * SubtractRect (USER.373)
2048 BOOL16 WINAPI
SubtractRect16( LPRECT16 dest
, const RECT16
*src1
,
2049 const RECT16
*src2
)
2053 if (IsRectEmpty16( src1
))
2055 SetRectEmpty16( dest
);
2059 if (IntersectRect16( &tmp
, src1
, src2
))
2061 if (EqualRect16( &tmp
, dest
))
2063 SetRectEmpty16( dest
);
2066 if ((tmp
.top
== dest
->top
) && (tmp
.bottom
== dest
->bottom
))
2068 if (tmp
.left
== dest
->left
) dest
->left
= tmp
.right
;
2069 else if (tmp
.right
== dest
->right
) dest
->right
= tmp
.left
;
2071 else if ((tmp
.left
== dest
->left
) && (tmp
.right
== dest
->right
))
2073 if (tmp
.top
== dest
->top
) dest
->top
= tmp
.bottom
;
2074 else if (tmp
.bottom
== dest
->bottom
) dest
->bottom
= tmp
.top
;
2081 /**********************************************************************
2082 * DllEntryPoint (USER.374)
2084 BOOL WINAPI
DllEntryPoint( DWORD reason
, HINSTANCE16 inst
, WORD ds
,
2085 WORD heap
, DWORD reserved1
, WORD reserved2
)
2087 if (reason
!= DLL_PROCESS_ATTACH
) return TRUE
;
2088 if (USER_HeapSel
) return TRUE
; /* already called */
2091 register_wow_handlers();
2092 gdi_inst
= LoadLibrary16( "gdi.exe" );
2093 LoadLibrary16( "display.drv" );
2094 LoadLibrary16( "keyboard.drv" );
2095 LoadLibrary16( "mouse.drv" );
2096 LoadLibrary16( "user.exe" ); /* make sure it never gets unloaded */
2101 /**********************************************************************
2102 * SetMenuContextHelpId (USER.384)
2104 BOOL16 WINAPI
SetMenuContextHelpId16( HMENU16 hMenu
, DWORD dwContextHelpID
)
2106 return SetMenuContextHelpId( HMENU_32(hMenu
), dwContextHelpID
);
2110 /**********************************************************************
2111 * GetMenuContextHelpId (USER.385)
2113 DWORD WINAPI
GetMenuContextHelpId16( HMENU16 hMenu
)
2115 return GetMenuContextHelpId( HMENU_32(hMenu
) );
2119 /***********************************************************************
2120 * LoadImage (USER.389)
2122 HANDLE16 WINAPI
LoadImage16(HINSTANCE16 hinst
, LPCSTR name
, UINT16 type
, INT16 cx
, INT16 cy
, UINT16 flags
)
2125 HRSRC16 hRsrc
, hGroupRsrc
;
2128 if (!hinst
|| (flags
& LR_LOADFROMFILE
))
2130 if (type
== IMAGE_BITMAP
)
2131 return HBITMAP_16( LoadImageA( 0, name
, type
, cx
, cy
, flags
));
2133 return get_icon_16( LoadImageA( 0, name
, type
, cx
, cy
, flags
));
2136 hinst
= GetExePtr( hinst
);
2138 if (flags
& LR_DEFAULTSIZE
)
2140 if (type
== IMAGE_ICON
)
2142 if (!cx
) cx
= GetSystemMetrics(SM_CXICON
);
2143 if (!cy
) cy
= GetSystemMetrics(SM_CYICON
);
2145 else if (type
== IMAGE_CURSOR
)
2147 if (!cx
) cx
= GetSystemMetrics(SM_CXCURSOR
);
2148 if (!cy
) cy
= GetSystemMetrics(SM_CYCURSOR
);
2158 static const WCHAR prefixW
[] = {'b','m','p',0};
2159 BITMAPFILEHEADER header
;
2160 WCHAR path
[MAX_PATH
], filename
[MAX_PATH
];
2164 if (!(hRsrc
= FindResource16( hinst
, name
, (LPCSTR
)RT_BITMAP
))) return 0;
2165 if (!(handle
= LoadResource16( hinst
, hRsrc
))) return 0;
2166 if (!(ptr
= LockResource16( handle
))) goto done
;
2167 size
= SizeofResource16( hinst
, hRsrc
);
2169 header
.bfType
= 0x4d42; /* 'BM' */
2170 header
.bfReserved1
= 0;
2171 header
.bfReserved2
= 0;
2172 header
.bfSize
= sizeof(header
) + size
;
2173 header
.bfOffBits
= 0; /* not used by the 32-bit loading code */
2175 if (!GetTempPathW( MAX_PATH
, path
)) goto done
;
2176 if (!GetTempFileNameW( path
, prefixW
, 0, filename
)) goto done
;
2178 file
= CreateFileW( filename
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, 0 );
2179 if (file
!= INVALID_HANDLE_VALUE
)
2183 ok
= WriteFile( file
, &header
, sizeof(header
), &written
, NULL
) && (written
== sizeof(header
));
2184 if (ok
) ok
= WriteFile( file
, ptr
, size
, &written
, NULL
) && (written
== size
);
2185 CloseHandle( file
);
2186 if (ok
) ret
= LoadImageW( 0, filename
, IMAGE_BITMAP
, cx
, cy
, flags
| LR_LOADFROMFILE
);
2189 if (filename
[0]) DeleteFileW( filename
);
2190 FreeResource16( handle
);
2191 return HBITMAP_16( ret
);
2201 if (!(hRsrc
= FindResource16( hinst
, name
,
2202 (LPCSTR
)(type
== IMAGE_ICON
? RT_GROUP_ICON
: RT_GROUP_CURSOR
))))
2206 if (!(handle
= LoadResource16( hinst
, hRsrc
))) return 0;
2207 if ((dir
= LockResource16( handle
))) id
= LookupIconIdFromDirectory( dir
, type
== IMAGE_ICON
);
2208 FreeResource16( handle
);
2211 if (!(hRsrc
= FindResource16( hinst
, MAKEINTRESOURCEA(id
),
2212 (LPCSTR
)(type
== IMAGE_ICON
? RT_ICON
: RT_CURSOR
) ))) return 0;
2214 if ((flags
& LR_SHARED
) && (hIcon
= find_shared_icon( hinst
, hRsrc
) ) != 0) return hIcon
;
2216 if (!(handle
= LoadResource16( hinst
, hRsrc
))) return 0;
2217 bits
= LockResource16( handle
);
2218 size
= SizeofResource16( hinst
, hRsrc
);
2219 hIcon
= CreateIconFromResourceEx16( bits
, size
, type
== IMAGE_ICON
, 0x00030000, cx
, cy
, flags
);
2220 FreeResource16( handle
);
2222 if (hIcon
&& (flags
& LR_SHARED
)) add_shared_icon( hinst
, hRsrc
, hGroupRsrc
, hIcon
);
2230 /******************************************************************************
2231 * CopyImage (USER.390) Creates new image and copies attributes to it
2234 HICON16 WINAPI
CopyImage16(HANDLE16 hnd
, UINT16 type
, INT16 desiredx
,
2235 INT16 desiredy
, UINT16 flags
)
2237 if (flags
& LR_COPYFROMRESOURCE
) FIXME( "LR_COPYFROMRESOURCE not supported\n" );
2242 return HBITMAP_16( CopyImage( HBITMAP_32(hnd
), type
, desiredx
, desiredy
, flags
));
2245 return CopyIcon16( FarGetOwner16(hnd
), hnd
);
2251 /**********************************************************************
2252 * DrawIconEx (USER.394)
2254 BOOL16 WINAPI
DrawIconEx16(HDC16 hdc
, INT16 xLeft
, INT16 yTop
, HICON16 hIcon
,
2255 INT16 cxWidth
, INT16 cyWidth
, UINT16 istep
,
2256 HBRUSH16 hbr
, UINT16 flags
)
2258 return DrawIconEx(HDC_32(hdc
), xLeft
, yTop
, get_icon_32(hIcon
), cxWidth
, cyWidth
,
2259 istep
, HBRUSH_32(hbr
), flags
);
2262 /**********************************************************************
2263 * GetIconInfo (USER.395)
2265 BOOL16 WINAPI
GetIconInfo16(HICON16 hIcon
, LPICONINFO16 iconinfo
)
2267 CURSORICONINFO
*info
= get_icon_ptr( hIcon
);
2270 if (!info
) return FALSE
;
2272 if ((info
->ptHotSpot
.x
== ICON_HOTSPOT
) && (info
->ptHotSpot
.y
== ICON_HOTSPOT
))
2274 iconinfo
->fIcon
= TRUE
;
2275 iconinfo
->xHotspot
= info
->nWidth
/ 2;
2276 iconinfo
->yHotspot
= info
->nHeight
/ 2;
2280 iconinfo
->fIcon
= FALSE
;
2281 iconinfo
->xHotspot
= info
->ptHotSpot
.x
;
2282 iconinfo
->yHotspot
= info
->ptHotSpot
.y
;
2285 height
= info
->nHeight
;
2287 if (info
->bBitsPerPixel
> 1)
2289 iconinfo
->hbmColor
= HBITMAP_16( CreateBitmap( info
->nWidth
, info
->nHeight
,
2290 info
->bPlanes
, info
->bBitsPerPixel
,
2293 get_bitmap_width_bytes(info
->nWidth
,1) ));
2297 iconinfo
->hbmColor
= 0;
2301 iconinfo
->hbmMask
= HBITMAP_16( CreateBitmap( info
->nWidth
, height
, 1, 1, info
+ 1 ));
2302 release_icon_ptr( hIcon
, info
);
2307 /***********************************************************************
2308 * FinalUserInit (USER.400)
2310 void WINAPI
FinalUserInit16( void )
2312 /* FIXME: Should chain to FinalGdiInit */
2316 /***********************************************************************
2317 * CreateCursor (USER.406)
2319 HCURSOR16 WINAPI
CreateCursor16(HINSTANCE16 hInstance
,
2320 INT16 xHotSpot
, INT16 yHotSpot
,
2321 INT16 nWidth
, INT16 nHeight
,
2322 LPCVOID lpANDbits
, LPCVOID lpXORbits
)
2324 CURSORICONINFO info
;
2326 info
.ptHotSpot
.x
= xHotSpot
;
2327 info
.ptHotSpot
.y
= yHotSpot
;
2328 info
.nWidth
= nWidth
;
2329 info
.nHeight
= nHeight
;
2330 info
.nWidthBytes
= 0;
2332 info
.bBitsPerPixel
= 1;
2334 return CreateCursorIconIndirect16(hInstance
, &info
, lpANDbits
, lpXORbits
);
2338 /***********************************************************************
2339 * CreateIcon (USER.407)
2341 HICON16 WINAPI
CreateIcon16( HINSTANCE16 hInstance
, INT16 nWidth
,
2342 INT16 nHeight
, BYTE bPlanes
, BYTE bBitsPixel
,
2343 LPCVOID lpANDbits
, LPCVOID lpXORbits
)
2345 CURSORICONINFO info
;
2347 info
.ptHotSpot
.x
= ICON_HOTSPOT
;
2348 info
.ptHotSpot
.y
= ICON_HOTSPOT
;
2349 info
.nWidth
= nWidth
;
2350 info
.nHeight
= nHeight
;
2351 info
.nWidthBytes
= 0;
2352 info
.bPlanes
= bPlanes
;
2353 info
.bBitsPerPixel
= bBitsPixel
;
2355 return CreateCursorIconIndirect16( hInstance
, &info
, lpANDbits
, lpXORbits
);
2359 /***********************************************************************
2360 * CreateCursorIconIndirect (USER.408)
2362 HGLOBAL16 WINAPI
CreateCursorIconIndirect16( HINSTANCE16 hInstance
,
2363 CURSORICONINFO
*info
,
2368 CURSORICONINFO
*ptr
;
2369 int sizeAnd
, sizeXor
;
2371 hInstance
= GetExePtr( hInstance
); /* Make it a module handle */
2372 if (!lpXORbits
|| !lpANDbits
|| info
->bPlanes
!= 1) return 0;
2373 info
->nWidthBytes
= get_bitmap_width_bytes(info
->nWidth
,info
->bBitsPerPixel
);
2374 sizeXor
= info
->nHeight
* info
->nWidthBytes
;
2375 sizeAnd
= info
->nHeight
* get_bitmap_width_bytes( info
->nWidth
, 1 );
2376 if (!(handle
= alloc_icon_handle( sizeof(CURSORICONINFO
) + sizeXor
+ sizeAnd
)))
2378 FarSetOwner16( handle
, hInstance
);
2379 ptr
= get_icon_ptr( handle
);
2380 memcpy( ptr
, info
, sizeof(*info
) );
2381 memcpy( ptr
+ 1, lpANDbits
, sizeAnd
);
2382 memcpy( (char *)(ptr
+ 1) + sizeAnd
, lpXORbits
, sizeXor
);
2383 release_icon_ptr( handle
, ptr
);
2388 /***********************************************************************
2389 * InitThreadInput (USER.409)
2391 HQUEUE16 WINAPI
InitThreadInput16( WORD unknown
, WORD flags
)
2393 /* nothing to do here */
2398 /*******************************************************************
2399 * InsertMenu (USER.410)
2401 BOOL16 WINAPI
InsertMenu16( HMENU16 hMenu
, UINT16 pos
, UINT16 flags
,
2402 UINT16 id
, SEGPTR data
)
2404 UINT pos32
= (UINT
)pos
;
2405 if ((pos
== (UINT16
)-1) && (flags
& MF_BYPOSITION
)) pos32
= (UINT
)-1;
2406 if (IS_MENU_STRING_ITEM(flags
) && data
)
2407 return InsertMenuA( HMENU_32(hMenu
), pos32
, flags
, id
, MapSL(data
) );
2409 /* If "data" is an HBITMAP, the high WORD will contain the application's DGROUP selector if the
2410 * application cast (LPSTR)hBitmap rather than (LPSTR)(LONG)hBitmap. */
2411 if (flags
& MF_BITMAP
) data
= (SEGPTR
)HBITMAP_32(LOWORD(data
));
2412 return InsertMenuA( HMENU_32(hMenu
), pos32
, flags
, id
, (LPSTR
)data
);
2416 /*******************************************************************
2417 * AppendMenu (USER.411)
2419 BOOL16 WINAPI
AppendMenu16(HMENU16 hMenu
, UINT16 flags
, UINT16 id
, SEGPTR data
)
2421 return InsertMenu16( hMenu
, -1, flags
| MF_BYPOSITION
, id
, data
);
2425 /**********************************************************************
2426 * RemoveMenu (USER.412)
2428 BOOL16 WINAPI
RemoveMenu16( HMENU16 hMenu
, UINT16 nPos
, UINT16 wFlags
)
2430 return RemoveMenu( HMENU_32(hMenu
), nPos
, wFlags
);
2434 /**********************************************************************
2435 * DeleteMenu (USER.413)
2437 BOOL16 WINAPI
DeleteMenu16( HMENU16 hMenu
, UINT16 nPos
, UINT16 wFlags
)
2439 return DeleteMenu( HMENU_32(hMenu
), nPos
, wFlags
);
2443 /*******************************************************************
2444 * ModifyMenu (USER.414)
2446 BOOL16 WINAPI
ModifyMenu16( HMENU16 hMenu
, UINT16 pos
, UINT16 flags
,
2447 UINT16 id
, SEGPTR data
)
2449 if (IS_MENU_STRING_ITEM(flags
))
2450 return ModifyMenuA( HMENU_32(hMenu
), pos
, flags
, id
, MapSL(data
) );
2451 return ModifyMenuA( HMENU_32(hMenu
), pos
, flags
, id
, (LPSTR
)data
);
2455 /**********************************************************************
2456 * CreatePopupMenu (USER.415)
2458 HMENU16 WINAPI
CreatePopupMenu16(void)
2460 return HMENU_16( CreatePopupMenu() );
2464 /**********************************************************************
2465 * SetMenuItemBitmaps (USER.418)
2467 BOOL16 WINAPI
SetMenuItemBitmaps16( HMENU16 hMenu
, UINT16 nPos
, UINT16 wFlags
,
2468 HBITMAP16 hNewUnCheck
, HBITMAP16 hNewCheck
)
2470 return SetMenuItemBitmaps( HMENU_32(hMenu
), nPos
, wFlags
,
2471 HBITMAP_32(hNewUnCheck
), HBITMAP_32(hNewCheck
) );
2475 /***********************************************************************
2476 * wvsprintf (USER.421)
2478 INT16 WINAPI
wvsprintf16( LPSTR buffer
, LPCSTR spec
, VA_LIST16 args
)
2480 WPRINTF_FORMAT format
;
2485 LPCSTR lpcstr_view
= NULL
;
2491 if (*spec
!= '%') { *p
++ = *spec
++; continue; }
2493 if (*spec
== '%') { *p
++ = *spec
++; continue; }
2494 spec
+= parse_format( spec
, &format
);
2498 char_view
= VA_ARG16( args
, CHAR
);
2499 len
= format
.precision
= 1;
2502 seg_str
= VA_ARG16( args
, SEGPTR
);
2503 if (IsBadReadPtr16( seg_str
, 1 )) lpcstr_view
= "";
2504 else lpcstr_view
= MapSL( seg_str
);
2505 if (!lpcstr_view
) lpcstr_view
= "(null)";
2506 for (len
= 0; !format
.precision
|| (len
< format
.precision
); len
++)
2507 if (!lpcstr_view
[len
]) break;
2508 format
.precision
= len
;
2511 if (format
.flags
& WPRINTF_LONG
) int_view
= VA_ARG16( args
, INT
);
2512 else int_view
= VA_ARG16( args
, INT16
);
2513 len
= sprintf( number
, "%d", int_view
);
2516 if (format
.flags
& WPRINTF_LONG
) int_view
= VA_ARG16( args
, UINT
);
2517 else int_view
= VA_ARG16( args
, UINT16
);
2518 len
= sprintf( number
, "%u", int_view
);
2521 if (format
.flags
& WPRINTF_LONG
) int_view
= VA_ARG16( args
, UINT
);
2522 else int_view
= VA_ARG16( args
, UINT16
);
2523 len
= sprintf( number
, (format
.flags
& WPRINTF_UPPER_HEX
) ? "%X" : "%x", int_view
);
2528 if (format
.precision
< len
) format
.precision
= len
;
2529 if (format
.flags
& WPRINTF_LEFTALIGN
) format
.flags
&= ~WPRINTF_ZEROPAD
;
2530 if ((format
.flags
& WPRINTF_ZEROPAD
) && (format
.width
> format
.precision
))
2531 format
.precision
= format
.width
;
2532 if (format
.flags
& WPRINTF_PREFIX_HEX
) len
+= 2;
2535 if (!(format
.flags
& WPRINTF_LEFTALIGN
))
2536 for (i
= format
.precision
; i
< format
.width
; i
++) *p
++ = ' ';
2541 /* wsprintf16 ignores null characters */
2542 if (*p
!= '\0') p
++;
2543 else if (format
.width
> 1) *p
++ = ' ';
2546 if (len
) memcpy( p
, lpcstr_view
, len
);
2550 if (format
.flags
& WPRINTF_PREFIX_HEX
)
2553 *p
++ = (format
.flags
& WPRINTF_UPPER_HEX
) ? 'X' : 'x';
2558 /* Transfer the sign now, just in case it will be zero-padded*/
2559 if (number
[0] == '-')
2566 for (i
= len
; i
< format
.precision
; i
++) *p
++ = '0';
2567 if (len
> sign
) memcpy( p
, number
+ sign
, len
- sign
);
2573 if (format
.flags
& WPRINTF_LEFTALIGN
)
2574 for (i
= format
.precision
; i
< format
.width
; i
++) *p
++ = ' ';
2581 /***********************************************************************
2582 * _wsprintf (USER.420)
2584 INT16 WINAPIV
wsprintf16( LPSTR buffer
, LPCSTR spec
, VA_LIST16 valist
)
2586 return wvsprintf16( buffer
, spec
, valist
);
2590 /***********************************************************************
2591 * lstrcmp (USER.430)
2593 INT16 WINAPI
lstrcmp16( LPCSTR str1
, LPCSTR str2
)
2596 /* Looks too complicated, but in optimized strcpy we might get
2597 * a 32bit wide difference and would truncate it to 16 bit, so
2598 * erroneously returning equality. */
2599 ret
= strcmp( str1
, str2
);
2600 if (ret
< 0) return -1;
2601 if (ret
> 0) return 1;
2606 /***********************************************************************
2607 * AnsiUpper (USER.431)
2609 SEGPTR WINAPI
AnsiUpper16( SEGPTR strOrChar
)
2611 /* uppercase only one char if strOrChar < 0x10000 */
2612 if (HIWORD(strOrChar
))
2614 CharUpperA( MapSL(strOrChar
) );
2617 else return (SEGPTR
)CharUpperA( (LPSTR
)strOrChar
);
2621 /***********************************************************************
2622 * AnsiLower (USER.432)
2624 SEGPTR WINAPI
AnsiLower16( SEGPTR strOrChar
)
2626 /* lowercase only one char if strOrChar < 0x10000 */
2627 if (HIWORD(strOrChar
))
2629 CharLowerA( MapSL(strOrChar
) );
2632 else return (SEGPTR
)CharLowerA( (LPSTR
)strOrChar
);
2636 /***********************************************************************
2637 * AnsiUpperBuff (USER.437)
2639 UINT16 WINAPI
AnsiUpperBuff16( LPSTR str
, UINT16 len
)
2641 CharUpperBuffA( str
, len
? len
: 65536 );
2646 /***********************************************************************
2647 * AnsiLowerBuff (USER.438)
2649 UINT16 WINAPI
AnsiLowerBuff16( LPSTR str
, UINT16 len
)
2651 CharLowerBuffA( str
, len
? len
: 65536 );
2656 /*******************************************************************
2657 * InsertMenuItem (USER.441)
2661 BOOL16 WINAPI
InsertMenuItem16( HMENU16 hmenu
, UINT16 pos
, BOOL16 byposition
,
2662 const MENUITEMINFO16
*mii
)
2666 miia
.cbSize
= sizeof(miia
);
2667 miia
.fMask
= mii
->fMask
;
2668 miia
.dwTypeData
= (LPSTR
)mii
->dwTypeData
;
2669 miia
.fType
= mii
->fType
;
2670 miia
.fState
= mii
->fState
;
2671 miia
.wID
= mii
->wID
;
2672 miia
.hSubMenu
= HMENU_32(mii
->hSubMenu
);
2673 miia
.hbmpChecked
= HBITMAP_32(mii
->hbmpChecked
);
2674 miia
.hbmpUnchecked
= HBITMAP_32(mii
->hbmpUnchecked
);
2675 miia
.dwItemData
= mii
->dwItemData
;
2676 miia
.cch
= mii
->cch
;
2677 if (IS_MENU_STRING_ITEM(miia
.fType
))
2678 miia
.dwTypeData
= MapSL(mii
->dwTypeData
);
2679 return InsertMenuItemA( HMENU_32(hmenu
), pos
, byposition
, &miia
);
2683 /**********************************************************************
2684 * DrawState (USER.449)
2686 BOOL16 WINAPI
DrawState16( HDC16 hdc
, HBRUSH16 hbr
, DRAWSTATEPROC16 func
, LPARAM ldata
,
2687 WPARAM16 wdata
, INT16 x
, INT16 y
, INT16 cx
, INT16 cy
, UINT16 flags
)
2689 struct draw_state_info info
;
2690 UINT opcode
= flags
& 0xf;
2692 if (opcode
== DST_TEXT
|| opcode
== DST_PREFIXTEXT
)
2694 /* make sure DrawStateA doesn't try to use ldata as a pointer */
2695 if (!wdata
) wdata
= strlen( MapSL(ldata
) );
2699 if (!GetTextExtentPoint32A( HDC_32(hdc
), MapSL(ldata
), wdata
, &s
)) return FALSE
;
2706 return DrawStateA( HDC_32(hdc
), HBRUSH_32(hbr
), draw_state_callback
,
2707 (LPARAM
)&info
, wdata
, x
, y
, cx
, cy
, flags
);
2711 /**********************************************************************
2712 * CreateIconFromResourceEx (USER.450)
2714 * FIXME: not sure about exact parameter types
2716 HICON16 WINAPI
CreateIconFromResourceEx16(LPBYTE bits
, UINT16 cbSize
,
2717 BOOL16 bIcon
, DWORD dwVersion
,
2718 INT16 width
, INT16 height
,
2721 return get_icon_16( CreateIconFromResourceEx( bits
, cbSize
, bIcon
, dwVersion
, width
, height
, cFlag
));
2725 /***********************************************************************
2726 * AdjustWindowRectEx (USER.454)
2728 BOOL16 WINAPI
AdjustWindowRectEx16( LPRECT16 rect
, DWORD style
, BOOL16 menu
, DWORD exStyle
)
2733 rect32
.left
= rect
->left
;
2734 rect32
.top
= rect
->top
;
2735 rect32
.right
= rect
->right
;
2736 rect32
.bottom
= rect
->bottom
;
2737 ret
= AdjustWindowRectEx( &rect32
, style
, menu
, exStyle
);
2738 rect
->left
= rect32
.left
;
2739 rect
->top
= rect32
.top
;
2740 rect
->right
= rect32
.right
;
2741 rect
->bottom
= rect32
.bottom
;
2746 /**********************************************************************
2747 * GetIconID (USER.455)
2749 WORD WINAPI
GetIconID16( HGLOBAL16 hResource
, DWORD resType
)
2751 BYTE
*dir
= GlobalLock16(hResource
);
2756 return LookupIconIdFromDirectoryEx16( dir
, FALSE
, GetSystemMetrics(SM_CXCURSOR
),
2757 GetSystemMetrics(SM_CYCURSOR
), LR_MONOCHROME
);
2759 return LookupIconIdFromDirectoryEx16( dir
, TRUE
, GetSystemMetrics(SM_CXICON
),
2760 GetSystemMetrics(SM_CYICON
), 0 );
2766 /**********************************************************************
2767 * LoadIconHandler (USER.456)
2769 HICON16 WINAPI
LoadIconHandler16( HGLOBAL16 hResource
, BOOL16 bNew
)
2771 return CreateIconFromResourceEx16( LockResource16( hResource
), 0xffff, TRUE
,
2772 bNew
? 0x00030000 : 0x00020000, 0, 0, LR_DEFAULTCOLOR
);
2776 /***********************************************************************
2777 * DestroyIcon (USER.457)
2779 BOOL16 WINAPI
DestroyIcon16(HICON16 hIcon
)
2783 TRACE("%04x\n", hIcon
);
2785 count
= release_shared_icon( hIcon
);
2786 if (count
!= -1) return !count
;
2787 /* assume non-shared */
2788 free_icon_handle( hIcon
);
2792 /***********************************************************************
2793 * DestroyCursor (USER.458)
2795 BOOL16 WINAPI
DestroyCursor16(HCURSOR16 hCursor
)
2797 return DestroyIcon16( hCursor
);
2801 /***********************************************************************
2802 * DumpIcon (USER.459)
2804 DWORD WINAPI
DumpIcon16( SEGPTR pInfo
, WORD
*lpLen
,
2805 SEGPTR
*lpXorBits
, SEGPTR
*lpAndBits
)
2807 CURSORICONINFO
*info
= MapSL( pInfo
);
2808 int sizeAnd
, sizeXor
;
2810 if (!info
) return 0;
2811 sizeXor
= info
->nHeight
* info
->nWidthBytes
;
2812 sizeAnd
= info
->nHeight
* get_bitmap_width_bytes( info
->nWidth
, 1 );
2813 if (lpAndBits
) *lpAndBits
= pInfo
+ sizeof(CURSORICONINFO
);
2814 if (lpXorBits
) *lpXorBits
= pInfo
+ sizeof(CURSORICONINFO
) + sizeAnd
;
2815 if (lpLen
) *lpLen
= sizeof(CURSORICONINFO
) + sizeAnd
+ sizeXor
;
2816 return MAKELONG( sizeXor
, sizeXor
);
2820 /*******************************************************************
2821 * DRAG_QueryUpdate16
2823 * Recursively find a child that contains spDragInfo->pt point
2824 * and send WM_QUERYDROPOBJECT. Helper for DragObject16.
2826 static BOOL
DRAG_QueryUpdate16( HWND hQueryWnd
, SEGPTR spDragInfo
)
2831 LPDRAGINFO16 ptrDragInfo
= MapSL(spDragInfo
);
2835 if (!IsWindowEnabled(hQueryWnd
)) return FALSE
;
2837 old_pt
.x
= ptrDragInfo
->pt
.x
;
2838 old_pt
.y
= ptrDragInfo
->pt
.y
;
2840 ScreenToClient( hQueryWnd
, &pt
);
2841 child
= ChildWindowFromPointEx( hQueryWnd
, pt
, CWP_SKIPINVISIBLE
);
2842 if (!child
) return FALSE
;
2844 if (child
!= hQueryWnd
)
2847 if (DRAG_QueryUpdate16( child
, spDragInfo
)) return TRUE
;
2851 GetClientRect( hQueryWnd
, &tempRect
);
2852 wParam
= !PtInRect( &tempRect
, pt
);
2855 ptrDragInfo
->pt
.x
= pt
.x
;
2856 ptrDragInfo
->pt
.y
= pt
.y
;
2857 ptrDragInfo
->hScope
= HWND_16(hQueryWnd
);
2859 bResult
= SendMessage16( HWND_16(hQueryWnd
), WM_QUERYDROPOBJECT
, wParam
, spDragInfo
);
2863 ptrDragInfo
->pt
.x
= old_pt
.x
;
2864 ptrDragInfo
->pt
.y
= old_pt
.y
;
2870 /******************************************************************************
2871 * DragObject (USER.464)
2873 DWORD WINAPI
DragObject16( HWND16 hwndScope
, HWND16 hWnd
, UINT16 wObj
,
2874 HANDLE16 hOfStruct
, WORD szList
, HCURSOR16 hCursor
)
2877 LPDRAGINFO16 lpDragInfo
;
2879 HCURSOR hOldCursor
=0, hBummer
=0, hCursor32
;
2880 HGLOBAL16 hDragInfo
= GlobalAlloc16( GMEM_SHARE
| GMEM_ZEROINIT
, 2*sizeof(DRAGINFO16
));
2881 HCURSOR hCurrentCursor
= 0;
2882 HWND16 hCurrentWnd
= 0;
2884 lpDragInfo
= (LPDRAGINFO16
) GlobalLock16(hDragInfo
);
2885 spDragInfo
= WOWGlobalLock16(hDragInfo
);
2887 if( !lpDragInfo
|| !spDragInfo
) return 0L;
2889 if (!(hBummer
= LoadCursorA(0, MAKEINTRESOURCEA(OCR_NO
))))
2891 GlobalFree16(hDragInfo
);
2895 if ((hCursor32
= get_icon_32( hCursor
))) SetCursor( hCursor32
);
2897 lpDragInfo
->hWnd
= hWnd
;
2898 lpDragInfo
->hScope
= 0;
2899 lpDragInfo
->wFlags
= wObj
;
2900 lpDragInfo
->hList
= szList
; /* near pointer! */
2901 lpDragInfo
->hOfStruct
= hOfStruct
;
2904 SetCapture( HWND_32(hWnd
) );
2909 GetMessageW( &msg
, 0, WM_MOUSEFIRST
, WM_MOUSELAST
);
2911 *(lpDragInfo
+1) = *lpDragInfo
;
2913 lpDragInfo
->pt
.x
= msg
.pt
.x
;
2914 lpDragInfo
->pt
.y
= msg
.pt
.y
;
2916 /* update DRAGINFO struct */
2917 if( DRAG_QueryUpdate16(WIN_Handle32(hwndScope
), spDragInfo
) > 0 )
2918 hCurrentCursor
= hCursor32
;
2921 hCurrentCursor
= hBummer
;
2922 lpDragInfo
->hScope
= 0;
2924 if( hCurrentCursor
)
2925 SetCursor(hCurrentCursor
);
2927 /* send WM_DRAGLOOP */
2928 SendMessage16( hWnd
, WM_DRAGLOOP
, hCurrentCursor
!= hBummer
, spDragInfo
);
2929 /* send WM_DRAGSELECT or WM_DRAGMOVE */
2930 if( hCurrentWnd
!= lpDragInfo
->hScope
)
2933 SendMessage16( hCurrentWnd
, WM_DRAGSELECT
, 0,
2934 MAKELPARAM(LOWORD(spDragInfo
)+sizeof(DRAGINFO16
),
2935 HIWORD(spDragInfo
)) );
2936 hCurrentWnd
= lpDragInfo
->hScope
;
2938 SendMessage16( hCurrentWnd
, WM_DRAGSELECT
, 1, spDragInfo
);
2942 SendMessage16( hCurrentWnd
, WM_DRAGMOVE
, 0, spDragInfo
);
2944 } while( msg
.message
!= WM_LBUTTONUP
&& msg
.message
!= WM_NCLBUTTONUP
);
2947 ShowCursor( FALSE
);
2949 if( hCursor
) SetCursor(hOldCursor
);
2951 if( hCurrentCursor
!= hBummer
)
2952 msg
.lParam
= SendMessage16( lpDragInfo
->hScope
, WM_DROPOBJECT
,
2956 GlobalFree16(hDragInfo
);
2958 return (DWORD
)(msg
.lParam
);
2962 /***********************************************************************
2963 * DrawFocusRect (USER.466)
2965 void WINAPI
DrawFocusRect16( HDC16 hdc
, const RECT16
* rc
)
2969 rect32
.left
= rc
->left
;
2970 rect32
.top
= rc
->top
;
2971 rect32
.right
= rc
->right
;
2972 rect32
.bottom
= rc
->bottom
;
2973 DrawFocusRect( HDC_32(hdc
), &rect32
);
2977 /***********************************************************************
2978 * AnsiNext (USER.472)
2980 SEGPTR WINAPI
AnsiNext16(SEGPTR current
)
2982 char *ptr
= MapSL(current
);
2983 return current
+ (CharNextA(ptr
) - ptr
);
2987 /***********************************************************************
2988 * AnsiPrev (USER.473)
2990 SEGPTR WINAPI
AnsiPrev16( LPCSTR start
, SEGPTR current
)
2992 char *ptr
= MapSL(current
);
2993 return current
- (ptr
- CharPrevA( start
, ptr
));
2997 /****************************************************************************
2998 * GetKeyboardLayoutName (USER.477)
3000 INT16 WINAPI
GetKeyboardLayoutName16( LPSTR name
)
3002 return GetKeyboardLayoutNameA( name
);
3006 /***********************************************************************
3007 * SystemParametersInfo (USER.483)
3009 BOOL16 WINAPI
SystemParametersInfo16( UINT16 uAction
, UINT16 uParam
,
3010 LPVOID lpvParam
, UINT16 fuWinIni
)
3014 TRACE("(%u, %u, %p, %u)\n", uAction
, uParam
, lpvParam
, fuWinIni
);
3019 case SPI_GETSCREENSAVEACTIVE
:
3020 case SPI_GETICONTITLEWRAP
:
3021 case SPI_GETMENUDROPALIGNMENT
:
3022 case SPI_GETFASTTASKSWITCH
:
3023 case SPI_GETDRAGFULLWINDOWS
:
3026 ret
= SystemParametersInfoA( uAction
, uParam
, lpvParam
? &tmp
: NULL
, fuWinIni
);
3027 if (ret
&& lpvParam
) *(BOOL16
*)lpvParam
= tmp
;
3032 case SPI_ICONHORIZONTALSPACING
:
3033 case SPI_GETSCREENSAVETIMEOUT
:
3034 case SPI_GETGRIDGRANULARITY
:
3035 case SPI_GETKEYBOARDDELAY
:
3036 case SPI_ICONVERTICALSPACING
:
3039 ret
= SystemParametersInfoA( uAction
, uParam
, lpvParam
? &tmp
: NULL
, fuWinIni
);
3040 if (ret
&& lpvParam
) *(INT16
*)lpvParam
= tmp
;
3044 case SPI_GETKEYBOARDSPEED
:
3045 case SPI_GETMOUSEHOVERWIDTH
:
3046 case SPI_GETMOUSEHOVERHEIGHT
:
3047 case SPI_GETMOUSEHOVERTIME
:
3050 ret
= SystemParametersInfoA( uAction
, uParam
, lpvParam
? &tmp
: NULL
, fuWinIni
);
3051 if (ret
&& lpvParam
) *(WORD
*)lpvParam
= tmp
;
3055 case SPI_GETICONTITLELOGFONT
:
3058 ret
= SystemParametersInfoA( uAction
, uParam
, lpvParam
? &tmp
: NULL
, fuWinIni
);
3059 if (ret
&& lpvParam
) logfont_32_to_16( &tmp
, (LPLOGFONT16
)lpvParam
);
3063 case SPI_GETNONCLIENTMETRICS
:
3065 NONCLIENTMETRICSA tmp
;
3066 LPNONCLIENTMETRICS16 lpnm16
= (LPNONCLIENTMETRICS16
)lpvParam
;
3067 if (lpnm16
&& lpnm16
->cbSize
== sizeof(NONCLIENTMETRICS16
))
3069 tmp
.cbSize
= sizeof(NONCLIENTMETRICSA
);
3070 ret
= SystemParametersInfoA( uAction
, uParam
, &tmp
, fuWinIni
);
3073 lpnm16
->iBorderWidth
= tmp
.iBorderWidth
;
3074 lpnm16
->iScrollWidth
= tmp
.iScrollWidth
;
3075 lpnm16
->iScrollHeight
= tmp
.iScrollHeight
;
3076 lpnm16
->iCaptionWidth
= tmp
.iCaptionWidth
;
3077 lpnm16
->iCaptionHeight
= tmp
.iCaptionHeight
;
3078 lpnm16
->iSmCaptionWidth
= tmp
.iSmCaptionWidth
;
3079 lpnm16
->iSmCaptionHeight
= tmp
.iSmCaptionHeight
;
3080 lpnm16
->iMenuWidth
= tmp
.iMenuWidth
;
3081 lpnm16
->iMenuHeight
= tmp
.iMenuHeight
;
3082 logfont_32_to_16( &tmp
.lfCaptionFont
, &lpnm16
->lfCaptionFont
);
3083 logfont_32_to_16( &tmp
.lfSmCaptionFont
, &lpnm16
->lfSmCaptionFont
);
3084 logfont_32_to_16( &tmp
.lfMenuFont
, &lpnm16
->lfMenuFont
);
3085 logfont_32_to_16( &tmp
.lfStatusFont
, &lpnm16
->lfStatusFont
);
3086 logfont_32_to_16( &tmp
.lfMessageFont
, &lpnm16
->lfMessageFont
);
3089 else /* winfile 95 sets cbSize to 340 */
3090 ret
= SystemParametersInfoA( uAction
, uParam
, lpvParam
, fuWinIni
);
3094 case SPI_GETWORKAREA
:
3097 ret
= SystemParametersInfoA( uAction
, uParam
, lpvParam
? &tmp
: NULL
, fuWinIni
);
3098 if (ret
&& lpvParam
)
3100 RECT16
*r16
= lpvParam
;
3101 r16
->left
= tmp
.left
;
3103 r16
->right
= tmp
.right
;
3104 r16
->bottom
= tmp
.bottom
;
3110 ret
= SystemParametersInfoA( uAction
, uParam
, lpvParam
, fuWinIni
);
3118 /***********************************************************************
3119 * USER_489 (USER.489)
3121 LONG WINAPI
stub_USER_489(void)
3128 /***********************************************************************
3129 * USER_490 (USER.490)
3131 LONG WINAPI
stub_USER_490(void)
3138 /***********************************************************************
3139 * USER_492 (USER.492)
3141 LONG WINAPI
stub_USER_492(void)
3148 /***********************************************************************
3149 * USER_496 (USER.496)
3151 LONG WINAPI
stub_USER_496(void)
3158 /***********************************************************************
3159 * FormatMessage (USER.606)
3161 DWORD WINAPI
FormatMessage16(
3163 SEGPTR lpSource
, /* [in] NOTE: not always a valid pointer */
3166 LPSTR lpBuffer
, /* [out] NOTE: *((HLOCAL16*)) for FORMAT_MESSAGE_ALLOCATE_BUFFER*/
3168 LPDWORD args
) /* [in] NOTE: va_list *args */
3170 /* This implementation is completely dependent on the format of the va_list on x86 CPUs */
3174 DWORD width
= dwFlags
& FORMAT_MESSAGE_MAX_WIDTH_MASK
;
3176 LPSTR allocstring
= NULL
;
3178 TRACE("(0x%x,%x,%d,0x%x,%p,%d,%p)\n",
3179 dwFlags
,lpSource
,dwMessageId
,dwLanguageId
,lpBuffer
,nSize
,args
);
3180 if ((dwFlags
& FORMAT_MESSAGE_FROM_SYSTEM
)
3181 && (dwFlags
& FORMAT_MESSAGE_FROM_HMODULE
)) return 0;
3182 if ((dwFlags
& FORMAT_MESSAGE_FROM_STRING
)
3183 &&((dwFlags
& FORMAT_MESSAGE_FROM_SYSTEM
)
3184 || (dwFlags
& FORMAT_MESSAGE_FROM_HMODULE
))) return 0;
3186 if (width
&& width
!= FORMAT_MESSAGE_MAX_WIDTH_MASK
)
3187 FIXME("line wrapping (%u) not supported.\n", width
);
3189 if (dwFlags
& FORMAT_MESSAGE_FROM_STRING
)
3191 char *source
= MapSL(lpSource
);
3192 from
= HeapAlloc( GetProcessHeap(), 0, strlen(source
)+1 );
3193 strcpy( from
, source
);
3195 else if (dwFlags
& FORMAT_MESSAGE_FROM_SYSTEM
) {
3196 from
= HeapAlloc( GetProcessHeap(),0,200 );
3197 sprintf(from
,"Systemmessage, messageid = 0x%08x\n",dwMessageId
);
3199 else if (dwFlags
& FORMAT_MESSAGE_FROM_HMODULE
) {
3201 HINSTANCE16 hinst16
= ((HINSTANCE16
)lpSource
& 0xffff);
3203 dwMessageId
&= 0xFFFF;
3204 bufsize
=LoadString16(hinst16
,dwMessageId
,NULL
,0);
3206 from
= HeapAlloc( GetProcessHeap(), 0, bufsize
+1);
3207 LoadString16(hinst16
,dwMessageId
,from
,bufsize
+1);
3210 target
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, 100);
3214 #define ADD_TO_T(c) \
3217 if (t-target == talloced) {\
3218 target = HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,target,talloced*2);\
3219 t = target+talloced;\
3226 while (*f
&& !eos
) {
3229 char *fmtstr
,*x
,*lastf
;
3230 DWORD
*argliststart
;
3240 case '1':case '2':case '3':case '4':case '5':
3241 case '6':case '7':case '8':case '9':
3244 case '0':case '1':case '2':case '3':
3245 case '4':case '5':case '6':case '7':
3248 insertnr
=insertnr
*10+*f
-'0';
3257 if (NULL
!=(x
=strchr(f
,'!'))) {
3259 fmtstr
=HeapAlloc(GetProcessHeap(),0,strlen(f
)+2);
3260 sprintf(fmtstr
,"%%%s",f
);
3263 fmtstr
=HeapAlloc(GetProcessHeap(),0,strlen(f
)+2);
3264 sprintf(fmtstr
,"%%%s",f
);
3265 f
+=strlen(f
); /*at \0*/
3271 fmtstr
=HeapAlloc( GetProcessHeap(), 0, 3 );
3272 strcpy( fmtstr
, "%s" );
3277 LPSTR b
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sz
= 100);
3279 argliststart
=args
+insertnr
-1;
3281 /* CMF - This makes a BIG assumption about va_list */
3282 while ((ret
= vsnprintf(b
, sz
, fmtstr
, (va_list) argliststart
)) < 0 || ret
>= sz
) {
3284 sz
= (ret
== -1 ? sz
+ 100 : ret
+ 1);
3285 new_b
= HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, b
, sz
);
3289 for (x
=b
; *x
; x
++) ADD_TO_T(*x
);
3290 HeapFree(GetProcessHeap(), 0, b
);
3292 /* NULL args - copy formatstr
3295 while ((lastf
<f
)&&(*lastf
)) {
3299 HeapFree(GetProcessHeap(),0,fmtstr
);
3301 case '0': /* Just stop processing format string */
3305 case 'n': /* 16 bit version just outputs 'n' */
3310 } else { /* '\n' or '\r' gets mapped to "\r\n" */
3311 if(*f
== '\n' || *f
== '\r') {
3315 if(*f
++ == '\r' && *f
== '\n')
3325 talloced
= strlen(target
)+1;
3326 TRACE("-- %s\n",debugstr_a(target
));
3327 if (dwFlags
& FORMAT_MESSAGE_ALLOCATE_BUFFER
) {
3328 /* nSize is the MINIMUM size */
3329 HLOCAL16 h
= LocalAlloc16(LPTR
,talloced
);
3330 SEGPTR ptr
= LocalLock16(h
);
3331 allocstring
= MapSL( ptr
);
3332 memcpy( allocstring
,target
,talloced
);
3334 *((HLOCAL16
*)lpBuffer
) = h
;
3336 lstrcpynA(lpBuffer
,target
,nSize
);
3337 HeapFree(GetProcessHeap(),0,target
);
3338 HeapFree(GetProcessHeap(),0,from
);
3339 return (dwFlags
& FORMAT_MESSAGE_ALLOCATE_BUFFER
) ?
3340 strlen(allocstring
):
3346 /**********************************************************************
3347 * DestroyIcon32 (USER.610)
3349 * This routine is actually exported from Win95 USER under the name
3350 * DestroyIcon32 ... The behaviour implemented here should mimic
3351 * the Win95 one exactly, especially the return values, which
3352 * depend on the setting of various flags.
3354 WORD WINAPI
DestroyIcon32( HGLOBAL16 handle
, UINT16 flags
)
3358 /* Check whether destroying active cursor */
3360 if (GetCursor16() == handle
)
3362 WARN("Destroying active cursor!\n" );
3366 /* Try shared cursor/icon first */
3368 if (!(flags
& CID_NONSHARED
))
3370 INT count
= release_shared_icon( handle
);
3372 return (flags
& CID_WIN32
) ? TRUE
: (count
== 0);
3375 /* Now assume non-shared cursor/icon */
3377 retv
= free_icon_handle( handle
);
3378 return (flags
& CID_RESOURCE
)? retv
: TRUE
;
3382 /***********************************************************************
3383 * ChangeDisplaySettings (USER.620)
3385 LONG WINAPI
ChangeDisplaySettings16( LPDEVMODEA devmode
, DWORD flags
)
3387 return ChangeDisplaySettingsA( devmode
, flags
);
3391 /***********************************************************************
3392 * EnumDisplaySettings (USER.621)
3394 BOOL16 WINAPI
EnumDisplaySettings16( LPCSTR name
, DWORD n
, LPDEVMODEA devmode
)
3396 return EnumDisplaySettingsA( name
, n
, devmode
);
3399 /**********************************************************************
3400 * DrawFrameControl (USER.656)
3402 BOOL16 WINAPI
DrawFrameControl16( HDC16 hdc
, LPRECT16 rc
, UINT16 uType
, UINT16 uState
)
3407 rect32
.left
= rc
->left
;
3408 rect32
.top
= rc
->top
;
3409 rect32
.right
= rc
->right
;
3410 rect32
.bottom
= rc
->bottom
;
3411 ret
= DrawFrameControl( HDC_32(hdc
), &rect32
, uType
, uState
);
3412 rc
->left
= rect32
.left
;
3413 rc
->top
= rect32
.top
;
3414 rc
->right
= rect32
.right
;
3415 rc
->bottom
= rect32
.bottom
;
3419 /**********************************************************************
3420 * DrawEdge (USER.659)
3422 BOOL16 WINAPI
DrawEdge16( HDC16 hdc
, LPRECT16 rc
, UINT16 edge
, UINT16 flags
)
3427 rect32
.left
= rc
->left
;
3428 rect32
.top
= rc
->top
;
3429 rect32
.right
= rc
->right
;
3430 rect32
.bottom
= rc
->bottom
;
3431 ret
= DrawEdge( HDC_32(hdc
), &rect32
, edge
, flags
);
3432 rc
->left
= rect32
.left
;
3433 rc
->top
= rect32
.top
;
3434 rc
->right
= rect32
.right
;
3435 rc
->bottom
= rect32
.bottom
;
3439 /**********************************************************************
3440 * CheckMenuRadioItem (USER.666)
3442 BOOL16 WINAPI
CheckMenuRadioItem16(HMENU16 hMenu
, UINT16 first
, UINT16 last
,
3443 UINT16 check
, BOOL16 bypos
)
3445 return CheckMenuRadioItem( HMENU_32(hMenu
), first
, last
, check
, bypos
);