本帖最后由 jycel 于 2009-10-13 13:31 编辑
一个是调用系统一个是自定义的!
注意:在使用时不能给按钮后面加背景色,我测试时添了显示不了!鼠标指针可以……
如图:
#Include <GuiImageList.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <GuiButton.au3>
Local $hImage, $y = 70, $iIcon = 3, $btn[6], $rdo[6], $chk[6], $hImageSmall
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("图标按钮测试", 633, 454, 192, 114)
$Button1 = GUICtrlCreateButton("退出", 112, 112, 337, 65)
_GUICtrlButton_SetImageList($Button1, _GetImageListHandle("shell32.dll", $iIcon , True), 0,2,2)
$Button2 = GUICtrlCreateButton("退出", 112, 212, 337, 35)
;
$hImage = _GUIImageList_Create(32, 32, 6, 3, 6,True)
_GUIImageList_AddIcon($hImage, @ScriptDir&"\1.ico",0,True)
_GUICtrlButton_SetImageList($Button2, $hImage, 0,2,2)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
case $Button1
Exit
case $Button2
Exit
EndSwitch
WEnd
Func _GetImageListHandle($sFile, $nIconID = 0, $fLarge = False)
Local $iSize = 16
If $fLarge 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, $fLarge)
EndIf
Return $hImage
EndFunc ;==>_GetImageListHandle
|