Function Reference


_GUICtrlButton_GetImageList

Retrieves an array that describes the image list assigned to a button control

#include <GuiButton.au3>
_GUICtrlButton_GetImageList ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns an array containing the following:
[0] - Image list handle
[1] - Left margin of the icon
[2] - Top margin of the icon
[3] - Right margin of the icon
[4] - Bottom margin of the icon
[5] - Specifies the alignment. This will be one of the following values:
0 - Image aligned with the left margin.
1 - Image aligned with the right margin.
2 - Image aligned with the top margin.
3 - Image aligned with the bottom margin.
4 - Image centered.

Related

_GUICtrlButton_SetImageList

See Also

Search BCM_GETIMAGELIST in MSDN Library.

Example

#include <GuiButton.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hImage, $y = 70, $iIcon = 125, $a_idBtn[6], $aImageListInfo

    GUICreate("Buttons", 510, 400)
    $g_idMemo = GUICtrlCreateEdit("", 119, 10, 376, 374, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(32, 32, 5, 3, 6)
    For $x = 6 To 11
        _GUIImageList_AddIcon($hImage, "shell32.dll", $x, True)
    Next

    $a_idBtn[0] = GUICtrlCreateButton("Button1", 10, 10, 90, 50)
    _GUICtrlButton_SetImageList($a_idBtn[0], $hImage)

    For $x = 1 To 5
        $a_idBtn[$x] = GUICtrlCreateButton("Button" & $x + 1, 10, $y, 90, 50)
        _GUICtrlButton_SetImageList($a_idBtn[$x], _GetImageListHandle("shell32.dll", $iIcon + $x, True), $x)
        $y += 60
    Next

    For $x = 0 To 5
        $aImageListInfo = _GUICtrlButton_GetImageList($a_idBtn[$x])
        MemoWrite("Button" & $x + 1 & " Imagelist Info" & @CRLF & "--------------------------------")
        MemoWrite("Image list handle........: " & $aImageListInfo[0])
        MemoWrite("Left margin of the icon..: " & $aImageListInfo[1])
        MemoWrite("Top margin of the icon...: " & $aImageListInfo[2])
        MemoWrite("Right margin of the icon.: " & $aImageListInfo[3])
        MemoWrite("Bottom margin of the icon: " & $aImageListInfo[4])
        MemoWrite("Alignment: " & _ExplainAlignment($aImageListInfo[5]))
        MemoWrite("--------------------------------" & @CRLF)
    Next

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

; using image list to set 1 image and have text on button
Func _GetImageListHandle($sFile, $nIconID = 0, $bLarge = False)
    Local $iSize = 16
    If $bLarge Then $iSize = 32

    Local $hImage = _GUIImageList_Create($iSize, $iSize, 5, 3)
    If StringUpper(StringMid($sFile, StringLen($sFile) - 2)) = "BMP" Then
        _GUIImageList_AddBitmap($hImage, $sFile)
    Else
        _GUIImageList_AddIcon($hImage, $sFile, $nIconID, $bLarge)
    EndIf
    Return $hImage
EndFunc   ;==>_GetImageListHandle

Func _ExplainAlignment($iAlign)
    Switch $iAlign
        Case 0
            Return "Image aligned with the left margin."
        Case 1
            Return "Image aligned with the right margin."
        Case 2
            Return "Image aligned with the top margin."
        Case 3
            Return "Image aligned with the bottom margin."
        Case 4
            Return "Image centered."
    EndSwitch
EndFunc   ;==>_ExplainAlignment