clarinets101 Posted December 21, 2015 Posted December 21, 2015 I have a utility that I wrote to assign printers from a list in an ini file to a host name, for a printer mapping utility. My issue is that as the printer list grows, sometimes it can be difficult to determine which printer is needed just based on the name. I know it's possible to have tool tips off of buttons, labels, and even the combolist dropdown button (using guictrlsettip), but what I would like to accomplish is a tooltip on one of the items in the dropdown as the mouse is hovered over it based off the location in the ini file that lists the printers. I have performed several google searches and couldn't find anything right off. Maybe I'm not searching the right terms. Please advise.ini file example:[PrinterName]Installed=Y/NLocation=Printer LocationModel=Printer ModelIP=IP AddressScript Example:#include <ButtonConstants.au3>#include <ComboConstants.au3>#include <EditConstants.au3>#include <GUIConstantsEx.au3>#include <StaticConstants.au3>#include <WindowsConstants.au3>#include <GuiComboBox.au3>$hostini=@ScriptDir&"\host.ini"$printerini=@ScriptDir&"\printers.ini"$printers=IniReadSectionNames($printerini)$string=""$aprinters=IniReadSectionNames($printerini)$sprinters=""for $i = 1 to $aprinters[0] $sprinters &= "|" & $aprinters[$i]Next$ahosts=IniReadSectionNames($hostini)$shosts=""For $j=1 To $ahosts[0] $shosts&="|"&$ahosts[$j]Next#Region ### START Koda GUI section ### Form=$Form1 = GUICreate("Host.ini", 181, 402, -1, -1)$Label1 = GUICtrlCreateLabel("Host Name:", 16, 24, 60, 17)$Label2 = GUICtrlCreateLabel("Printer 1:", 16, 80, 46, 17)$Combo6 = GUICtrlCreateCombo("", 16, 48, 145, 25, BitOR($GUI_SS_DEFAULT_COMBO,$CBS_SORT,$CBS_UPPERCASE))$Combo1 = GUICtrlCreateCombo("", 16, 104, 145, 25, BitOR($GUI_SS_DEFAULT_COMBO,$CBS_SORT))$Label3 = GUICtrlCreateLabel("Printer 2:", 16, 136, 46, 17)$Combo2 = GUICtrlCreateCombo("", 16, 160, 145, 25, BitOR($GUI_SS_DEFAULT_COMBO,$CBS_SORT))$Label4 = GUICtrlCreateLabel("Printer 3:", 16, 192, 46, 17)$Combo3 = GUICtrlCreateCombo("", 16, 216, 145, 25, BitOR($GUI_SS_DEFAULT_COMBO,$CBS_SORT))$Label5 = GUICtrlCreateLabel("Printer 4:", 16, 248, 46, 17)$Combo4 = GUICtrlCreateCombo("", 16, 272, 145, 25, BitOR($GUI_SS_DEFAULT_COMBO,$CBS_SORT))$Label6 = GUICtrlCreateLabel("Printer 5:", 16, 304, 46, 17)$Combo5 = GUICtrlCreateCombo("", 16, 328, 145, 25, BitOR($GUI_SS_DEFAULT_COMBO,$CBS_SORT))$Button1 = GUICtrlCreateButton("OK", 120, 360, 43, 25)$Button2 = GUICtrlCreateButton("Reset", 16, 360, 43, 25)$Button3 = GUICtrlCreateButton("Delete", 68, 360, 43, 25)guictrlsetdata($Combo1, $sprinters, "")guictrlsetdata($Combo2, $sprinters, "")guictrlsetdata($Combo3, $sprinters, "")guictrlsetdata($Combo4, $sprinters, "")guictrlsetdata($Combo5, $sprinters, "")guictrlsetdata($Combo6, $shosts, "")GUISetState(@SW_SHOW)#EndRegion ### END Koda GUI section ###While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Combo6 $printer1=IniRead($hostini,GUICtrlRead($Combo6),"Printer1","") $printer2=IniRead($hostini,GUICtrlRead($Combo6),"Printer2","") $printer3=IniRead($hostini,GUICtrlRead($Combo6),"Printer3","") $printer4=IniRead($hostini,GUICtrlRead($Combo6),"Printer4","") $printer5=IniRead($hostini,GUICtrlRead($Combo6),"Printer5","") GUICtrlSetData($Combo1,$printer1) If $printer2 = "" Then GUICtrlSetData($Combo2, $sprinters, "") Else GUICtrlSetData($Combo2,$printer2) EndIf If $printer3 = "" Then GUICtrlSetData($Combo3, $sprinters, "") Else GUICtrlSetData($Combo3,$printer3) EndIf If $printer4 = "" Then GUICtrlSetData($Combo4, $sprinters, "") Else GUICtrlSetData($Combo4,$printer4) EndIf If $printer5 = "" Then GUICtrlSetData($Combo5, $sprinters, "") Else GUICtrlSetData($Combo5,$printer5) EndIf Case $Button1 IniWrite($hostini,GUICtrlRead($Combo6),"Printer1",GUICtrlRead($Combo1)) IniWrite($hostini,GUICtrlRead($Combo6),"Printer2",GUICtrlRead($Combo2)) IniWrite($hostini,GUICtrlRead($Combo6),"Printer3",GUICtrlRead($Combo3)) IniWrite($hostini,GUICtrlRead($Combo6),"Printer4",GUICtrlRead($Combo4)) IniWrite($hostini,GUICtrlRead($Combo6),"Printer5",GUICtrlRead($Combo5)) $aprinters=IniReadSectionNames($printerini) $sprinters="" for $i = 1 to $aprinters[0] $sprinters &= "|" & $aprinters[$i] Next $ahosts=IniReadSectionNames($hostini) $shosts="" For $j=1 To $ahosts[0] $shosts&="|"&$ahosts[$j] Next GUICtrlSetData($Combo6,$shosts,"") GUICtrlSetData($Combo1, $sprinters, "") GUICtrlSetData($Combo2, $sprinters, "") GUICtrlSetData($Combo3, $sprinters, "") GUICtrlSetData($Combo4, $sprinters, "") GUICtrlSetData($Combo5, $sprinters, "") Case $Button2 $aprinters=IniReadSectionNames($printerini) $sprinters="" for $i = 1 to $aprinters[0] $sprinters &= "|" & $aprinters[$i] Next $ahosts=IniReadSectionNames($hostini) $shosts="" For $j=1 To $ahosts[0] $shosts&="|"&$ahosts[$j] Next GUICtrlSetData($Combo6,$shosts,"") GUICtrlSetData($Combo1, $sprinters, "") GUICtrlSetData($Combo2, $sprinters, "") GUICtrlSetData($Combo3, $sprinters, "") GUICtrlSetData($Combo4, $sprinters, "") GUICtrlSetData($Combo5, $sprinters, "") Case $Button3 $msgbox=MsgBox(52,"Remove?","Are you sure you want to remove the configuration for: "&GUICtrlRead($Combo6)&"?") If $msgbox=6 Then IniDelete($hostini,GUICtrlRead($Combo6)) $aprinters=IniReadSectionNames($printerini) $sprinters="" for $i = 1 to $aprinters[0] $sprinters &= "|" & $aprinters[$i] Next $ahosts=IniReadSectionNames($hostini) $shosts="" For $j=1 To $ahosts[0] $shosts&="|"&$ahosts[$j] Next GUICtrlSetData($Combo6,$shosts,"") GUICtrlSetData($Combo1, $sprinters, "") GUICtrlSetData($Combo2, $sprinters, "") GUICtrlSetData($Combo3, $sprinters, "") GUICtrlSetData($Combo4, $sprinters, "") GUICtrlSetData($Combo5, $sprinters, "") Else $aprinters=IniReadSectionNames($printerini) $sprinters="" for $i = 1 to $aprinters[0] $sprinters &= "|" & $aprinters[$i] Next $ahosts=IniReadSectionNames($hostini) $shosts="" For $j=1 To $ahosts[0] $shosts&="|"&$ahosts[$j] Next GUICtrlSetData($Combo6,$shosts,"") GUICtrlSetData($Combo1, $sprinters, "") GUICtrlSetData($Combo2, $sprinters, "") GUICtrlSetData($Combo3, $sprinters, "") GUICtrlSetData($Combo4, $sprinters, "") GUICtrlSetData($Combo5, $sprinters, "") EndIf EndSwitchWEnd
LarsJ Posted December 22, 2015 Posted December 22, 2015 It's hard to add tooltips to list items in the native ComboBox control. But take a look at the ComboBoxEx control and especially the example for _GUICtrlComboBoxEx_Create in the helpfile. Watch the events you get when you hover the mouse over different list items. You can add tooltip code to these events.Add a new post if you need more details. 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
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