Sign in to follow this  
Followers 0

How do I delete a Treeview child?

17 posts in this topic

#1 ·  Posted

Like the title says. how can I delete a single TreeView child??Or do I have to redraw the treeview without that item cause that would be a stupid workaround...


s!mpL3 LAN Messenger

Current version 2.9.8.6 [04/11/2014]

Download Here

s!mpL3

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

BUMP...nobody knows if it's possible?????????????

Edited by AoRaToS

s!mpL3 LAN Messenger

Current version 2.9.8.6 [04/11/2014]

Download Here

s!mpL3

Share this post


Link to post
Share on other sites

#3 ·  Posted

Just a hint. One search for TreeView in the help file and what do you get on line 10, 11 and 12?

It's even a nice little sample for you to try out in there. So how f** hard can it be? People spent real time to provide you with a state of the art help file but do you bother to look in it? That is showing disrespect, shame on you!

Now, if the sample does not work, that's another story. but then you should let us know and post some sample code demonstrating your problem.

;) Uten

PS: I know some of the TreeView samples don't work on w2k without some simple tweaking.

Share this post


Link to post
Share on other sites

#4 ·  Posted

I can't see anything that will delete a treeview child, only a udf tha deletes all the children,enlighten me


s!mpL3 LAN Messenger

Current version 2.9.8.6 [04/11/2014]

Download Here

s!mpL3

Share this post


Link to post
Share on other sites

#5 ·  Posted

_GUICtrlTreeView_Delete: Removes an item and all its children

You want to remove the item but not the children without moving them?

Share this post


Link to post
Share on other sites

#6 ·  Posted

This is probably more like it for you: _GUICtrlTreeView_DeleteChildren : Deletes all children of a item

Line 12 as I pointed you to in my first post.

Share this post


Link to post
Share on other sites

#7 ·  Posted

And when I think of it. A children is an item? So _GUICtrlTreeView_Delete should work on children as an item to?

Share this post


Link to post
Share on other sites

#8 ·  Posted

I want to remove one single Child from an item

ITEM

--->child1

--->child2

How can I delete child 2?


s!mpL3 LAN Messenger

Current version 2.9.8.6 [04/11/2014]

Download Here

s!mpL3

Share this post


Link to post
Share on other sites

#9 ·  Posted

Get the handle of the child and modify the helpfile sample

$child = _GUICtrlTreeView_AddChild($hTreeView, $hItem, StringFormat("[%02d] New Child", $y), $iImage, $iImage)
        Next
    Next
    _GUICtrlTreeView_EndUpdate($hTreeView)oÝ÷ Ù«­¢+Ø$$%5Í   ½à ÐÄØÀ°ÅÕ½Ðí%¹½ÉµÑ¥½¸ÅÕ½Ðì°ÅÕ½Ðí±ÑÅÕ½ÐìµÀìMÑÉ¥¹½ÉµÐ ÅÕ½ÐílÀÉt9Ü%Ñ´ÅÕ½Ðì°ÀÌØíà´Ä¤µÀìÅÕ½Ðì´´ØÈìÅÕ½ÐìµÀìMÑÉ¥¹½ÉµÐ ÅÕ½ÐílÀÉt9Ü
¡¥±ÅÕ½Ðì°ÀÌØíä´Ä¤¤($$%}U%
ÑɱQÉY¥Ý}±Ñ ÀÌØí¡QÉY¥Ü°ÀÌØí¡¥±

Share this post


Link to post
Share on other sites

#10 ·  Posted

I want to remove one single Child from an item

ITEM

--->child1

--->child2

How can I delete child 2?

Look at:

_GUICtrlTreeView_GetFirstItem

_GUICtrlTreeView_GetFirstChild

_GUICtrlTreeView_GetNextSibling

_GUICtrlTreeView_Delete

Share this post


Link to post
Share on other sites

#11 ·  Posted

OMG! RTFM mate, you're getting brilliant help, yet you ain't trying one bit!

So here you go. Your answer. Plucked it ALL from in the example in the help file that Uten mentioned. Amazing aint it?

#include <GUIConstants.au3>
#Include <GuiTreeView.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("AForm1", 183, 175, 193, 115)
$hTreeView = GUICtrlCreateTreeView(8, 8, 169, 129)
$parent_1 = _GUICtrlTreeView_Add($hTreeView, 0, "Parent 1")
$parent_2 = _GUICtrlTreeView_Add($hTreeView, 0, "Parent 2")

