Jump to content

Update Tooltip for button


muncherw
 Share

Recommended Posts

When I hover over a button in my Gui I want the tooltip to change based on a computername selected from a dropdown box. I've cut out a lot of the code just to give a basic idea as most of my code isn't relevant to the question so If I've left something out please let me know. I can get computer names and use them but I don't know how to change GUICtrlSetTip with this. Can someone give me a clue as to what I need to do?

$computerName=""

$Admin1Dropdown = GUICtrlCreateCombo("", 30, 34, 220, 25)
GUICtrlSetData(-1, $adm1p)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")

$Ping = GUICtrlCreateButton("Ping", 150, 75, 40, 40, $BS_ICON)
GUICtrlSetImage(-1, "\\Network\Technicians\Muncher\C$ Express\ping.ico", 1)
GUICtrlSetTip(-1, "Ping " & $computerName)
GuiCtrlCreateLabel("Ping", 156, 115)

While 1

    $id = _getDropdown()
    $computerName = GUICtrlRead($id)

   ;Somewhere in here after I get the computer name I need to update GUICtrlSetTip

Wend
Other People's Stuff:Andy Flesner's AutoIt v3: Your Quick Guide[topic="34302"]Locodarwin's ExcelCom_UDF[/topic][topic="61090"]MrCreatorR's Opera Library[/topic]
Link to comment
Share on other sites

Within the While 1 Loop, Update the button with the Button GUID rather than -1 Like so

GUICtrlSetTip($Ping, "Ping " & $computerName)

When I hover over a button in my Gui I want the tooltip to change based on a computername selected from a dropdown box. I've cut out a lot of the code just to give a basic idea as most of my code isn't relevant to the question so If I've left something out please let me know. I can get computer names and use them but I don't know how to change GUICtrlSetTip with this. Can someone give me a clue as to what I need to do?

$computerName=""

$Admin1Dropdown = GUICtrlCreateCombo("", 30, 34, 220, 25)
GUICtrlSetData(-1, $adm1p)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")

$Ping = GUICtrlCreateButton("Ping", 150, 75, 40, 40, $BS_ICON)
GUICtrlSetImage(-1, "\\Network\Technicians\Muncher\C$ Express\ping.ico", 1)
GUICtrlSetTip(-1, "Ping " & $computerName)
GuiCtrlCreateLabel("Ping", 156, 115)

While 1

    $id = _getDropdown()
    $computerName = GUICtrlRead($id)

 ;Somewhere in here after I get the computer name I need to update GUICtrlSetTip

Wend
Edited by DaRam
Link to comment
Share on other sites

Within the While 1 Loop, Update the button with the Button GUID rather than -1 Like so

GUICtrlSetTip($Ping, "Ping " & $computerName)
I tried that right after I get the computer name but it doesn't seem to work. It actually makes it so there is no tooltip at all.

While 1

    $computerName = GUICtrlRead($id)
    GUICtrlSetTip($Ping, "Ping " & $computerName)

Wend
Other People's Stuff:Andy Flesner's AutoIt v3: Your Quick Guide[topic="34302"]Locodarwin's ExcelCom_UDF[/topic][topic="61090"]MrCreatorR's Opera Library[/topic]
Link to comment
Share on other sites

You need to wait for an event (use GUIGetMsg()) and trigger the change - right now it is probably mindlessly updating.

Edit2: The change would probably be an event triggered by combo box selection/change

Edit: Or add a delay using Sleep()

I tried that right after I get the computer name but it doesn't seem to work. It actually makes it so there is no tooltip at all.

Edited by DaRam
Link to comment
Share on other sites

You need to wait for an event (use GUIGetMsg()) and trigger the change - right now it is probably mindlessly updating.

Ahhhh. OKay that did indeed work then. So this doesn't do exactly what I want then. I'm wanting the tooltip to change with whatever is currently in the dropdown otherwise my buttons only show the name after I use them. I'll go play with it some more now that you have pointed me in the correct direction. And I'll be back if I fail. Failing is a special skill of mine so I'll probably be back. :)

Thanks for your help thus far!

Other People's Stuff:Andy Flesner's AutoIt v3: Your Quick Guide[topic="34302"]Locodarwin's ExcelCom_UDF[/topic][topic="61090"]MrCreatorR's Opera Library[/topic]
Link to comment
Share on other sites

You need to wait for an event (use GUIGetMsg()) and trigger the change - right now it is probably mindlessly updating.

Edit2: The change would probably be an event triggered by combo box selection/change

Here is what I came up with:

$id = _getDropdown()
    $oldComputerName = $computerName
    $computerName = GUICtrlRead($id)
    
    if $oldComputerName <> $ComputerName then
        GUICtrlSetTip($Ping, "Ping " & $computerName)
    endif

I just couldn't figure out how to do it by checking an event. This is functional and I guess it doesn't hurt anything. Would another route be better?

Other People's Stuff:Andy Flesner's AutoIt v3: Your Quick Guide[topic="34302"]Locodarwin's ExcelCom_UDF[/topic][topic="61090"]MrCreatorR's Opera Library[/topic]
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...