找回密码
 加入
搜索
查看: 2469|回复: 2

[GUI管理] _GUICtrlToolbar_AddBitmap 如何响应按钮?(已解决)

[复制链接]
发表于 2010-12-25 14:43:59 | 显示全部楼层 |阅读模式
本帖最后由 qq342252004 于 2010-12-25 15:03 编辑

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

Opt('MustDeclareVars', 1)

$Debug_TB = False ; Check ClassName being passed to functions, set to True and use a handle to another control to see it work

_Main()

Func _Main()
    Local $hGUI, $hToolbar
    Local Enum $idNew = 1000, $idOpen, $idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create ($hGUI)
    GUISetState()

    ; Add standard system bitmaps
    _GUICtrlToolbar_AddBitmap ($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)

    ; 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)

    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

EndFunc   ;==>_Main
 楼主| 发表于 2010-12-25 15:03:07 | 显示全部楼层
#include <GuiToolbar.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>

Opt('MustDeclareVars', 1)

$Debug_TB = False ; Check ClassName being passed to functions, set to True and use a handle to another control to see it work

Global $hToolbar, $iMemo
Global $iItem ; Command identifier of the button associated with the notification.
Global Enum $idNew = 1000, $idOpen, $idSave, $idHelp

_Main()

Func _Main()
        Local $hGUI, $aSize

        ; Create GUI
        $hGUI = GUICreate("Toolbar", 600, 400)
        $hToolbar = _GUICtrlToolbar_Create ($hGUI)
        $aSize = _GUICtrlToolbar_GetMaxSize ($hToolbar)
        GUISetState()
        GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY")

        ; Add standard system bitmaps
        _GUICtrlToolbar_AddBitmap ($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)

        ; 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)

        ; Loop until user exits
        Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE

EndFunc   ;==>_Main

; WM_NOTIFY event handler
Func _WM_NOTIFY($hWndGUI, $MsgID, $wParam, $lParam)
        #forceref $hWndGUI, $MsgID, $wParam
        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 $NM_LDOWN
                                        MsgBox(0,'',_GUICtrlToolbar_CommandToIndex ($hToolbar, $iItem))
                        EndSwitch
        EndSwitch
        Return $GUI_RUNDEFMSG
EndFunc   ;==>_WM_NOTIFY
发表于 2011-1-10 14:05:05 | 显示全部楼层
kankan xuexia
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-6-3 02:19 , Processed in 0.078271 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表