zeebit 发表于 2008-5-12 09:38:55

Autoit下工具栏的使用

想编个小程序,里面要用过工具栏,在论坛上找了下,没找到
再到Autoit的帮助里去找,都是英文的,找到了个不错的,推荐一下(也方便以后网友在此论坛上搜索)
此工具栏支持拖动哦!
#include <GuiConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolBar.au3>
#include <GuiComboBox.au3>

Opt("MustDeclareVars", 1)

$Debug_RB = False

Global $iMemo

_Main()

Func _Main()
    Local $hgui, $btnExit, $hReBar, $hToolbar, $hCombo, $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))
   
    ; create the rebar control
    $hReBar = _GUICtrlReBar_Create($hgui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))
   
    $iMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($iMemo, 10, 400, 0, "Courier New")

    ; 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 toolbar to put in the rebar
    $hToolbar = _GUICtrlToolBar_Create($hgui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))
   
    ; Add standard system bitmaps
    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

    ; Add buttons
    _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 input box to put in the rebar
    $hInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ; add band containing the control to the begining of rebar
    _GUICtrlReBar_AddToolBarBand($hReBar, $hToolbar)

    ;add band containing the control
    _GUICtrlReBar_AddBand($hReBar, GUICtrlGetHandle($hInput), 120, 200, "Name:")

    ;add band containing the control
    _GUICtrlReBar_AddBand($hReBar, $hCombo, 120, 200, "Dir " & @WindowsDir & "\*.exe:")

    _GUICtrlRebar_SetBandBackColor($hReBar, 1, Int(0x00008B))
    _GUICtrlRebar_SetBandForeColor($hReBar, 1, Int(0xFFFFFF))
   
    $btnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($btnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($btnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    _GUICtrlRebar_SetBandID($hReBar, 0, 2246)

    MemoWrite("Moved Band Index 0 -> 2: " & _GUICtrlRebar_MoveBand($hReBar, 0, 2))

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
      MemoWrite("============================================")
      MemoWrite("Band Index " & $x & @TAB & "ID: " & _GUICtrlRebar_GetBandID($hReBar, $x))
    Next

    While 1
      Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $btnExit
                Exit
      EndSwitch
    WEnd
EndFunc   ;==>_Main

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($iMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


[ 本帖最后由 zeebit 于 2008-5-12 09:40 编辑 ]

jsj731 发表于 2008-5-13 10:13:31

好呀好呀!谢楼主,正需要呢!

gdygood 发表于 2008-9-22 11:17:24

:face (37): 记号,以后学会了再看

gjxk999 发表于 2008-10-26 10:08:34

学习了,谢谢搂主,谢谢分享!

jsj731 发表于 2008-11-1 10:41:11

呵呵,支持楼主!!!!!!!!!!!

geaifei 发表于 2008-11-1 17:35:55

吼吼o(∩_∩)o...

hzcjd 发表于 2008-12-21 12:57:31

:face (13):

bachelor66 发表于 2009-5-27 15:22:40

好呀,好资料……

anyky123 发表于 2009-10-24 10:54:24

编译不了!请加我QQ534500688

a1986040444 发表于 2009-10-25 22:15:13

好几天没过来了

a1986040444 发表于 2009-10-25 22:15:45

好几天没过来了

iamwonvy 发表于 2011-7-16 18:11:41

有问题
而且运行后和你截图不一样{:face (229):}

turboking 发表于 2012-1-1 15:27:54

UDF里边的。。。

Ycxw2008 发表于 2012-1-5 07:59:52

少2个头文件
#include <WindowsConstants.au3>
#include <Constants.au3>

turboking 发表于 2012-1-6 10:59:54

学习一下。。。。呵呵
页: [1] 2
查看完整版本: Autoit下工具栏的使用