#include <GuiToolbar.au3>
#include <GuiMenu.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
Global $hGUI
Local $hToolbar
Local Enum $idNew = 1000, $idOpen
$hGUI = GUICreate("Toolbar", 200,100)
GUISetState()
$test=GUICreate("Toolbar", 100,20,12,50,BitOR($WS_CHILD,$WS_OVERLAPPED,$WS_POPUP),BitOR($WS_EX_MDICHILD,$WS_EX_TOOLWINDOW),$hGUI)
$hToolbar = _GUICtrlToolbar_Create($test)
_GUICtrlToolbar_SetExtendedStyle($hToolbar, $TBSTYLE_EX_DRAWDDARROWS)
GUISetState()
_GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
_GUICtrlToolbar_AddButton($hToolbar, $idNew, $STD_FILENEW, 0, $BTNS_DROPDOWN)
_GUICtrlToolbar_AddButton($hToolbar, $idOpen, $STD_FILEOPEN)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
While 1
If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit
WEnd
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
Local $tNMHDR, $iCode, $hMenu
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$iCode = DllStructGetData($tNMHDR, "Code")
If $iCode = $TBN_DROPDOWN Then
$hMenu = _GUICtrlMenu_CreatePopup()
_GUICtrlMenu_AddMenuItem($hMenu, "菜单1")
_GUICtrlMenu_AddMenuItem($hMenu, "菜单2")
_GUICtrlMenu_AddMenuItem($hMenu, "菜单3")
_GUICtrlMenu_TrackPopupMenu($hMenu, $hGUI)
_GUICtrlMenu_DestroyMenu($hMenu)
EndIf
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
|