#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiImageList.au3>
#include <GUIToolBar.au3>
#include <GuiButton.au3>
Global Enum $cmd01 = 1000, $cmd02, $cmd03, $cmd04
$Form1 = GUICreate("Example", 500, 280)
$hImage = _GUIImageList_Create(32, 32, 5, 3)
_GUIImageList_AddIcon($hImage, 'shell32.dll', 110, True)
_GUIImageList_AddIcon($hImage, 'shell32.dll', 137, True)
_GUIImageList_AddIcon($hImage, 'shell32.dll', 146, True)
_GUIImageList_AddIcon($hImage, 'shell32.dll', 128, True)
$hToolbar = _GUICtrlToolbar_Create($Form1, BitOR($TBSTYLE_FLAT, $TBSTYLE_LIST))
_GUICtrlToolbar_SetImageList($hToolbar, $hImage)
_GUICtrlToolbar_SetIndent($hToolbar, 8)
_GUICtrlToolbar_AddButton($hToolbar, $cmd01, 0, _GUICtrlToolbar_AddString($hToolbar, "工具栏按钮01"))
_GUICtrlToolbar_AddButtonSep($hToolbar)
_GUICtrlToolbar_AddButton($hToolbar, $cmd02, 1, _GUICtrlToolbar_AddString($hToolbar, "工具栏按钮02"))
_GUICtrlToolbar_AddButton($hToolbar, $cmd03, 2, _GUICtrlToolbar_AddString($hToolbar, "工具栏按钮03"))
_GUICtrlToolbar_AddButtonSep($hToolbar)
_GUICtrlToolbar_AddButton($hToolbar, $cmd04, 3, _GUICtrlToolbar_AddString($hToolbar, "工具栏按钮04"))
$BtnGroup = GUICtrlCreateGroup("", 3, 53, 494, 60)
$Btn01 = GUICtrlCreateButton("普通的按钮01", 7, 65, 119, 40)
GUICtrlSetFont(-1, 9, 400, 0, "Microsoft Yahei")
$Btn02 = GUICtrlCreateButton("普通的按钮02", 130, 65, 119, 40)
GUICtrlSetFont(-1, 9, 400, 0, "Microsoft Yahei")
$Btn03 = GUICtrlCreateButton("普通的按钮03", 247, 65, 119, 40)
GUICtrlSetFont(-1, 9, 400, 0, "Microsoft Yahei")
$Btn04 = GUICtrlCreateButton("普通的按钮04", 370, 65, 119, 40)
GUICtrlSetFont(-1, 9, 400, 0, "Microsoft Yahei")
_GUICtrlButton_SetImageList($Btn01, _GetImageListHandle("shell32.dll", 110, True), 0)
_GUICtrlButton_SetImageList($Btn02, _GetImageListHandle("shell32.dll", 137, True), 0)
_GUICtrlButton_SetImageList($Btn03, _GetImageListHandle("shell32.dll", 146, True), 0)
_GUICtrlButton_SetImageList($Btn04, _GetImageListHandle("shell32.dll", 128, True), 0)
GUISetState()
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
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd