获取分割按钮控件的信息
#include <GuiButton.au3>
_GUICtrlButton_SetSplitInfo($hWnd [, $himlGlyph = -1 [, $iSplitStyle = $BCSS_ALIGNLEFT [, $iWidth = 0 [, $iHeight = 0]]]])
$hWnd | 控件的控件ID/句柄 |
$himlGlyph | [可选参数] 图像列表句柄 |
$iSplitStyle | [可选参数] 拆分按钮样式. 可以是下列标志之一或多个标志:. $BCSS_ALIGNLEFT - 水平左对齐图像或拆分符号 $BCSS_IMAGE - 用 ico 图标作为拆分符号 $BCSS_NOSPLIT - 没有拆分符号 $BCSS_STRETCH - 伸展拆分符号, 但需保持宽高比 |
$iWidth | [可选参数] 拆分符号宽度 |
$iHeight | [可选参数] 拆分符号高度 |
成功: | 返回 True |
失败: | 返回 False |
在MSDN中搜索
#include <GUIConstantsEx.au3>
#include <GuiButton.au3>
#include <WindowsConstants.au3>
#include <GuiMenu.au3>
Global $btn, $iMemo, $btn2
; Note the controlId from these buttons can NOT be read with GuiCtrlRead
_Main()
Func _Main()
Local $hGUI, $aInfo
$hGUI = GUICreate("Buttons", 400, 400)
$iMemo = GUICtrlCreateEdit("", 10, 100, 390, 284, $WS_VSCROLL)
GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")
$btn = _GUICtrlButton_Create($hGUI, "Split Button", 10, 10, 120, 30, $BS_SPLITBUTTON)
_GUICtrlButton_SetSplitInfo($btn)
$btn2 = _GUICtrlButton_Create($hGUI, "Split Button 2", 10, 50, 120, 30, $BS_SPLITBUTTON)
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
GUISetState()
$aInfo = _GUICtrlButton_GetSplitInfo($btn)
MemoWrite("Split Info" & @LF & "----------------")
For $x = 0 To 3
MemoWrite("$ainfo[" & $x & "] = " & $aInfo[$x])
Next
MemoWrite("Split Info" & @LF & "----------------")
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
EndSwitch
WEnd
Exit
EndFunc ;==>_Main
; 写入一行到 memo 控件
Func MemoWrite($sMessage)
GUICtrlSetData($iMemo, $sMessage & @CRLF, 1)
EndFunc ;==>MemoWrite
Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam)
#forceref $hWnd, $Msg, $wParam
Local Const $BCN_HOTITEMCHANGE = -1249
Local $tNMBHOTITEM = DllStructCreate("hwnd hWndFrom;int IDFrom;int Code;dword dwFlags", $lParam)
Local $nNotifyCode = DllStructGetData($tNMBHOTITEM, "Code")
Local $nID = DllStructGetData($tNMBHOTITEM, "IDFrom")
Local $hCtrl = DllStructGetData($tNMBHOTITEM, "hWndFrom")
Local $dwFlags = DllStructGetData($tNMBHOTITEM, "dwFlags")
Local $sText = ""
Switch $nNotifyCode
Case $BCN_HOTITEMCHANGE ; Win XP and Above
If BitAND($dwFlags, 0x10) = 0x10 Then
$sText = "$BCN_HOTITEMCHANGE - Entering: " & @CRLF
ElseIf BitAND($dwFlags, 0x20) = 0x20 Then
$sText = "$BCN_HOTITEMCHANGE - Leaving: " & @CRLF
EndIf
MemoWrite($sText & _
"-----------------------------" & @CRLF & _
"WM_NOTIFY - Infos:" & @CRLF & _
"-----------------------------" & @CRLF & _
"Code" & @TAB & ":" & $nNotifyCode & @CRLF & _
"CtrlID" & @TAB & ":" & $nID & @CRLF & _
"CtrlHWnd:" & $hCtrl & @CRLF & _
_GUICtrlButton_GetText($hCtrl) & @CRLF)
Case $BCN_DROPDOWN
MemoWrite("$BCN_DROPDOWN")
_Popup_Menu($hCtrl)
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
Func _Popup_Menu($hCtrl)
Local $hMenu
Local Enum $idOpen = 1000, $idSave, $idInfo
$hMenu = _GUICtrlMenu_CreatePopup()
_GUICtrlMenu_InsertMenuItem($hMenu, 0, "Open", $idOpen)
_GUICtrlMenu_InsertMenuItem($hMenu, 1, "Save", $idSave)
_GUICtrlMenu_InsertMenuItem($hMenu, 3, "", 0)
_GUICtrlMenu_InsertMenuItem($hMenu, 3, "Info", $idInfo)
Switch _GUICtrlMenu_TrackPopupMenu($hMenu, $hCtrl, -1, -1, 1, 1, 2)
Case $idOpen
MemoWrite("Open - Selected")
Case $idSave
MemoWrite("Save - Selected")
Case $idInfo
MemoWrite("Info - Selected")
EndSwitch
_GUICtrlMenu_DestroyMenu($hMenu)
EndFunc ;==>_Popup_Menu
; React on a button click
Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
#forceref $hWnd, $Msg
Local $nNotifyCode = BitShift($wParam, 16)
Local $nID = BitAND($wParam, 0x0000FFFF)
Local $hCtrl = $lParam
Local $sText = ""
Switch $hCtrl
Case $btn, $btn2
Switch $nNotifyCode
Case $BN_CLICKED
$sText = "$BN_CLICKED" & @CRLF
Case $BN_PAINT
$sText = "$BN_PAINT" & @CRLF
Case $BN_PUSHED, $BN_HILITE
$sText = "$BN_PUSHED, $BN_HILITE" & @CRLF
Case $BN_UNPUSHED, $BN_UNHILITE
$sText = "$BN_UNPUSHED" & @CRLF
Case $BN_DISABLE
$sText = "$BN_DISABLE" & @CRLF
Case $BN_DBLCLK, $BN_DOUBLECLICKED
$sText = "$BN_DBLCLK, $BN_DOUBLECLICKED" & @CRLF
Case $BN_SETFOCUS
$sText = "$BN_SETFOCUS" & @CRLF
Case $BN_KILLFOCUS
$sText = "$BN_KILLFOCUS" & @CRLF
EndSwitch
MemoWrite($sText & _
"-----------------------------" & @CRLF & _
"WM_COMMAND - Infos:" & @CRLF & _
"-----------------------------" & @CRLF & _
"Code" & @TAB & ":" & $nNotifyCode & @CRLF & _
"CtrlID" & @TAB & ":" & $nID & @CRLF & _
"CtrlHWnd:" & $hCtrl & @CRLF & _
_GUICtrlButton_GetText($hCtrl) & @CRLF)
Return 0 ; Only workout clicking on the button
EndSwitch
; Proceed the default AutoIt3 internal message commands.
; You also can complete let the line out.
; !!! But only 'Return' (without any value) will not proceed
; the default AutoIt3-message in the future !!!
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_COMMAND