xwt620 发表于 2011-10-31 20:50:58

请教下Rebar的用法,看了帮助文件还是没摸清头脑

看了_GUICtrlRebar_DragMove的帮助文件中间有以下代码
    ; 添加按钮
    _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)

    ; 在伸缩条(rebar)上创建一个输入框
    $hInput = GUICtrlCreateInput("输入控件", 0, 0, 120, 20)
可是执行了以后,只看见窗口上有一个input控件,那上面的4个按钮到哪去了呢?

水木子 发表于 2011-11-1 09:11:56

#include <Constants.au3>
#include <GuiToolbar.au3>
#include <GuiImageList.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>

Global $iButtonNum = 30
Global $iCmdID
Global $iWidth = 80, $iHeight = 80

$MyGui = GUICreate("ToolBar 应用", 600, 450)
$hToolBar = _GUICtrlToolbar_Create($MyGui, $TBSTYLE_WRAPABLE)
$hToolBar_Image = _GUIImageList_Create(32, 32, 5, 3)
_GUICtrlToolbar_SetImageList($hToolBar, $hToolBar_Image)
_GUICtrlToolbar_SetIndent($hToolBar, 5)

For $i = 0 To $iButtonNum
        _GUIImageList_AddIcon($hToolBar_Image, @SystemDir & "\Shell32.dll", 100 + $i, True)
        $sButtonText = _GUICtrlToolbar_AddString($hToolBar, "按钮 - " & $i + 1)
        _GUICtrlToolbar_AddButton($hToolBar, 1000 + $i, $i, $sButtonText)
Next

_GUICtrlToolbar_SetButtonSize($hToolBar, $iWidth, $iHeight)
_GUICtrlToolbar_SetStyle($hToolBar, BitOR($TBSTYLE_FLAT, $TBSTYLE_WRAPABLE, $CCS_TOP, $TBSTYLE_TRANSPARENT))
GUISetState()
GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY")

Do
Until GUIGetMsg() = -3

Func _WM_NOTIFY($hWndGUI, $MsgID, $wParam, $lParam)
        Local $tNMHDR, $event, $hwndFrom, $code, $i_idNew, $dwFlags, $lResult, $idFrom, $i_idOld
        Local $tNMTOOLBAR, $tNMTBHOTITEM
        $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
        $hwndFrom = DllStructGetData($tNMHDR, "hWndFrom")
        $idFrom = DllStructGetData($tNMHDR, "IDFrom")
        $code = DllStructGetData($tNMHDR, "Code")
        Switch $hwndFrom
                Case $hToolBar
                        Switch $code
                                Case -2
                                        If $iCmdID Then
                                                MsgBox(0, 'CmdID = ' & $iCmdID, 'ButtonText = ' & _GUICtrlToolbar_GetButtonText($hToolBar, $iCmdID))
                                        EndIf
                                        $iCmdID = ''
                                Case $TBN_HOTITEMCHANGE
                                        $tNMTBHOTITEM = DllStructCreate($tagNMTBHOTITEM, $lParam)
                                        $i_idOld = DllStructGetData($tNMTBHOTITEM, "idOld")
                                        $i_idNew = DllStructGetData($tNMTBHOTITEM, "idNew")
                                        $iCmdID = $i_idNew
                        EndSwitch
        EndSwitch
        Return $GUI_RUNDEFMSG
EndFunc   ;==>_WM_NOTIFY

xwt620 发表于 2011-11-1 20:58:56

额。。。这个toolbar的应用,我问的是rebar的应用

水木子 发表于 2011-11-2 10:06:54

回复 3# xwt620

不好意思,光注意看你的代码了,你的变量名误导了我。

xwt620 发表于 2011-11-2 20:00:10

回复 4# 水木子


    呵呵,没关系。我发现帮助文件中所有的rebar例子都不能用

netegg 发表于 2011-11-9 06:47:18

回复 5# xwt620
好像也不是不能用,只是例子里的似乎都更类似浮动控件,导致会自动覆盖原有的工具栏一类的东西,不知道谁用过,有没有办法解决
页: [1]
查看完整版本: 请教下Rebar的用法,看了帮助文件还是没摸清头脑