Jump to content

LividCode

Members
  • Posts

    3
  • Joined

  • Last visited

Everything posted by LividCode

  1. 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
  2. Eh? LOL Sorry, for being stupid. I was having a moment apparently. Thanks.
  3. I am trying to figure out how to detect if a user clicks the button for a toolbar item or the dropdown arrow of the button and which button/dropdown it was. If the drop down arrow was clicked I am wanting to show a menu. All the examples i seem to find for the toolbar don't show whether the bottom alone was clicked or the drop down arrow. Also They all seem to do the events on BUTTONDOWN. I want to use Button UP. Any Help would be great. Thanks #include #include #include #include #include #include #include #include GUIRegisterMsg($WM_LBUTTONUP, "_WM_LBUTTONUP") Global $hLeftClick _Main() Func _Main() _CreateMainGUI() GUISetState() ; display the GUI While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $hLeftClick ; Our dummy control clicked MsgBox(0, "Click", "LEFT CLICK!") EndSwitch WEnd EndFunc Func _CreateMainGUI() $mainFrm = GUICreate("Test", 623, 150, 192, 124, BitOR($GUI_SS_DEFAULT_GUI,$WS_MAXIMIZEBOX,$WS_SIZEBOX,$WS_THICKFRAME,$WS_TABSTOP)) ;Create GUI form GUISetIcon(@ScriptDir & "\resources\1364868664_60322.ico", -1) $hToolbar = _GUICtrlToolbar_Create($mainFrm, $TBSTYLE_FLAT) $aSize = _GUICtrlToolbar_GetMaxSize($hToolbar) _GUICtrlToolbar_SetExtendedStyle($hToolbar, $TBSTYLE_EX_DRAWDDARROWS) ;add images for toolbar Global $hImage = _GUIImageList_Create(32, 32, 5) _GUIImageList_AddIcon($hImage, @ScriptDir & "\resources\explorer.ico", 0, True) _GUIImageList_AddIcon($hImage, @ScriptDir & "\resources\cmd.ico", 0, True) _GUICtrlToolbar_SetImageList($hToolbar, $hImage) ;Assign the image list to toolbar ;setup button text $explorer_button_txt = _GUICtrlToolbar_AddString($hToolbar, "Explorer") $cmd_button_txt = _GUICtrlToolbar_AddString($hToolbar, "Command Prompt") ;add toolbar buttons _GUICtrlToolbar_AddButton($hToolbar, 1000, 0, $explorer_button_txt, $BTNS_DROPDOWN) _GUICtrlToolbar_AddButton($hToolbar, 1001, 1, $cmd_button_txt, $BTNS_DROPDOWN) ; Create a dummy control for the handler to action $hLeftClick = GUICtrlCreateDummy() EndFunc Func _WM_LBUTTONUP($hWnd, $iMsg, $wParam, $lParam) ; Action the dummy control GUICtrlSendToDummy($hLeftClick) EndFunc
×
×
  • Create New...