VB Code:
Dim strKEy As String Dim RemoteHost As String Private Sub Form_Load() Dim x Dim PCName As String Dim Command As String Dim Msg As String Dim i As Integer ' Declarations Dim intIDX As Integer ' Get List of Computers on Network (Type All: Server and Workstation) ServerList = EnumServer(SRV_TYPE_ALL) ' Loop through all the computers and add them to the treeview If ServerList.Init Then Dim rt As Node Dim ch As Node Dim strServer As String Dim t Set rt = TreeView1.Nodes.Add(, , "rootnode", "Sistem Kawalan Makmal") For intIDX = 1 To UBound(ServerList.List) strServer = ServerList.List(intIDX).ServerName t = strServer & intIDX Set ch = TreeView1.Nodes.Add(rt, tvwChild, t, strServer) rt.Expanded = True Next End If TreeView1.Nodes(1).Selected = True strKEy = TreeView1.SelectedItem.Key End Sub Private Sub TreeView1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single) Dim str If strKEy <> "" Then If TreeView1.Nodes(strKEy).Parent Is Nothing Then If Button = 2 Then ' if the mousebutton 2 is pressed (right) PopupMenu Rclick ' then it calls the menu which is hidden to be shown at the cordinates of the mousepointer (x,y) Else Button = 1 RemoteHost = TreeView1.Nodes(strKEy).Text sckControlPanel.RemoteHost = RemoteHost sckControlPanel.RemotePort = 8005 sckControlPanel.Connect MsgBox (" " & TreeView1.Nodes(strKEy).Text) End If End If Else sckControlPanel.Close Call sckControlPanel_Close End If Data1.Refresh End Sub
Hai you guys, the above are the code to generate connected computer on the same network and displaying it in treeview. The problem here is the left click can't seem to function. I have tried putting a MsgBox at the button 1 to see what is it displaying when i click on the node and no matter what i click it will only display the root node name. This mean that i can't select the other computer name so it can't connect to the other computer.
RemoteHost = TreeView1.Nodes(strKEy).Text
Is there something wrong with this line. Can someone tell me what is wrong? Thanks in advanced




Reply With Quote