2 * Misc 16-bit USER functions
4 * Copyright 2002 Patrik Stridvall
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "wine/winuser16.h"
30 #include "cursoricon.h"
32 /* handle to handle 16 conversions */
33 #define HANDLE_16(h32) (LOWORD(h32))
35 /* handle16 to handle conversions */
36 #define HANDLE_32(h16) ((HANDLE)(ULONG_PTR)(h16))
37 #define HINSTANCE_32(h16) ((HINSTANCE)(ULONG_PTR)(h16))
39 #define IS_MENU_STRING_ITEM(flags) \
40 (((flags) & (MF_STRING | MF_BITMAP | MF_OWNERDRAW | MF_SEPARATOR)) == MF_STRING)
42 WORD WINAPI
DestroyIcon32(HGLOBAL16
, UINT16
);
45 struct gray_string_info
47 GRAYSTRINGPROC16 proc
;
52 /* callback for 16-bit gray string proc with opaque pointer */
53 static BOOL CALLBACK
gray_string_callback( HDC hdc
, LPARAM param
, INT len
)
55 const struct gray_string_info
*info
= (struct gray_string_info
*)param
;
59 args
[3] = HDC_16(hdc
);
60 args
[2] = HIWORD(info
->param
);
61 args
[1] = LOWORD(info
->param
);
63 WOWCallback16Ex( (DWORD
)info
->proc
, WCB16_PASCAL
, sizeof(args
), args
, &ret
);
67 /* callback for 16-bit gray string proc with string pointer */
68 static BOOL CALLBACK
gray_string_callback_ptr( HDC hdc
, LPARAM param
, INT len
)
70 const struct gray_string_info
*info
;
71 char *str
= (char *)param
;
73 info
= (struct gray_string_info
*)(str
- offsetof( struct gray_string_info
, str
));
74 return gray_string_callback( hdc
, (LPARAM
)info
, len
);
77 struct draw_state_info
83 /* callback for 16-bit DrawState functions */
84 static BOOL CALLBACK
draw_state_callback( HDC hdc
, LPARAM lparam
, WPARAM wparam
, int cx
, int cy
)
86 const struct draw_state_info
*info
= (struct draw_state_info
*)lparam
;
90 args
[5] = HDC_16(hdc
);
91 args
[4] = HIWORD(info
->param
);
92 args
[3] = LOWORD(info
->param
);
96 WOWCallback16Ex( (DWORD
)info
->proc
, WCB16_PASCAL
, sizeof(args
), args
, &ret
);
100 /***********************************************************************
101 * SetCursor (USER.69)
103 HCURSOR16 WINAPI
SetCursor16(HCURSOR16 hCursor
)
105 return HCURSOR_16(SetCursor(HCURSOR_32(hCursor
)));
108 /***********************************************************************
109 * ShowCursor (USER.71)
111 INT16 WINAPI
ShowCursor16(BOOL16 bShow
)
113 return ShowCursor(bShow
);
116 /***********************************************************************
119 BOOL16 WINAPI
DrawIcon16(HDC16 hdc
, INT16 x
, INT16 y
, HICON16 hIcon
)
121 return DrawIcon(HDC_32(hdc
), x
, y
, HICON_32(hIcon
));
125 /***********************************************************************
128 INT16 WINAPI
DrawText16( HDC16 hdc
, LPCSTR str
, INT16 count
, LPRECT16 rect
, UINT16 flags
)
135 CONV_RECT16TO32( rect
, &rect32
);
136 ret
= DrawTextA( HDC_32(hdc
), str
, count
, &rect32
, flags
);
137 CONV_RECT32TO16( &rect32
, rect
);
139 else ret
= DrawTextA( HDC_32(hdc
), str
, count
, NULL
, flags
);
144 /***********************************************************************
147 * See "Undocumented Windows". Used by W2.0 paint.exe.
149 DWORD WINAPI
IconSize16(void)
151 return MAKELONG(GetSystemMetrics(SM_CYICON
), GetSystemMetrics(SM_CXICON
));
155 /**********************************************************************
156 * CreateMenu (USER.151)
158 HMENU16 WINAPI
CreateMenu16(void)
160 return HMENU_16( CreateMenu() );
164 /**********************************************************************
165 * DestroyMenu (USER.152)
167 BOOL16 WINAPI
DestroyMenu16( HMENU16 hMenu
)
169 return DestroyMenu( HMENU_32(hMenu
) );
173 /*******************************************************************
174 * ChangeMenu (USER.153)
176 BOOL16 WINAPI
ChangeMenu16( HMENU16 hMenu
, UINT16 pos
, SEGPTR data
,
177 UINT16 id
, UINT16 flags
)
179 if (flags
& MF_APPEND
) return AppendMenu16( hMenu
, flags
& ~MF_APPEND
, id
, data
);
181 /* FIXME: Word passes the item id in 'pos' and 0 or 0xffff as id */
182 /* for MF_DELETE. We should check the parameters for all others */
183 /* MF_* actions also (anybody got a doc on ChangeMenu?). */
185 if (flags
& MF_DELETE
) return DeleteMenu16(hMenu
, pos
, flags
& ~MF_DELETE
);
186 if (flags
& MF_CHANGE
) return ModifyMenu16(hMenu
, pos
, flags
& ~MF_CHANGE
, id
, data
);
187 if (flags
& MF_REMOVE
) return RemoveMenu16(hMenu
, flags
& MF_BYPOSITION
? pos
: id
,
188 flags
& ~MF_REMOVE
);
189 /* Default: MF_INSERT */
190 return InsertMenu16( hMenu
, pos
, flags
, id
, data
);
194 /*******************************************************************
195 * CheckMenuItem (USER.154)
197 BOOL16 WINAPI
CheckMenuItem16( HMENU16 hMenu
, UINT16 id
, UINT16 flags
)
199 return CheckMenuItem( HMENU_32(hMenu
), id
, flags
);
203 /**********************************************************************
204 * EnableMenuItem (USER.155)
206 UINT16 WINAPI
EnableMenuItem16( HMENU16 hMenu
, UINT16 wItemID
, UINT16 wFlags
)
208 return EnableMenuItem( HMENU_32(hMenu
), wItemID
, wFlags
);
212 /**********************************************************************
213 * GetSubMenu (USER.159)
215 HMENU16 WINAPI
GetSubMenu16( HMENU16 hMenu
, INT16 nPos
)
217 return HMENU_16( GetSubMenu( HMENU_32(hMenu
), nPos
) );
221 /*******************************************************************
222 * GetMenuString (USER.161)
224 INT16 WINAPI
GetMenuString16( HMENU16 hMenu
, UINT16 wItemID
,
225 LPSTR str
, INT16 nMaxSiz
, UINT16 wFlags
)
227 return GetMenuStringA( HMENU_32(hMenu
), wItemID
, str
, nMaxSiz
, wFlags
);
231 /**********************************************************************
234 BOOL16 WINAPI
WinHelp16( HWND16 hWnd
, LPCSTR lpHelpFile
, UINT16 wCommand
,
240 /* We might call WinExec() */
241 ReleaseThunkLock(&mutex_count
);
243 ret
= WinHelpA(WIN_Handle32(hWnd
), lpHelpFile
, wCommand
, (DWORD
)MapSL(dwData
));
245 RestoreThunkLock(mutex_count
);
250 /***********************************************************************
251 * LoadCursor (USER.173)
253 HCURSOR16 WINAPI
LoadCursor16(HINSTANCE16 hInstance
, LPCSTR name
)
255 return HCURSOR_16(LoadCursorA(HINSTANCE_32(hInstance
), name
));
259 /***********************************************************************
260 * LoadIcon (USER.174)
262 HICON16 WINAPI
LoadIcon16(HINSTANCE16 hInstance
, LPCSTR name
)
264 return HICON_16(LoadIconA(HINSTANCE_32(hInstance
), name
));
267 /**********************************************************************
268 * LoadBitmap (USER.175)
270 HBITMAP16 WINAPI
LoadBitmap16(HINSTANCE16 hInstance
, LPCSTR name
)
272 return HBITMAP_16(LoadBitmapA(HINSTANCE_32(hInstance
), name
));
276 /***********************************************************************
277 * GrayString (USER.185)
279 BOOL16 WINAPI
GrayString16( HDC16 hdc
, HBRUSH16 hbr
, GRAYSTRINGPROC16 gsprc
,
280 LPARAM lParam
, INT16 cch
, INT16 x
, INT16 y
,
285 if (!gsprc
) return GrayStringA( HDC_32(hdc
), HBRUSH_32(hbr
), NULL
,
286 (LPARAM
)MapSL(lParam
), cch
, x
, y
, cx
, cy
);
288 if (cch
== -1 || (cch
&& cx
&& cy
))
290 /* lParam can be treated as an opaque pointer */
291 struct gray_string_info info
;
295 ret
= GrayStringA( HDC_32(hdc
), HBRUSH_32(hbr
), gray_string_callback
,
296 (LPARAM
)&info
, cch
, x
, y
, cx
, cy
);
298 else /* here we need some string conversions */
300 char *str16
= MapSL(lParam
);
301 struct gray_string_info
*info
;
303 if (!cch
) cch
= strlen(str16
);
304 if (!(info
= HeapAlloc( GetProcessHeap(), 0, sizeof(*info
) + cch
))) return FALSE
;
306 info
->param
= lParam
;
307 memcpy( info
->str
, str16
, cch
);
308 ret
= GrayStringA( HDC_32(hdc
), HBRUSH_32(hbr
), gray_string_callback_ptr
,
309 (LPARAM
)info
->str
, cch
, x
, y
, cx
, cy
);
310 HeapFree( GetProcessHeap(), 0, info
);
316 /***********************************************************************
317 * TabbedTextOut (USER.196)
319 LONG WINAPI
TabbedTextOut16( HDC16 hdc
, INT16 x
, INT16 y
, LPCSTR lpstr
,
320 INT16 count
, INT16 nb_tabs
, const INT16
*tabs16
, INT16 tab_org
)
323 INT i
, *tabs
= HeapAlloc( GetProcessHeap(), 0, nb_tabs
* sizeof(tabs
) );
325 for (i
= 0; i
< nb_tabs
; i
++) tabs
[i
] = tabs16
[i
];
326 ret
= TabbedTextOutA( HDC_32(hdc
), x
, y
, lpstr
, count
, nb_tabs
, tabs
, tab_org
);
327 HeapFree( GetProcessHeap(), 0, tabs
);
332 /***********************************************************************
333 * GetTabbedTextExtent (USER.197)
335 DWORD WINAPI
GetTabbedTextExtent16( HDC16 hdc
, LPCSTR lpstr
, INT16 count
,
336 INT16 nb_tabs
, const INT16
*tabs16
)
339 INT i
, *tabs
= HeapAlloc( GetProcessHeap(), 0, nb_tabs
* sizeof(tabs
) );
341 for (i
= 0; i
< nb_tabs
; i
++) tabs
[i
] = tabs16
[i
];
342 ret
= GetTabbedTextExtentA( HDC_32(hdc
), lpstr
, count
, nb_tabs
, tabs
);
343 HeapFree( GetProcessHeap(), 0, tabs
);
348 /*************************************************************************
349 * ScrollDC (USER.221)
351 BOOL16 WINAPI
ScrollDC16( HDC16 hdc
, INT16 dx
, INT16 dy
, const RECT16
*rect
,
352 const RECT16
*cliprc
, HRGN16 hrgnUpdate
,
355 RECT rect32
, clipRect32
, rcUpdate32
;
358 if (rect
) CONV_RECT16TO32( rect
, &rect32
);
359 if (cliprc
) CONV_RECT16TO32( cliprc
, &clipRect32
);
360 ret
= ScrollDC( HDC_32(hdc
), dx
, dy
, rect
? &rect32
: NULL
,
361 cliprc
? &clipRect32
: NULL
, HRGN_32(hrgnUpdate
),
363 if (rcUpdate
) CONV_RECT32TO16( &rcUpdate32
, rcUpdate
);
367 /***********************************************************************
368 * GetCursor (USER.247)
370 HCURSOR16 WINAPI
GetCursor16(void)
372 return HCURSOR_16(GetCursor());
376 /**********************************************************************
377 * GetMenuState (USER.250)
379 UINT16 WINAPI
GetMenuState16( HMENU16 hMenu
, UINT16 wItemID
, UINT16 wFlags
)
381 return GetMenuState( HMENU_32(hMenu
), wItemID
, wFlags
);
385 /**********************************************************************
386 * GetMenuItemCount (USER.263)
388 INT16 WINAPI
GetMenuItemCount16( HMENU16 hMenu
)
390 return GetMenuItemCount( HMENU_32(hMenu
) );
394 /**********************************************************************
395 * GetMenuItemID (USER.264)
397 UINT16 WINAPI
GetMenuItemID16( HMENU16 hMenu
, INT16 nPos
)
399 return GetMenuItemID( HMENU_32(hMenu
), nPos
);
403 /***********************************************************************
404 * GlobalAddAtom (USER.268)
406 ATOM WINAPI
GlobalAddAtom16(LPCSTR lpString
)
408 return GlobalAddAtomA(lpString
);
411 /***********************************************************************
412 * GlobalDeleteAtom (USER.269)
414 ATOM WINAPI
GlobalDeleteAtom16(ATOM nAtom
)
416 return GlobalDeleteAtom(nAtom
);
419 /***********************************************************************
420 * GlobalFindAtom (USER.270)
422 ATOM WINAPI
GlobalFindAtom16(LPCSTR lpString
)
424 return GlobalFindAtomA(lpString
);
427 /***********************************************************************
428 * GlobalGetAtomName (USER.271)
430 UINT16 WINAPI
GlobalGetAtomName16(ATOM nAtom
, LPSTR lpBuffer
, INT16 nSize
)
432 return GlobalGetAtomNameA(nAtom
, lpBuffer
, nSize
);
436 /***********************************************************************
437 * GetSysColorBrush (USER.281)
439 HBRUSH16 WINAPI
GetSysColorBrush16( INT16 index
)
441 return HBRUSH_16( GetSysColorBrush(index
) );
445 /***********************************************************************
446 * SelectPalette (USER.282)
448 HPALETTE16 WINAPI
SelectPalette16( HDC16 hdc
, HPALETTE16 hpal
, BOOL16 bForceBackground
)
450 return HPALETTE_16( SelectPalette( HDC_32(hdc
), HPALETTE_32(hpal
), bForceBackground
));
453 /***********************************************************************
454 * RealizePalette (USER.283)
456 UINT16 WINAPI
RealizePalette16( HDC16 hdc
)
458 return UserRealizePalette( HDC_32(hdc
) );
462 /***********************************************************************
463 * SignalProc (USER.314)
465 void WINAPI
SignalProc16( HANDLE16 hModule
, UINT16 code
,
466 UINT16 uExitFn
, HINSTANCE16 hInstance
, HQUEUE16 hQueue
)
468 if (code
== USIG16_DLL_UNLOAD
)
470 /* HOOK_FreeModuleHooks( hModule ); */
471 CLASS_FreeModuleClasses( hModule
);
472 CURSORICON_FreeModuleIcons( hModule
);
477 /**********************************************************************
480 BOOL16 WINAPI
IsMenu16( HMENU16 hmenu
)
482 return IsMenu( HMENU_32(hmenu
) );
486 /**********************************************************************
487 * SetMenuContextHelpId (USER.384)
489 BOOL16 WINAPI
SetMenuContextHelpId16( HMENU16 hMenu
, DWORD dwContextHelpID
)
491 return SetMenuContextHelpId( HMENU_32(hMenu
), dwContextHelpID
);
495 /**********************************************************************
496 * GetMenuContextHelpId (USER.385)
498 DWORD WINAPI
GetMenuContextHelpId16( HMENU16 hMenu
)
500 return GetMenuContextHelpId( HMENU_32(hMenu
) );
504 /***********************************************************************
505 * LoadImage (USER.389)
508 HANDLE16 WINAPI
LoadImage16(HINSTANCE16 hinst
, LPCSTR name
, UINT16 type
,
509 INT16 desiredx
, INT16 desiredy
, UINT16 loadflags
)
511 return HANDLE_16(LoadImageA(HINSTANCE_32(hinst
), name
, type
, desiredx
,
512 desiredy
, loadflags
));
515 /******************************************************************************
516 * CopyImage (USER.390) Creates new image and copies attributes to it
519 HICON16 WINAPI
CopyImage16(HANDLE16 hnd
, UINT16 type
, INT16 desiredx
,
520 INT16 desiredy
, UINT16 flags
)
522 return HICON_16(CopyImage(HANDLE_32(hnd
), (UINT
)type
, (INT
)desiredx
,
523 (INT
)desiredy
, (UINT
)flags
));
526 /**********************************************************************
527 * DrawIconEx (USER.394)
529 BOOL16 WINAPI
DrawIconEx16(HDC16 hdc
, INT16 xLeft
, INT16 yTop
, HICON16 hIcon
,
530 INT16 cxWidth
, INT16 cyWidth
, UINT16 istep
,
531 HBRUSH16 hbr
, UINT16 flags
)
533 return DrawIconEx(HDC_32(hdc
), xLeft
, yTop
, HICON_32(hIcon
), cxWidth
, cyWidth
,
534 istep
, HBRUSH_32(hbr
), flags
);
537 /**********************************************************************
538 * GetIconInfo (USER.395)
540 BOOL16 WINAPI
GetIconInfo16(HICON16 hIcon
, LPICONINFO16 iconinfo
)
543 BOOL16 ret
= GetIconInfo(HICON_32(hIcon
), &ii32
);
545 iconinfo
->fIcon
= ii32
.fIcon
;
546 iconinfo
->xHotspot
= ii32
.xHotspot
;
547 iconinfo
->yHotspot
= ii32
.yHotspot
;
548 iconinfo
->hbmMask
= HBITMAP_16(ii32
.hbmMask
);
549 iconinfo
->hbmColor
= HBITMAP_16(ii32
.hbmColor
);
553 /***********************************************************************
554 * CreateCursor (USER.406)
556 HCURSOR16 WINAPI
CreateCursor16(HINSTANCE16 hInstance
,
557 INT16 xHotSpot
, INT16 yHotSpot
,
558 INT16 nWidth
, INT16 nHeight
,
559 LPCVOID lpANDbits
, LPCVOID lpXORbits
)
563 info
.ptHotSpot
.x
= xHotSpot
;
564 info
.ptHotSpot
.y
= yHotSpot
;
565 info
.nWidth
= nWidth
;
566 info
.nHeight
= nHeight
;
567 info
.nWidthBytes
= 0;
569 info
.bBitsPerPixel
= 1;
571 return CreateCursorIconIndirect16(hInstance
, &info
, lpANDbits
, lpXORbits
);
575 /*******************************************************************
576 * InsertMenu (USER.410)
578 BOOL16 WINAPI
InsertMenu16( HMENU16 hMenu
, UINT16 pos
, UINT16 flags
,
579 UINT16 id
, SEGPTR data
)
581 UINT pos32
= (UINT
)pos
;
582 if ((pos
== (UINT16
)-1) && (flags
& MF_BYPOSITION
)) pos32
= (UINT
)-1;
583 if (IS_MENU_STRING_ITEM(flags
) && data
)
584 return InsertMenuA( HMENU_32(hMenu
), pos32
, flags
, id
, MapSL(data
) );
585 return InsertMenuA( HMENU_32(hMenu
), pos32
, flags
, id
, (LPSTR
)data
);
589 /*******************************************************************
590 * AppendMenu (USER.411)
592 BOOL16 WINAPI
AppendMenu16(HMENU16 hMenu
, UINT16 flags
, UINT16 id
, SEGPTR data
)
594 return InsertMenu16( hMenu
, -1, flags
| MF_BYPOSITION
, id
, data
);
598 /**********************************************************************
599 * RemoveMenu (USER.412)
601 BOOL16 WINAPI
RemoveMenu16( HMENU16 hMenu
, UINT16 nPos
, UINT16 wFlags
)
603 return RemoveMenu( HMENU_32(hMenu
), nPos
, wFlags
);
607 /**********************************************************************
608 * DeleteMenu (USER.413)
610 BOOL16 WINAPI
DeleteMenu16( HMENU16 hMenu
, UINT16 nPos
, UINT16 wFlags
)
612 return DeleteMenu( HMENU_32(hMenu
), nPos
, wFlags
);
616 /*******************************************************************
617 * ModifyMenu (USER.414)
619 BOOL16 WINAPI
ModifyMenu16( HMENU16 hMenu
, UINT16 pos
, UINT16 flags
,
620 UINT16 id
, SEGPTR data
)
622 if (IS_MENU_STRING_ITEM(flags
))
623 return ModifyMenuA( HMENU_32(hMenu
), pos
, flags
, id
, MapSL(data
) );
624 return ModifyMenuA( HMENU_32(hMenu
), pos
, flags
, id
, (LPSTR
)data
);
628 /**********************************************************************
629 * CreatePopupMenu (USER.415)
631 HMENU16 WINAPI
CreatePopupMenu16(void)
633 return HMENU_16( CreatePopupMenu() );
637 /**********************************************************************
638 * SetMenuItemBitmaps (USER.418)
640 BOOL16 WINAPI
SetMenuItemBitmaps16( HMENU16 hMenu
, UINT16 nPos
, UINT16 wFlags
,
641 HBITMAP16 hNewUnCheck
, HBITMAP16 hNewCheck
)
643 return SetMenuItemBitmaps( HMENU_32(hMenu
), nPos
, wFlags
,
644 HBITMAP_32(hNewUnCheck
), HBITMAP_32(hNewCheck
) );
648 /*******************************************************************
649 * InsertMenuItem (USER.441)
653 BOOL16 WINAPI
InsertMenuItem16( HMENU16 hmenu
, UINT16 pos
, BOOL16 byposition
,
654 const MENUITEMINFO16
*mii
)
658 miia
.cbSize
= sizeof(miia
);
659 miia
.fMask
= mii
->fMask
;
660 miia
.dwTypeData
= (LPSTR
)mii
->dwTypeData
;
661 miia
.fType
= mii
->fType
;
662 miia
.fState
= mii
->fState
;
664 miia
.hSubMenu
= HMENU_32(mii
->hSubMenu
);
665 miia
.hbmpChecked
= HBITMAP_32(mii
->hbmpChecked
);
666 miia
.hbmpUnchecked
= HBITMAP_32(mii
->hbmpUnchecked
);
667 miia
.dwItemData
= mii
->dwItemData
;
669 if (IS_MENU_STRING_ITEM(miia
.fType
))
670 miia
.dwTypeData
= MapSL(mii
->dwTypeData
);
671 return InsertMenuItemA( HMENU_32(hmenu
), pos
, byposition
, &miia
);
675 /**********************************************************************
676 * DrawState (USER.449)
678 BOOL16 WINAPI
DrawState16( HDC16 hdc
, HBRUSH16 hbr
, DRAWSTATEPROC16 func
, LPARAM ldata
,
679 WPARAM16 wdata
, INT16 x
, INT16 y
, INT16 cx
, INT16 cy
, UINT16 flags
)
681 struct draw_state_info info
;
682 UINT opcode
= flags
& 0xf;
684 if (opcode
== DST_TEXT
|| opcode
== DST_PREFIXTEXT
)
686 /* make sure DrawStateA doesn't try to use ldata as a pointer */
687 if (!wdata
) wdata
= strlen( MapSL(ldata
) );
691 if (!GetTextExtentPoint32A( HDC_32(hdc
), MapSL(ldata
), wdata
, &s
)) return FALSE
;
698 return DrawStateA( HDC_32(hdc
), HBRUSH_32(hbr
), draw_state_callback
,
699 (LPARAM
)&info
, wdata
, x
, y
, cx
, cy
, flags
);
703 /**********************************************************************
704 * CreateIconFromResourceEx (USER.450)
706 * FIXME: not sure about exact parameter types
708 HICON16 WINAPI
CreateIconFromResourceEx16(LPBYTE bits
, UINT16 cbSize
,
709 BOOL16 bIcon
, DWORD dwVersion
,
710 INT16 width
, INT16 height
,
713 return HICON_16(CreateIconFromResourceEx(bits
, cbSize
, bIcon
, dwVersion
,
714 width
, height
, cFlag
));
717 /***********************************************************************
718 * DestroyIcon (USER.457)
720 BOOL16 WINAPI
DestroyIcon16(HICON16 hIcon
)
722 return DestroyIcon32(hIcon
, 0);
725 /***********************************************************************
726 * DestroyCursor (USER.458)
728 BOOL16 WINAPI
DestroyCursor16(HCURSOR16 hCursor
)
730 return DestroyIcon32(hCursor
, 0);
733 /*******************************************************************
736 * Recursively find a child that contains spDragInfo->pt point
737 * and send WM_QUERYDROPOBJECT. Helper for DragObject16.
739 static BOOL
DRAG_QueryUpdate16( HWND hQueryWnd
, SEGPTR spDragInfo
)
744 LPDRAGINFO16 ptrDragInfo
= MapSL(spDragInfo
);
748 if (!IsWindowEnabled(hQueryWnd
)) return FALSE
;
750 old_pt
.x
= ptrDragInfo
->pt
.x
;
751 old_pt
.y
= ptrDragInfo
->pt
.y
;
753 ScreenToClient( hQueryWnd
, &pt
);
754 child
= ChildWindowFromPointEx( hQueryWnd
, pt
, CWP_SKIPINVISIBLE
);
755 if (!child
) return FALSE
;
757 if (child
!= hQueryWnd
)
760 if (DRAG_QueryUpdate16( child
, spDragInfo
)) return TRUE
;
764 GetClientRect( hQueryWnd
, &tempRect
);
765 wParam
= !PtInRect( &tempRect
, pt
);
768 ptrDragInfo
->pt
.x
= pt
.x
;
769 ptrDragInfo
->pt
.y
= pt
.y
;
770 ptrDragInfo
->hScope
= HWND_16(hQueryWnd
);
772 bResult
= SendMessage16( HWND_16(hQueryWnd
), WM_QUERYDROPOBJECT
, wParam
, spDragInfo
);
776 ptrDragInfo
->pt
.x
= old_pt
.x
;
777 ptrDragInfo
->pt
.y
= old_pt
.y
;
783 /******************************************************************************
784 * DragObject (USER.464)
786 DWORD WINAPI
DragObject16( HWND16 hwndScope
, HWND16 hWnd
, UINT16 wObj
,
787 HANDLE16 hOfStruct
, WORD szList
, HCURSOR16 hCursor
)
790 LPDRAGINFO16 lpDragInfo
;
792 HCURSOR hOldCursor
=0, hBummer
=0;
793 HGLOBAL16 hDragInfo
= GlobalAlloc16( GMEM_SHARE
| GMEM_ZEROINIT
, 2*sizeof(DRAGINFO16
));
794 HCURSOR hCurrentCursor
= 0;
795 HWND16 hCurrentWnd
= 0;
797 lpDragInfo
= (LPDRAGINFO16
) GlobalLock16(hDragInfo
);
798 spDragInfo
= K32WOWGlobalLock16(hDragInfo
);
800 if( !lpDragInfo
|| !spDragInfo
) return 0L;
802 if (!(hBummer
= LoadCursorA(0, MAKEINTRESOURCEA(OCR_NO
))))
804 GlobalFree16(hDragInfo
);
808 if(hCursor
) hOldCursor
= SetCursor(HCURSOR_32(hCursor
));
810 lpDragInfo
->hWnd
= hWnd
;
811 lpDragInfo
->hScope
= 0;
812 lpDragInfo
->wFlags
= wObj
;
813 lpDragInfo
->hList
= szList
; /* near pointer! */
814 lpDragInfo
->hOfStruct
= hOfStruct
;
817 SetCapture( HWND_32(hWnd
) );
822 GetMessageW( &msg
, 0, WM_MOUSEFIRST
, WM_MOUSELAST
);
824 *(lpDragInfo
+1) = *lpDragInfo
;
826 lpDragInfo
->pt
.x
= msg
.pt
.x
;
827 lpDragInfo
->pt
.y
= msg
.pt
.y
;
829 /* update DRAGINFO struct */
830 if( DRAG_QueryUpdate16(WIN_Handle32(hwndScope
), spDragInfo
) > 0 )
831 hCurrentCursor
= HCURSOR_32(hCursor
);
834 hCurrentCursor
= hBummer
;
835 lpDragInfo
->hScope
= 0;
838 SetCursor(hCurrentCursor
);
840 /* send WM_DRAGLOOP */
841 SendMessage16( hWnd
, WM_DRAGLOOP
, (WPARAM16
)(hCurrentCursor
!= hBummer
),
842 (LPARAM
) spDragInfo
);
843 /* send WM_DRAGSELECT or WM_DRAGMOVE */
844 if( hCurrentWnd
!= lpDragInfo
->hScope
)
847 SendMessage16( hCurrentWnd
, WM_DRAGSELECT
, 0,
848 (LPARAM
)MAKELONG(LOWORD(spDragInfo
)+sizeof(DRAGINFO16
),
849 HIWORD(spDragInfo
)) );
850 hCurrentWnd
= lpDragInfo
->hScope
;
852 SendMessage16( hCurrentWnd
, WM_DRAGSELECT
, 1, (LPARAM
)spDragInfo
);
856 SendMessage16( hCurrentWnd
, WM_DRAGMOVE
, 0, (LPARAM
)spDragInfo
);
858 } while( msg
.message
!= WM_LBUTTONUP
&& msg
.message
!= WM_NCLBUTTONUP
);
863 if( hCursor
) SetCursor(hOldCursor
);
865 if( hCurrentCursor
!= hBummer
)
866 msg
.lParam
= SendMessage16( lpDragInfo
->hScope
, WM_DROPOBJECT
,
867 (WPARAM16
)hWnd
, (LPARAM
)spDragInfo
);
870 GlobalFree16(hDragInfo
);
872 return (DWORD
)(msg
.lParam
);
876 /**********************************************************************
877 * DrawFrameControl (USER.656)
879 BOOL16 WINAPI
DrawFrameControl16( HDC16 hdc
, LPRECT16 rc
, UINT16 uType
, UINT16 uState
)
884 CONV_RECT16TO32( rc
, &rect32
);
885 ret
= DrawFrameControl( HDC_32(hdc
), &rect32
, uType
, uState
);
886 CONV_RECT32TO16( &rect32
, rc
);
890 /**********************************************************************
891 * DrawEdge (USER.659)
893 BOOL16 WINAPI
DrawEdge16( HDC16 hdc
, LPRECT16 rc
, UINT16 edge
, UINT16 flags
)
898 CONV_RECT16TO32( rc
, &rect32
);
899 ret
= DrawEdge( HDC_32(hdc
), &rect32
, edge
, flags
);
900 CONV_RECT32TO16( &rect32
, rc
);
904 /**********************************************************************
905 * CheckMenuRadioItem (USER.666)
907 BOOL16 WINAPI
CheckMenuRadioItem16(HMENU16 hMenu
, UINT16 first
, UINT16 last
,
908 UINT16 check
, BOOL16 bypos
)
910 return CheckMenuRadioItem( HMENU_32(hMenu
), first
, last
, check
, bypos
);