#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)
$hToolbar1 = _GUICtrlToolbar_Create($hGUI)
_GUICtrlToolbar_SetExtendedStyle($hToolbar1, $TBSTYLE_EX_DRAWDDARROWS)
_GUICtrlToolbar_AddBitmap($hToolbar1, 1, -1, $IDB_STD_SMALL_COLOR)
_GUICtrlToolbar_AddButton($hToolbar1, $idNew, $STD_FILENEW, 0, $BTNS_DROPDOWN)
_GUICtrlToolbar_AddButton($hToolbar1, $idOpen, $STD_FILEOPEN)
GUISetState()
$test=GUICreate("Toolbar", 200,23,0,24,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