创建伸缩条控件
#Include <GuiRebar.au3>
_GUICtrlRebar_Create($hWnd[, $iStyles = 0x513])
$hWnd | 父窗口或所有者窗口的句柄 |
$iStyles | [可选参数] 除标准窗口样式之外,伸缩条控件还支持多种样式: $RBS_AUTOSIZE - 版本 4.71. 当控件改变大小或位置时,伸缩条控件自动改变带区的布局 控件将发送 $RBN_AUTOSIZE 变化通知消息 $RBS_BANDBORDERS - 版本 4.71. 伸缩条控件显示细线以分隔相邻的带区 $RBS_DBLCLKTOGGLE - 版本 4.71. 当用户双击带区,带区将切换最大化或最小化状态 如果没有这种样式,用户单击带区切换最大化或最小化状态 $RBS_FIXEDORDER - 版本 4.70. 伸缩条控件总是以相同次序显示带区 可以移动带区到不同的行,但带区顺序总是不变的 $RBS_REGISTERDROP - 版本 4.71. 当拖动对象到带区时,生成 $RBN_GETOBJECT 通知消息 $RBS_TOOLTIPS - 版本 4.71. 尚不支持 $RBS_VARHEIGHT - 版本 4.71. 在可能的情况下,伸缩条控件显示带区最低要求的高度 如果没有这种风格,控制显示所有带区在同一高度; 利用可见带区的最高高度确定其它带区的高度 $RBS_VERTICALGRIPPER - 版本 4.71. 垂直伸缩条控件显示垂直尺寸控制柄,而不是水平显示 伸缩条控件没有 $CCS_VERT 样式时,这种样式将被忽略 $CCS_LEFT - 版本 4.70. 控件垂直显示在父窗体左边 $CCS_NODIVIDER - 禁止在控件顶部绘制两个像素高亮 $CCS_RIGHT - 版本 4.70. 控件垂直显示在父窗体右边 $CCS_VERT - 版本 4.70. 控件垂直居中显示 [可选参数] 默认 : $CCS_TOP, $RBS_VARHEIGHT 强制 : $WS_CHILD, $WS_VISIBLE, $WS_CLIPCHILDREN, $WS_CLIPSIBLINGS |
成功: | 返回伸缩条控件句柄 | |
失败: | 设置@error: |
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <GuiComboBox.au3>
#include <GuiDateTimePicker.au3>
#include <GuiEdit.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <GUIConstantsEx.au3>
$Debug_RB = False
Global $hReBar
_Main()
Func _Main()
Local $hgui, $btnExit, $hToolbar, $hCombo, $hDTP, $hInput
Local Enum $idNew = 1000, $idOpen, $idSave, $idHelp
$hgui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
; create the rebar control
$hReBar = _GUICtrlRebar_Create($hgui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))
; create a toolbar to put in the rebar
$hToolbar = _GUICtrlToolbar_Create($hgui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))
; 添加标准系统位图
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)
; create a combobox to put in the rebar
$hCombo = _GUICtrlComboBox_Create($hgui, "", 0, 0, 120)
_GUICtrlComboBox_BeginUpdate($hCombo)
_GUICtrlComboBox_AddDir($hCombo, @WindowsDir & "\*.exe")
_GUICtrlComboBox_EndUpdate($hCombo)
; create a date time picker to put in the rebar
$hDTP = _GUICtrlDTP_Create($hgui, 0, 0, 190)
; create a input box to put in the rebar
;~ $hInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)
$hInput = _GUICtrlEdit_Create($hgui, "Input control", 0, 0, 120, 20)
; default for add is append
; add band with control
_GUICtrlRebar_AddBand($hReBar, $hCombo, 120, 200, "Dir *.exe")
; add band with date time picker
_GUICtrlRebar_AddBand($hReBar, $hDTP, 120)
; add band with toolbar to begining of rebar
_GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)
;add another control
;~ _GUICtrlReBar_AddBand($hReBar, GUICtrlGetHandle($hInput), 120, 200, "Name:")
_GUICtrlRebar_AddBand($hReBar, $hInput, 120, 200, "Name:")
$btnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
GUISetState(@SW_SHOW)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE, $btnExit
Exit
EndSwitch
WEnd
EndFunc ;==>_Main
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR
Local $tAUTOBREAK, $tAUTOSIZE, $tNMREBAR, $tCHEVRON, $tCHILDSIZE, $tOBJECTNOTIFY
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hReBar
Switch $iCode
Case $RBN_AUTOBREAK
; Notifies a rebar's parent that a break will appear in the bar. The parent determines whether to make the break
$tAUTOBREAK = DllStructCreate($tagNMREBARAUTOBREAK, $ilParam)
_DebugPrint("$RBN_AUTOBREAK" & @LF & "--> hWndFrom:" & @TAB & DllStructGetData($tAUTOBREAK, "hWndFrom") & @LF & _
"-->IDFrom:" & @TAB & DllStructGetData($tAUTOBREAK, "IDFrom") & @LF & _
"-->Code:" & @TAB & DllStructGetData($tAUTOBREAK, "Code") & @LF & _
"-->uBand:" & @TAB & DllStructGetData($tAUTOBREAK, "uBand") & @LF & _
"-->wID:" & @TAB & DllStructGetData($tAUTOBREAK, "wID") & @LF & _
"-->lParam:" & @TAB & DllStructGetData($tAUTOBREAK, "lParam") & @LF & _
"-->uMsg:" & @TAB & DllStructGetData($tAUTOBREAK, "uMsg") & @LF & _
"-->fStyleCurrent:" & @TAB & DllStructGetData($tAUTOBREAK, "fStyleCurrent") & @LF & _
"-->fAutoBreak:" & @TAB & DllStructGetData($tAUTOBREAK, "fAutoBreak"))
; Return value not used
Case $RBN_AUTOSIZE
; Sent by a rebar control created with the $RBS_AUTOSIZE style when the rebar automatically resizes itself
$tAUTOSIZE = DllStructCreate($tagNMRBAUTOSIZE, $ilParam)
_DebugPrint("$RBN_AUTOSIZE" & @LF & "--> hWndFrom:" & @TAB & DllStructGetData($tAUTOSIZE, "hWndFrom") & @LF & _
"-->IDFrom:" & @TAB & DllStructGetData($tAUTOSIZE, "IDFrom") & @LF & _
"-->Code:" & @TAB & DllStructGetData($tAUTOSIZE, "Code") & @LF & _
"-->fChanged:" & @TAB & DllStructGetData($tAUTOSIZE, "fChanged") & @LF & _
"-->TargetLeft:" & @TAB & DllStructGetData($tAUTOSIZE, "TargetLeft") & @LF & _
"-->TargetTop:" & @TAB & DllStructGetData($tAUTOSIZE, "TargetTop") & @LF & _
"-->TargetRight:" & @TAB & DllStructGetData($tAUTOSIZE, "TargetRight") & @LF & _
"-->TargetBottom:" & @TAB & DllStructGetData($tAUTOSIZE, "TargetBottom") & @LF & _
"-->ActualLeft:" & @TAB & DllStructGetData($tAUTOSIZE, "ActualLeft") & @LF & _
"-->ActualTop:" & @TAB & DllStructGetData($tAUTOSIZE, "ActualTop") & @LF & _
"-->ActualRight:" & @TAB & DllStructGetData($tAUTOSIZE, "ActualRight") & @LF & _
"-->ActualBottom:" & @TAB & DllStructGetData($tAUTOSIZE, "ActualBottom"))
; Return value not used
Case $RBN_BEGINDRAG
; Sent by a rebar control when the user begins dragging a band
$tNMREBAR = DllStructCreate($tagNMREBAR, $ilParam)
_DebugPrint("$RBN_BEGINDRAG" & @LF & "--> hWndFrom:" & @TAB & DllStructGetData($tNMREBAR, "hWndFrom") & @LF & _
"-->IDFrom:" & @TAB & DllStructGetData($tNMREBAR, "IDFrom") & @LF & _
"-->Code:" & @TAB & DllStructGetData($tNMREBAR, "Code") & @LF & _
"-->dwMask:" & @TAB & DllStructGetData($tNMREBAR, "dwMask") & @LF & _
"-->uBand:" & @TAB & DllStructGetData($tNMREBAR, "uBand") & @LF & _
"-->fStyle:" & @TAB & DllStructGetData($tNMREBAR, "fStyle") & @LF & _
"-->wID:" & @TAB & DllStructGetData($tNMREBAR, "wID") & @LF & _
"-->lParam:" & @TAB & DllStructGetData($tNMREBAR, "lParam"))
Return 0 ; to allow the rebar to continue the drag operation
;~ Return 1 ; nonzero to abort the drag operation
Case $RBN_CHEVRONPUSHED
; Sent by a rebar control when a chevron is pushed
; When an application receives this notification, it is responsible for displaying a popup menu with items for each hidden tool.
; Use the rc member of the NMREBARCHEVRON structure to find the correct position for the popup menu
$tCHEVRON = DllStructCreate($tagNMREBARCHEVRON, $ilParam)
_DebugPrint("$RBN_CHEVRONPUSHED" & @LF & "--> hWndFrom:" & @TAB & DllStructGetData($tCHEVRON, "hWndFrom") & @LF & _
"-->IDFrom:" & @TAB & DllStructGetData($tCHEVRON, "IDFrom") & @LF & _
"-->Code:" & @TAB & DllStructGetData($tCHEVRON, "Code") & @LF & _
"-->uBand:" & @TAB & DllStructGetData($tCHEVRON, "uBand") & @LF & _
"-->wID:" & @TAB & DllStructGetData($tCHEVRON, "wID") & @LF & _
"-->lParam:" & @TAB & DllStructGetData($tCHEVRON, "lParam") & @LF & _
"-->Left:" & @TAB & DllStructGetData($tCHEVRON, "Left") & @LF & _
"-->Top:" & @TAB & DllStructGetData($tCHEVRON, "Top") & @LF & _
"-->Right:" & @TAB & DllStructGetData($tCHEVRON, "Right") & @LF & _
"-->lParamNM:" & @TAB & DllStructGetData($tCHEVRON, "lParamNM"))
; Return value not used
Case $RBN_CHILDSIZE
; Sent by a rebar control when a band's child window is resized
$tCHILDSIZE = DllStructCreate($tagNMREBARCHILDSIZE, $ilParam)
_DebugPrint("$RBN_CHILDSIZE" & @LF & "--> hWndFrom:" & @TAB & DllStructGetData($tCHILDSIZE, "hWndFrom") & @LF & _
"-->IDFrom:" & @TAB & DllStructGetData($tCHILDSIZE, "IDFrom") & @LF & _
"-->Code:" & @TAB & DllStructGetData($tCHILDSIZE, "Code") & @LF & _
"-->uBand:" & @TAB & DllStructGetData($tCHILDSIZE, "uBand") & @LF & _
"-->wID:" & @TAB & DllStructGetData($tCHILDSIZE, "wID") & @LF & _
"-->CLeft:" & @TAB & DllStructGetData($tCHILDSIZE, "CLeft") & @LF & _
"-->CTop:" & @TAB & DllStructGetData($tCHILDSIZE, "CTop") & @LF & _
"-->CRight:" & @TAB & DllStructGetData($tCHILDSIZE, "CRight") & @LF & _
"-->CBottom:" & @TAB & DllStructGetData($tCHILDSIZE, "CBottom") & @LF & _
"-->BLeft:" & @TAB & DllStructGetData($tCHILDSIZE, "BandLeft") & @LF & _
"-->BTop:" & @TAB & DllStructGetData($tCHILDSIZE, "BTop") & @LF & _
"-->BRight:" & @TAB & DllStructGetData($tCHILDSIZE, "BRight") & @LF & _
"-->BBottom:" & @TAB & DllStructGetData($tCHILDSIZE, "BBottom"))
; Return value not used
Case $RBN_DELETEDBAND
; Sent by a rebar control after a band has been deleted
$tNMREBAR = DllStructCreate($tagNMREBAR, $ilParam)
_DebugPrint("$RBN_DELETEDBAND" & @LF & "--> hWndFrom:" & @TAB & DllStructGetData($tNMREBAR, "hWndFrom") & @LF & _
"-->IDFrom:" & @TAB & DllStructGetData($tNMREBAR, "IDFrom") & @LF & _
"-->Code:" & @TAB & DllStructGetData($tNMREBAR, "Code") & @LF & _
"-->dwMask:" & @TAB & DllStructGetData($tNMREBAR, "dwMask") & @LF & _
"-->uBand:" & @TAB & DllStructGetData($tNMREBAR, "uBand") & @LF & _
"-->fStyle:" & @TAB & DllStructGetData($tNMREBAR, "fStyle") & @LF & _
"-->wID:" & @TAB & DllStructGetData($tNMREBAR, "wID") & @LF & _
"-->lParam:" & @TAB & DllStructGetData($tNMREBAR, "lParam"))
; Return value not used
Case $RBN_DELETINGBAND
; Sent by a rebar control when a band is about to be deleted
$tNMREBAR = DllStructCreate($tagNMREBAR, $ilParam)
_DebugPrint("$RBN_DELETINGBAND" & @LF & "--> hWndFrom:" & @TAB & DllStructGetData($tNMREBAR, "hWndFrom") & @LF & _
"-->IDFrom:" & @TAB & DllStructGetData($tNMREBAR, "IDFrom") & @LF & _
"-->Code:" & @TAB & DllStructGetData($tNMREBAR, "Code") & @LF & _
"-->dwMask:" & @TAB & DllStructGetData($tNMREBAR, "dwMask") & @LF & _
"-->uBand:" & @TAB & DllStructGetData($tNMREBAR, "uBand") & @LF & _
"-->fStyle:" & @TAB & DllStructGetData($tNMREBAR, "fStyle") & @LF & _
"-->wID:" & @TAB & DllStructGetData($tNMREBAR, "wID") & @LF & _
"-->lParam:" & @TAB & DllStructGetData($tNMREBAR, "lParam"))
; Return value not used
Case $RBN_ENDDRAG
; Sent by a rebar control when the user stops dragging a band
$tNMREBAR = DllStructCreate($tagNMREBAR, $ilParam)
_DebugPrint("$RBN_ENDDRAG" & @LF & "--> hWndFrom:" & @TAB & DllStructGetData($tNMREBAR, "hWndFrom") & @LF & _
"-->IDFrom:" & @TAB & DllStructGetData($tNMREBAR, "IDFrom") & @LF & _
"-->Code:" & @TAB & DllStructGetData($tNMREBAR, "Code") & @LF & _
"-->dwMask:" & @TAB & DllStructGetData($tNMREBAR, "dwMask") & @LF & _
"-->uBand:" & @TAB & DllStructGetData($tNMREBAR, "uBand") & @LF & _
"-->fStyle:" & @TAB & DllStructGetData($tNMREBAR, "fStyle") & @LF & _
"-->wID:" & @TAB & DllStructGetData($tNMREBAR, "wID") & @LF & _
"-->lParam:" & @TAB & DllStructGetData($tNMREBAR, "lParam"))
; Return value not used
Case $RBN_GETOBJECT
; Sent by a rebar control created with the $RBS_REGISTERDROP style when an object is dragged over a band in the control
$tOBJECTNOTIFY = DllStructCreate($tagNMOBJECTNOTIFY, $ilParam)
_DebugPrint("$RBN_GETOBJECT" & @LF & "--> hWndFrom:" & @TAB & DllStructGetData($tOBJECTNOTIFY, "hWndFrom") & @LF & _
"-->IDFrom:" & @TAB & DllStructGetData($tOBJECTNOTIFY, "IDFrom") & @LF & _
"-->Code:" & @TAB & DllStructGetData($tOBJECTNOTIFY, "Code") & @LF & _
"-->Item:" & @TAB & DllStructGetData($tOBJECTNOTIFY, "Item") & @LF & _
"-->piid:" & @TAB & DllStructGetData($tOBJECTNOTIFY, "piid") & @LF & _
"-->pObject:" & @TAB & DllStructGetData($tOBJECTNOTIFY, "pObject") & @LF & _
"-->Result:" & @TAB & DllStructGetData($tOBJECTNOTIFY, "Result"))
; Return value not used
Case $RBN_HEIGHTCHANGE
; Sent by a rebar control when its height has changed
; Rebar controls that use the $CCS_VERT style send this notification message when their width changes
_DebugPrint("$RBN_HEIGHTCHANGE" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
"-->IDFrom:" & @TAB & $iIDFrom & @LF & _
"-->Code:" & @TAB & $iCode)
; Return value not used
Case $RBN_LAYOUTCHANGED
; Sent by a rebar control when the user changes the layout of the control's bands
_DebugPrint("$RBN_LAYOUTCHANGED" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
"-->IDFrom:" & @TAB & $iIDFrom & @LF & _
"-->Code:" & @TAB & $iCode)
; Return value not used
Case $RBN_MINMAX
; Sent by a rebar control prior to maximizing or minimizing a band
_DebugPrint("$RBN_MINMAX" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
"-->IDFrom:" & @TAB & $iIDFrom & @LF & _
"-->Code:" & @TAB & $iCode)
;~ Return 1 ; a non-zero value to prevent the operation from taking place
Return 0 ; zero to allow it to continue
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
Func _DebugPrint($s_text, $line = @ScriptLineNumber)
ConsoleWrite( _
"!===========================================================" & @LF & _
"+======================================================" & @LF & _
"-->Line(" & StringFormat("%04d", $line) & "):" & @TAB & $s_text & @LF & _
"+======================================================" & @LF)
EndFunc ;==>_DebugPrint