函数参考
GUICtrlSetImage
设置指定控件的位图或图标.
参数
控件ID |
控件标识符(控件ID),可由 GUICtrlCreate... 函数的返回值获得. |
文件名 |
要在控件上显示的图片的文件名称. |
图标名 |
[可选参数] 若目标文件含有多个图标则必须指定图标ID,可以是一个图片名称,也可以是一个负数. 否则使用 -1. |
图标类型 |
[可选参数] 指定图标尺寸:0 = 小图标, 1 = 正常(默认).
对于 TreeViewItem 则: 2 = 选中, 4 = 非选中项目. |
返回值
注意/说明
Use a resource hacker to know the value of the valid icon name in a file.
If used on a Button control the image will be displayed on the button. Images can also be set for Checkbox controls as long as the $BS_PUSHLIKE style is used. In both case the $BS_ICON or $BS_BITMAP styles are needed to select the type of the picture used. The first icon resolution will be used in a multi icon resolution file. I.E. if a 128x128 is the first resolution and the control is 64x64 the image will be truncated.
!!! If use this command on a TreeViewItem the first time, then all other items will use this icon/image automatically by default !!!
If you use GUICtrlSetImage on a TreeView or ListView then all items of it will change to this icon/image.
Passing a positive number will reference the string equivalent icon name.
Passing a negative number causes 1-based "index" behaviour. Some Dll can have icon extracted just with negative numbers.
相关
GUICtrlCreatePic, GUICtrlCreateIcon, GUICtrlCreateButton, GUICtrlCreateCheckbox
示例/演示
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
Example()
Func Example()
Local $msg
GUICreate("My GUI") ; will create a dialog box that when displayed is centered
GUICtrlCreateButton("my picture button", 10, 20, 40, 40, $BS_ICON)
GUICtrlSetImage(-1, "shell32.dll", 22)
GUISetState()
; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
EndFunc ;==>Example