Jump to content

Print Server & Printer with now duplicate Servers


Recommended Posts

I'm trying to list out in a treeview Print Servers and Printers without haveing duplicate servers listed..

So far this way seems to work

$hItem = _GUICtrlTreeView_FindItem($TreeView2, $PrintServer, True, 0)
                If $hItem = "" Then
                    $Printserver_TreeViewItem = GUICtrlCreateTreeViewItem($PrintServer, $TreeView2) ; Never found server then add..
                    $Printer_TreeViewItem = GUICtrlCreateTreeViewItem($printer, $Printserver_TreeViewItem)
                    If $IP <> "" Then
                        $IP_TreeViewItem = GUICtrlCreateTreeViewItem("IP: " & $IP, $Printer_TreeViewItem)
                    Else
                    EndIf
                Else
                    $Printer_TreeViewItem = GUICtrlCreateTreeViewItem($printer, $Printserver_TreeViewItem)
                    If $IP <> "" Then
                        $IP_TreeViewItem = GUICtrlCreateTreeViewItem("IP: " & $IP, $Printer_TreeViewItem)
                    Else
                    EndIf
                EndIf

But I find it slow when I'm loading 200 or more printers.. How can I speed this up ??

Link to comment
Share on other sites

Try this:

_GUICtrlTreeView_BeginUpdate($TreeView2)

; ... make all your updates

_GUICtrlTreeView_EndUpdate($TreeView2)

:unsure:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Every time you change something in the TreeView control, it takes the time to redraw the control. This causes the treeview to stop repainting until you are done changing things. See help file.

:unsure:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

It would also help if you created the complete list in an array or a delimited string, then loaded the items in the TreeView in one pass without the test for duplication in the loop. De-dup and sort the list in memory away from the GUI before you load the data to the control.

:unsure:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...