I'm trying to get tooltips to show for the toolbar buttons and I just can't seem to get them to work along with the other code. What am I doing wrong here?
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <GuiImageList.au3>
;#include <ImageListConstants.au3>
#include <GuiToolbar.au3>
;#include <GuiReBar.au3>
#include <ListViewConstants.au3>
#include <ToolbarConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPIConstants.au3>
#include <GuiMenu.au3>
#include <GuiListView.au3>
#include <GuiToolTip.au3>
Global Enum $savebtn = 3000, $newbtn
$frmMain = GUICreate("frmMain", 839, 508, 192, 124, BitOR($GUI_SS_DEFAULT_GUI,$WS_MAXIMIZEBOX,$WS_SIZEBOX,$WS_THICKFRAME,$WS_TABSTOP))
$menu_File = GUICtrlCreateMenu("&File")
$menu_Exit = GUICtrlCreateMenuItem("E&xit", $menu_File)
$ImageList1 = _GUIImageList_Create(32, 32, 5)
_GUIImageList_AddIcon($ImageList1, "C:\Windows\System32\shell32.dll", 258, True)
_GUIImageList_AddIcon($ImageList1, "C:\Windows\System32\imageres.dll", 2, True)
$tbMain = _GUICtrlToolbar_Create($frmMain)
_GUICtrlToolbar_SetExtendedStyle($tbMain, $TBSTYLE_EX_DRAWDDARROWS)
_GUICtrlToolbar_SetImageList($tbMain, $ImageList1)
_GUICtrlToolbar_AddButton($tbMain, $savebtn, 0, 0)
_GUICtrlToolbar_AddButton($tbMain, $newbtn, 1, 0, $BTNS_DROPDOWN)
$sbMain = _GUICtrlStatusBar_Create($frmMain)
Dim $sbMain_PartsWidth[5] = [125, 325, 525, 650, -1]
$ListView1 = GUICtrlCreateListView("COL1|COL2|COL3|", 1, 46, 834, 414)
GUICtrlSetResizing(-1, $GUI_DOCKLEFT+$GUI_DOCKRIGHT+$GUI_DOCKTOP+$GUI_DOCKBOTTOM)
GUICtrlCreateListViewItem("COL1ROW1|COL2ROW1|COL3ROW1", $ListView1)
GUICtrlCreateListViewItem("COL1ROW2|COL2ROW2|COL3ROW2", $ListView1)
GUICtrlCreateListViewItem("COL1ROW3|COL2ROW3|COL3ROW3", $ListView1)
GUICtrlCreateListViewItem("COL1ROW4|COL2ROW4|COL3ROW4", $ListView1)
; Create ToolTip
$hToolTip = _GUIToolTip_Create($tbMain)
_GUICtrlToolbar_SetToolTips($tbMain, $hToolTip)
Opt("GUIOnEventMode", 1) ;// Change to OnEvent mode
Opt("GUICloseOnEsc", 0) ;//esc key does not close windows
OnAutoItExitRegister("OnAutoItExit") ;//on autoit script exit, call this function
GUISetOnEvent($GUI_EVENT_CLOSE, "Event_closeApplication",$frmMain)
GUIRegisterMsg($WM_SIZE, "WM_SIZE")
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
GUISetState(@SW_SHOW, $frmMain)
While 1
Sleep(10) ; Sleep to reduce CPU usage
WEnd
Func WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam)
_GUICtrlStatusBar_Resize($sbMain) ;auto size statusbar
_WinAPI_MoveWindow($tbMain, 0, 0 , 0, 0) ;auto size toolbar
Return $GUI_RUNDEFMSG
EndFunc ;==>MY_WM_SIZE
Func Event_closeApplication()
Switch @GUI_WinHandle
Case $frmMain
local $doclose = MsgBox(BitOR($MB_ICONWARNING,$MB_YESNO,$MB_TASKMODAL), "Close Application", "You are about to close this application! Are you sure you want to do this?")
Switch $doclose
case $IDYES ;clicked yes
Exit
case $IDNO ;clicked no
;do nothing, the application continues to run.
EndSwitch
;Case $frmAsset
; GUISetState(@SW_HIDE,$frmAsset)
; GUISetState(@SW_ENABLE, $frmMain)
; WinActivate($frmMain)
EndSwitch
EndFunc
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
Local $hWndFrom, $iCode, $tNMHDR, $hWndListView
$hWndListView = $ListView1
If Not IsHWnd($ListView1) Then $hWndListView = GUICtrlGetHandle($ListView1)
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndListView
Switch $iCode
Case $NM_CLICK
;ConsoleWrite("Left click")
Case $NM_DBLCLK
ConsoleWrite("Double left click" & _GUICtrlListView_GetItemText ( $hWndFrom, _GUICtrlListView_GetSelectedIndices($ListView1),0))
Case $NM_RDBLCLK
;ConsoleWrite("Double right click")
Case $NM_RCLICK
ConsoleWrite("right click")
;ListView_RClick()
Return 0
Case $LVN_COLUMNCLICK ; A column was clicked
Local $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
ConsoleWrite("Sort LV")
EndSwitch
Case $tbMain
;ConsoleWrite("FROM: " & $icode & @CRLF)
Switch $iCode
Case $TBN_DROPDOWN
ConsoleWrite("button drop down")
Case $TTN_GETDISPINFO
$tInfo = DllStructCreate($tagNMTTDISPINFO, $ilParam)
ConsoleWrite("Set Tooltips")
$iID = DllStructGetData($tInfo, "IDFrom")
Switch $iID
Case $savebtn
DllStructSetData($tInfo, "aText", "Save")
Case $newbtn
DllStructSetData($tInfo, "aText", "New")
EndSwitch
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
Func OnAutoItExit() ;function runs when the application is closing. Event_closeApplication() runs first.
;do application cleanup
EndFunc ;==>OnAutoItExit