函数参考


_GUIImageList_GetIconWidth

检索图像列表中图像的宽度

#Include <GuiImageList.au3>
_GUIImageList_GetIconWidth($hWnd)

参数

$hWnd 控件句柄

返回值

成功: 图像宽度像素值
失败: 返回 0

注意/说明

None.

相关

_GUIImageList_GetIconHeight, _GUIImageList_GetIconSize, _GUIImageList_GetIconSizeEx

示例/演示


#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
#include <GuiImageList.au3>

Global $iMemo

_Main()

Func _Main()
    Local $hImage, $hGUI, $hDC

    $hGUI = GUICreate("ImageList Get Icon Width", 400, 300)
    $iMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")
    GUISetState()

    ; 加载图像
    $hImage = _GUIImageList_Create(32, 24)
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0xFF0000, 32, 24))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x00FF00, 32, 24))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x0000FF, 32, 24))

    ; 描绘图像
    $hDC = _WinAPI_GetDC($hGUI)
    _GUIImageList_Draw($hImage, 0, $hDC, 4, 4)
    _GUIImageList_Draw($hImage, 1, $hDC, 40, 4)
    _GUIImageList_Draw($hImage, 2, $hDC, 76, 4)

    _WinAPI_ReleaseDC($hGUI, $hDC)

    ; 显示图像列表的图标尺寸
    MemoWrite("Image width : " & _GUIImageList_GetIconWidth($hImage))
    MemoWrite("Image height: " & _GUIImageList_GetIconHeight($hImage))

    ; 循环直到用户退出
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>_Main

; 写入一行到 memo 控件
Func MemoWrite($sMessage)
    GUICtrlSetData($iMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite