_GUICtrlToolbar_AddBitmap 如何响应按钮?(已解决)
本帖最后由 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 #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 kankan xuexia
页:
[1]