Function Reference


_WinAPI_LoadIconWithScaleDown

Loads an icon and scales down a larger image instead of scaling up a smaller image

#include <WinAPIIcons.au3>
_WinAPI_LoadIconWithScaleDown ( $hInstance, $sName, $iWidth, $iHeight )

Parameters

$hInstance Handle to the module of either a DLL or executable (.exe) file that contains the icon to be loaded.
$sName The information about the icon to load. If $hInstance is not 0, $sName specifies the icon resource
either by name or ordinal, otherwise, $sName specifies either the name of a standalone icon (.ico)
file or the identifier of a predefined icon to load.
$IDI_APPLICATION
$IDI_HAND
$IDI_QUESTION
$IDI_EXCLAMATION
$IDI_ASTERISK
$IDI_WINLOGO
$IDI_SHIELD
$IDI_ERROR
$IDI_INFORMATION
$IDI_WARNING
$iWidth The desired width, in pixels, of the icon.
$iHeight The desired height, in pixels, of the icon.

Return Value

Success: The icon handle.
Failure: 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

When you are finished using the icon, destroy it using the _WinAPI_DestroyIcon() function.

This function requires Windows Vista or later.

Related

_WinAPI_DestroyIcon

See Also

Search LoadIconWithScaleDown in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <SendMessage.au3>
#include <StaticConstants.au3>
#include <WinAPIIcons.au3>
#include <WinAPISys.au3>

If Number(_WinAPI_GetVersion()) < 6.0 Then
        MsgBox(($MB_ICONERROR + $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later.')
        Exit
EndIf

GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 324, 324)
GUICtrlCreateIcon('', 0, 64, 64, 196, 196)
Local $h_Icon = GUICtrlGetHandle(-1)
GUISetState(@SW_SHOW)

Local $hIcon = _WinAPI_LoadIconWithScaleDown(0, @ScriptDir & '\Extras\Soccer.ico', 196, 196)
Local $hPrev = _SendMessage($h_Icon, $STM_SETIMAGE, 1, $hIcon)
If $hPrev Then
        _WinAPI_DestroyIcon($hPrev)
EndIf

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE