检索按钮的矩形,返回数据结构.
#Include <GuiToolBar.au3>
_GUICtrlToolbar_GetButtonRectEx($hWnd, $iCommandID)
$hWnd | 控件句柄 |
$iCommandID | 按钮命令 ID |
成功: | 返回 $tagRECT 结构 |
#include <GuiToolbar.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
$Debug_TB = False ; 检查传递给函数的类名, 设置为真并使用另一控件的句柄可以看出它是否有效
Global $iMemo
_Main()
Func _Main()
Local $hGUI, $hToolbar, $tRect
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)
; 显示保存按钮矩形
$tRect = _GUICtrlToolbar_GetButtonRectEx($hToolbar, $idSave)
MemoWrite("Save Button Rect")
MemoWrite("----------------")
MemoWrite("Left ...: " & DllStructGetData($tRect, "Left"))
MemoWrite("Top ....: " & DllStructGetData($tRect, "Top"))
MemoWrite("Right ..: " & DllStructGetData($tRect, "Right"))
MemoWrite("Bottom .: " & DllStructGetData($tRect, "Bottom"))
; 循环直到用户退出
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc ;==>_Main
; 写入消息到 memo
Func MemoWrite($sMessage = "")
GUICtrlSetData($iMemo, $sMessage & @CRLF, 1)
EndFunc ;==>MemoWrite