MacScript Posted July 26, 2014 Share Posted July 26, 2014 HI all, been looking around but have not had much luck and finding out how to add tooltips to some of my context menu options. If some one could point me in the correct direction I would appreciate it. Thanks Link to comment Share on other sites More sharing options...
LarsJ Posted July 27, 2014 Share Posted July 27, 2014 Try this:expandcollapse popup; right click on gui to bring up context Menu. ; right click on the "ok" button to bring up a controll specific context menu. #include <GUIConstantsEx.au3> #include <ButtonConstants.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> Global $MenuText, $MenuOpen, $MenuSave, $MenuInfo, $MenuAbout Example() Func Example() GUICreate("My GUI Context Menu", 300, 200) Local $contextmenu = GUICtrlCreateContextMenu() Local $newsubmenu = GUICtrlCreateMenu("new", $contextmenu) $MenuText = GUICtrlCreateMenuItem("text", $newsubmenu) $MenuOpen = GUICtrlCreateMenuItem("Open", $contextmenu) $MenuSave = GUICtrlCreateMenuItem("Save", $contextmenu) GUICtrlCreateMenuItem("", $contextmenu) ; separator $MenuInfo = GUICtrlCreateMenuItem("Info", $contextmenu) Local $button = GUICtrlCreateButton("OK", 100, 100, 70, 20) Local $buttoncontext = GUICtrlCreateContextMenu($button) $MenuAbout = GUICtrlCreateMenuItem("About button", $buttoncontext) GUIRegisterMsg( $WM_MENUSELECT, "WM_MENUSELECT" ) GUISetState(@SW_SHOW) ; Run the GUI until the dialog is closed Local $iMsg = 0 While 1 $iMsg = GUIGetMsg() If $iMsg = $GUI_EVENT_CLOSE Then ExitLoop If $iMsg = $MenuText Then MsgBox($MB_SYSTEMMODAL, "Menu Selected", 'text') If $iMsg = $MenuOpen Then MsgBox($MB_SYSTEMMODAL, "Menu Selected", 'Open') If $iMsg = $MenuSave Then MsgBox($MB_SYSTEMMODAL, "Menu Selected", 'Save') If $iMsg = $MenuInfo Then MsgBox($MB_SYSTEMMODAL, "Menu Selected", 'Info') If $iMsg = $MenuAbout Then MsgBox($MB_SYSTEMMODAL, "Menu Selected", 'About') WEnd GUIDelete() EndFunc ;==>Example Func WM_MENUSELECT( $hWnd, $iMsg, $iwParam, $ilParam ) Local $idMenu = BitAND( $iwParam, 0xFFFF ) Switch $idMenu Case $MenuText ToolTip( "Tooltip for text menu" ) Case $MenuOpen ToolTip( "Tooltip for Open menu" ) Case $MenuSave ToolTip( "Tooltip for Save menu" ) Case $MenuInfo ToolTip( "Tooltip for Info menu" ) Case $MenuAbout ToolTip( "Tooltip for About button" ) Case Else ToolTip( "" ) EndSwitch EndFunc Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
MacScript Posted July 27, 2014 Author Share Posted July 27, 2014 Thanks for your example. I noticed in the wm_menuselect function that it does not return any value does this mean that it will do the Autoit message handling or not? Also does this function only work on context menus or other type of controls? Thanks for your help. Link to comment Share on other sites More sharing options...
MacScript Posted August 1, 2014 Author Share Posted August 1, 2014 I am having one issue with this tool tip method. When one of the tooltips is up it seem to leave that tool tip visible if I do not mouse over one of the connext menu options that do not have a tooltip. So mouse over menu item with Tooltop. then just move my mouse away from the menus entirely and tool tip stays forever. Any suggestions? Link to comment Share on other sites More sharing options...
MikahS Posted August 4, 2014 Share Posted August 4, 2014 To remove a tooltip either the script must finish running or you will need to use a:ToolTip("") Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
Wingens Posted August 9, 2014 Share Posted August 9, 2014 (edited) Why not use: GUICtrlSetTip Example of how i used it: $VERSION = GUICtrlCreateLabel("Windows version:", 248, 16, 115, 17) $VERSIONLIST = GUICtrlCreateCombo("", 248, 40, 201, 25, BitOR($CBS_DROPDOWNLIST, $WS_VSCROLL)) GUICtrlSetTip($VERSIONLIST, "Choose your Windows version.") If you hover your mouse over the combomenu then i shows a little thing with the text in it. =================================================================== Update: Sorry posted this before i checked what your code did...don't know for sure if my example works for your situation... Edited August 9, 2014 by Wingens Link to comment Share on other sites More sharing options...
MacScript Posted August 10, 2014 Author Share Posted August 10, 2014 Because you can not do that command for context menus. That command is for other type of controls. Link to comment Share on other sites More sharing options...
jaja714 Posted February 3, 2022 Share Posted February 3, 2022 (edited) In 2022, the help file implies that GUICtrlSetTip works for any GUICtrlCreate...() function. Is everyone certain that GUICtrlSetTip doesn't work for GUICtrlCreateMenuItem? I know I can't get it to work ... I get a return value of 0. #include <GUIConstantsEx.au3> Example() Func Example() GUICreate("My GUI control tip") ; will create a dialog box that when displayed is centered GUICtrlCreateLabel("my label", 10, 20) GUICtrlSetTip(-1, "tip of my label") $x = GUICtrlCreateMenu("&menu") GUICtrlSetTip(-1, "menu") GUICtrlCreateMenuItem("1",$x) GUICtrlSetTip(-1, "first option") GUISetState(@SW_SHOW) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd EndFunc ;==>Example Edited February 3, 2022 by jaja714 adding code example Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now