biase, Did you look at the Help file examples? I think not because you are not even registering the correct message! This works for me: #include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiToolbar.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
Global $iItem
Global $aStrings[5]
Global $aTitles[6] = ["Radio", "TV", "Movie", "", "About", "Exit"] ; We need the blank so the CIDs match the indices
Global Enum $idRadio = 1000, $idTV, $idMovie, $idAbout, $idExit
Global $aCID[6]
$hGUI = GUICreate("Multimedia", 623, 449, 192, 114)
$hImageList = _GUIImageList_Create(32, 32, 5)
_GUIImageList_AddIcon($hImageList, @ScriptDir & 'Iron_Radio.ico', '', True)
_GUIImageList_AddIcon($hImageList, @ScriptDir & 'Iron_TV.ico', '', True)
_GUIImageList_AddIcon($hImageList, @ScriptDir & 'Iron_Movie.ico', '', True)
_GUIImageList_AddIcon($hImageList, @ScriptDir & 'Iron_About.ico', '', True)
_GUIImageList_AddIcon($hImageList, @ScriptDir & 'Iron_Exit.ico', '', True)
$hToolBar = _GUICtrlToolbar_Create($hGUI, 0)
_GUICtrlToolbar_SetImageList($hToolBar, $hImageList)
; Add strings
$aStrings[0] = _GUICtrlToolbar_AddString($hToolBar, $aTitles[0])
$aStrings[1] = _GUICtrlToolbar_AddString($hToolBar, $aTitles[1])
$aStrings[2] = _GUICtrlToolbar_AddString($hToolBar, $aTitles[2])
$aStrings[3] = _GUICtrlToolbar_AddString($hToolBar, $aTitles[4]) ; Careful with the index numbering here
$aStrings[4] = _GUICtrlToolbar_AddString($hToolBar, $aTitles[5])
_GUICtrlToolbar_AddButton($hToolBar, $idRadio, 0, 0)
_GUICtrlToolbar_AddButton($hToolBar, $idTv, 1, 1)
_GUICtrlToolbar_AddButton($hToolBar, $idMovie, 2, 2)
_GUICtrlToolbar_AddButtonSep($hToolbar)
_GUICtrlToolbar_AddButton($hToolBar, $idAbout, 3, 3)
_GUICtrlToolbar_AddButton($hToolBar, $idExit, 4, 4)
; This dummy will fire when a button is clicked
$cDummy = GUICtrlCreateDummy()
GUISetState()
; Register WM_COMMAND messages
GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY")
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
Case $cDummy
; The dummy was fired so read the index and show the button title
MsgBox(0, "Clicked", $aTitles[GUICtrlRead($cDummy)])
EndSwitch
WEnd
; WM_NOTIFY event handler
Func _WM_NOTIFY($hWndGUI, $MsgID, $wParam, $lParam)
#forceref $hWndGUI, $MsgID, $wParam
Local $tNMHDR, $hwndFrom, $code, $i_idNew, $dwFlags, $i_idOld
Local $tNMTBHOTITEM
$tNMHDR = DllStructCreate($tagNMHDR, $lParam)
$hwndFrom = DllStructGetData($tNMHDR, "hWndFrom")
$code = DllStructGetData($tNMHDR, "Code")
Switch $hwndFrom
Case $hToolbar
Switch $code
Case $NM_LDOWN
; A button was clicked so fire the dummy control with the index of the "hot" item
$iClicked = _GUICtrlToolbar_CommandToIndex($hToolbar, $iItem)
GUICtrlSendToDummy($cDummy, $iClicked)
Case $TBN_HOTITEMCHANGE
$tNMTBHOTITEM = DllStructCreate($tagNMTBHOTITEM, $lParam)
$i_idOld = DllStructGetData($tNMTBHOTITEM, "idOld")
$i_idNew = DllStructGetData($tNMTBHOTITEM, "idNew")
; Note the "hot" item
$iItem = $i_idNew
$dwFlags = DllStructGetData($tNMTBHOTITEM, "dwFlags")
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>_WM_NOTIFYYou may wonder why I went to all the trouble of using a dummy control rather then showing the MsgBox directly from the message handler - read the Help file page for GUIRegisterMsg to find out. M23