DrawIconEx Function

The DrawIconEx function draws an icon or cursor into the specified device context, performing the specified raster operations, and stretching or compressing the icon or cursor as specified.

Syntax

BOOL DrawIconEx(      
    HDC hdc,     int xLeft,     int yTop,     HICON hIcon,     int cxWidth,     int cyWidth,     UINT istepIfAniCur,     HBRUSH hbrFlickerFreeDraw,     UINT diFlags );

Parameters

hdc
[in] Handle to the device context into which the icon or cursor will be drawn.
xLeft
[in] Specifies the logical x-coordinate of the upper-left corner of the icon or cursor.
yTop
[in] Specifies the logical y-coordinate of the upper-left corner of the icon or cursor.
hIcon
[in] Handle to the icon or cursor to be drawn. This parameter can identify an animated cursor.
cxWidth
[in] Specifies the logical width of the icon or cursor. If this parameter is zero and the diFlags parameter is DI_DEFAULTSIZE, the function uses the SM_CXICON system metric value to set the width. If this parameter is zero and DI_DEFAULTSIZE is not used, the function uses the actual resource width.
cyWidth
[in] Specifies the logical height of the icon or cursor. If this parameter is zero and the diFlags parameter is DI_DEFAULTSIZE, the function uses the SM_CYICON system metric value to set the width. If this parameter is zero and DI_DEFAULTSIZE is not used, the function uses the actual resource height.
istepIfAniCur
[in] Specifies the index of the frame to draw, if hIcon identifies an animated cursor. This parameter is ignored if hIcon does not identify an animated cursor.
hbrFlickerFreeDraw
[in] Handle to a brush that the system uses for flicker-free drawing. If hbrFlickerFreeDraw is a valid brush handle, the system creates an offscreen bitmap using the specified brush for the background color, draws the icon or cursor into the bitmap, and then copies the bitmap into the device context identified by hdc. If hbrFlickerFreeDraw is NULL, the system draws the icon or cursor directly into the device context.
diFlags
[in] Specifies the drawing flags. This parameter can be one of the following values:
DI_COMPAT
Draws the icon or cursor using the system default image rather than the user-specified image. For more information, see About Cursors. Windows NT4.0 and later: This flag is ignored.
DI_DEFAULTSIZE
Draws the icon or cursor using the width and height specified by the system metric values for icons, if the cxWidth and cyWidth parameters are set to zero. If this flag is not specified and cxWidth and cyWidth are set to zero, the function uses the actual resource size.
DI_IMAGE
Draws the icon or cursor using the image.
DI_MASK
Draws the icon or cursor using the mask.
DI_NOMIRROR
Windows XP: Draws the icon as an unmirrored icon. By default, the icon is drawn as a mirrored icon if hdc is mirrored.
DI_NORMAL
Combination of DI_IMAGE and DI_MASK.

Return Value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

The DrawIconEx function places the icon's upper-left corner at the location specified by the xLeft and yTop parameters. The location is subject to the current mapping mode of the device context.

To duplicate DrawIcon (hDC, X, Y, hIcon), call DrawIconEx as follows:

DrawIconEx (hDC, X, Y, hIcon, 0, 0, 0, NULL, DI_NORMAL | DI_COMPAT | DI_DEFAULTSIZE); 

Function Information

Minimum DLL Versionuser32.dll
HeaderDeclared in Winuser.h, include Windows.h
Import libraryUser32.lib
Minimum operating systems Windows 95, Windows NT 3.5
UnicodeImplemented as Unicode version.

See Also

Tags :


Page view tracker