$child_1_1 = _GUICtrlTreeView_AddChild($hTreeView, $parent_1, "Child 1")
$child_1_2 = _GUICtrlTreeView_AddChild($hTreeView, $parent_1, "Child 2")
$child_1_3 = _GUICtrlTreeView_AddChild($hTreeView, $parent_1, "Child 3")

$child_2_1 = _GUICtrlTreeView_AddChild($hTreeView, $parent_2, "Child 4")
$child_2_2 = _GUICtrlTreeView_AddChild($hTreeView, $parent_2, "Child 4")
$child_2_2_1 = _GUICtrlTreeView_AddChild($hTreeView, $child_2_2, "Child 5")


$Button1 = GUICtrlCreateButton("Exit", 16, 144, 75, 25, 0)
$Button2 = GUICtrlCreateButton("Delete Child 3", 96, 144, 75, 25, 0)
_GUICtrlTreeView_Expand($hTreeView)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            Exit
        Case $Button2
            $ret = _GUICtrlTreeView_Delete ($hTreeView, $child_1_3)
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites

#12 ·  Posted

I don't think that'll work, even if it does, that's adding a child and deleting in, I want to search for achild ad delete it, how hard can it be?nothing seems to work


s!mpL3 LAN Messenger

Current version 2.9.8.6 [04/11/2014]

Download Here

s!mpL3

Share this post


Link to post
Share on other sites

#13 ·  Posted

Start from the beginning. What exactly do you want to achieve. Add lots of detail and pictures. Then we can help. Cause this is going nowhere.

Cheers,

Brett

Share this post


Link to post
Share on other sites

#14 ·  Posted

I don't think that'll work, even if it does, that's adding a child and deleting in, I want to search for achild ad delete it, how hard can it be?nothing seems to work

Adding new information proving that you did not look to hard in the help file does not help much.

And *ROLF* Your new question is already answered above:D

I'm sorry I'm just in that mood this morning..;)

Share this post


Link to post
Share on other sites

#15 ·  Posted

Ok my friend, that's more like help, take a look at my script:

#include <GuiConstantsEx.au3>
#include <GuiTreeView.au3>
#include <GuiImageList.au3>
#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <TreeViewConstants.au3>
#include <StaticConstants.au3>
#include <String.au3>

Opt("GUIOnEventMode",1)
Opt("TrayMenuMode",1)
TraySetIcon("Shell32.dll",16)

Global $LANTree, $Online, $NETVIEW
Global $PrivateIP = @IPAddress1
Global $serversocket = 0
Global $signonclientip, $contactcast, $changeaddress, $contactdata

MainGUI()
Contacts()
;Messenger()

Func Messenger()
    UDPStartup()
    $chatserver = UDPBind($PrivateIP, 65333)
    TrayTip("", "LAN Talk: " & @ComputerName & "(" & $PrivateIP & ")", 5)
    Sleep(3000)
    If @error <> 0 Then
        TrayTip("", @error, 10)
        Call ("OnExit")
    Else
        While 1
            $data = UDPRecv($chatserver, 5000)
            If $data <> "" Then
                MsgBox(0,"a",$data)
            EndIf
            sleep(100)
        WEnd
    EndIf
EndFunc

Func Contacts()
;start contact server
    UDPStartup()
    $contactserver = UDPBind($PrivateIP, 65335)
    TrayTip("", "LAN Talk: " & @ComputerName & "(" & $PrivateIP & ")", 5)
    Sleep(500)
;create multicast address
    $splitaddress = StringSplit($PrivateIP, ".")
    $changeaddress = $splitaddress[1] & "." & $splitaddress[2] & "." & $splitaddress[3] & "." & "255"
