设置工具栏按钮的大小
#Include <GuiToolBar.au3>
_GUICtrlToolbar_SetButtonSize($hWnd, $iHeight, $iWidth)
$hWnd | 控件句柄 |
$iHeight | 按钮的高度像素值 |
$iWidth | 按钮的宽度像素值 |
成功: | 返回 True |
失败: | 返回 False |
#include <GuiToolbar.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
$Debug_TB = False ; 检查传递给函数的类名, 设置为True并输出到一个控件的句柄,用于检查它是否工作
Global $iMemo
_Main()
Func _Main()
Local $hGUI, $hToolbar, $aSize
Local Enum $idNew = 1000, $idOpen, $idSave, $idHelp
; 创建 GUI
$hGUI = GUICreate("Toolbar", 400, 300)
$hToolbar = _GUICtrlToolbar_Create($hGUI)
$iMemo = GUICtrlCreateEdit("", 2, 36, 396, 262, $WS_VSCROLL)
GUICtrlSetFont($iMemo, 10, 400, 0, "Courier New")
GUISetState()
; 添加标准系统位图
Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
Case 0
_GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
Case 2
_GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
EndSwitch
; 添加按钮
_GUICtrlToolbar_AddButton($hToolbar, $idNew, $STD_FILENEW)
_GUICtrlToolbar_AddButton($hToolbar, $idOpen, $STD_FILEOPEN)
_GUICtrlToolbar_AddButton($hToolbar, $idSave, $STD_FILESAVE)
_GUICtrlToolbar_AddButtonSep($hToolbar)
_GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)
; Show button size
$aSize = _GUICtrlToolbar_GetButtonSize($hToolbar)
MemoWrite("Button height : " & $aSize[0])
MemoWrite("Button width .: " & $aSize[1])
_GUICtrlToolbar_SetButtonSize($hToolbar, $aSize[0], $aSize[1] + 10)
$aSize = _GUICtrlToolbar_GetButtonSize($hToolbar)
MemoWrite("New Button Size")
MemoWrite("Button height : " & $aSize[0])
MemoWrite("Button width .: " & $aSize[1])
; 循环直到用户退出
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc ;==>_Main
; 写入消息到 memo
Func MemoWrite($sMessage = "")
GUICtrlSetData($iMemo, $sMessage & @CRLF, 1)
EndFunc ;==>MemoWrite