;send packet
    $contactcast = UDPOpen($changeaddress, 65335)
    UDPSend($contactcast, "SIGN-ON" & $PrivateIP & "|" & @ComputerName)
    UDPCloseSocket($contactcast)
    While 1
        $contactdata = UDPRecv($contactserver, 50)
        If $contactdata <> "" Then
            If StringLeft($contactdata,7) = "SIGN-ON" Then
                $signonclientipname = StringMid($contactdata, 8)
                $signonclient = StringSplit($signonclientipname, "|")
                $signonclientip = $signonclient[1]
                $signonclientname = $signonclient[2]
                $signonclientid = $signonclientname & " - " & $signonclientip
                If $signonclientip <> $PrivateIP Then
                    $signonsearchclient = _GUICtrlTreeView_FindItem($NETVIEW,$signonclientid)
                    If $signonsearchclient = 0 Then
                        GUICtrlCreateTreeViewItem($signonclientid, $NETVIEW)
                        GUICtrlSetState($NETVIEW, BitOR($GUI_EXPAND, $GUI_DEFBUTTON))
                    ;Call("Clientmsg")
                    EndIf
                EndIf
            EndIf
            If StringLeft($contactdata,8) = "SIGN-OFF" Then
                $signoffclientipname = StringMid($contactdata, 9)
                $signoffclient = StringSplit($signoffclientipname, "|")
                $signoffclientip = $signoffclient[1]
                $signoffclientname = $signoffclient[2]
                $signoffclientid = $signoffclientname & " - " & $signoffclientip
                MsgBox(0,".",$signoffclientid)
                $signoffsearchclient = _GUICtrlTreeView_FindItem($NETVIEW,$signoffclientid)
                If $signoffsearchclient Then
                    MsgBox(0,".",$signoffsearchclient)
                    _GUICtrlTreeView_Delete($NETVIEW,$signoffsearchclient)
                EndIf
            EndIf
        EndIf
        Sleep(100)
    WEnd
EndFunc

Func MainGUI()
    GUICreate("LAN Talk", 204, 404)
    $LANTree = GUICtrlCreateTreeView(2, 2, 200, 400, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
    $NETVIEW = GUICtrlCreateTreeViewItem("Local Network", $LANTree)
    GUISetOnEvent($GUI_EVENT_CLOSE,"OnExit")
    GUICtrlSetColor(-1, 0x0000C0)
    GUICtrlSetState($NETVIEW, BitOR($GUI_EXPAND, $GUI_DEFBUTTON))
    GUISetState()
EndFunc

Func OnExit()
    $sign_off = UDPOpen($changeaddress, 65335)
    UDPSend($sign_off, "SIGN-OFF" & $PrivateIP & "|" & @ComputerName)
    UDPCloseSocket($sign_off)
    GUIDelete($LANTree)
    Exit
EndFunc

While 1
    Sleep(100)
WEnd

Check this out:

_GUICtrlTreeView_Delete($NETVIEW,$signoffsearchclient)

I want to delete the one that sends SIGN-OFF...I've tried allot of things :/


s!mpL3 LAN Messenger

Current version 2.9.8.6 [04/11/2014]

Download Here

s!mpL3

Share this post


Link to post
Share on other sites

#16 ·  Posted

There is no way I can check this code as it requires a setup I don't have (you did not provide it)!

As I'm int that mode and your utterly, sorry to say this, stupid way of starting, bumping and replies this topic there is no way I will provide a working sample.

Post a modified helpfile sample that proves you have tried it. Helpfile sample + the code I posted above should give plenty of clues as that is how I did try it..;)

You may have to change the *AddIcon stuff to

Local $offset=0
    _GUIImageList_AddIcon($hImage, "shell32.dll", $offset + 10)
    _GUIImageList_AddIcon($hImage, "shell32.dll", $offset + 31)
    _GUIImageList_AddIcon($hImage, "shell32.dll", $offset + 65)
    _GUIImageList_AddIcon($hImage, "shell32.dll", $offset + 68)
    _GUIImageList_AddIcon($hImage, "shell32.dll", $offset + 37)
    _GUIImageList_AddIcon($hImage, "shell32.dll", $offset + 46)
to get it going. Depends on the OS, I don't know.

Share this post


Link to post
Share on other sites

#17 ·  Posted

You shouldn't be talking like that, the support forum is for asking and providing help not for making people feel stupid cause they didn't specify exactly.you can see the problem without having to have a local network, I believe the treeview find doesn't return the handle correctly and I can't see why, I'll try and find the solution by myself and post soon...


s!mpL3 LAN Messenger

Current version 2.9.8.6 [04/11/2014]

Download Here

s!mpL3

Share this post


Link to post
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
Sign in to follow this  
Followers 0