Jump to content

Recommended Posts

Posted

I'm to stupid to get it to work!!!

it looks like i find the value but i cant delete the row from "ListViewClients"

here is the code:

Func Disconnect($hSocket, $iError); Damn, we lost a client. Time of death: @Hour & @Min & @Sec :P
local $iIT=""
   $iIT = _GUICtrlListBox_FindString($ListViewClients, $hSocket, True)
    ConsoleWrite('@@(266) :(' & @MIN & ':' & @SEC & ')' & "$iI & $hSocket " & $iIT &"-"&$hSocket& @CR) ;### Function Trace
   $fan=_GUICtrlListView_DeleteItem($ListViewClients,$iIT)
   $fan2 = _GUICtrlListView_GetItemTextString($ListViewClients, $iIT)

   ConsoleWrite('@@(266) :(' & @MIN & ':' & @SEC & ')' & "$fan " & $fan& ":"& $fan2&@CR) ;### Function Trace
    MsgBox(4160, "Deleted?", _GUICtrlListView_DeleteItem($ListViewClients, $iIT))

And here is the result:

@@(266) :(26:58)1: lgvCHA-C001192.168.123.98

@@(266) :(26:58)16443: lgv

@@(266) :(27:01)$iI & $hSocket 0-1644

@@(266) :(27:01)$fan False:lgv|CHA-C001|192.168.123.98|test|f64b3875-c942-4e0d-8535-7b8f8b89451c->CHA-C001|1644

  • Moderators
Posted

lgvlgv,

See any problem here? :graduated:

$iIT = _GUICtrlListBox_FindString($ListViewClients, $hSocket, True)

ConsoleWrite('@@(266) :(' & @MIN & ':' & @SEC & ')' & "$iI & $hSocket " & $iIT &"-"&$hSocket& @CR) ;### Function Trace

$fan=_GUICtrlListView_DeleteItem($ListViewClients,$iIT)

$fan2 = _GUICtrlListView_GetItemTextString($ListViewClients, $iIT)

What type of control are we actually dealing with here? ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted (edited)

still cant get it to work?

Func Disconnect($hSocket, $iError); Damn, we lost a client. Time of death: @Hour & @Min & @Sec :P
Local $iIT = "", $fan = "",$tInfo
$tInfo = DllStructCreate($tagLVFINDINFO)
    DllStructSetData($tInfo, "Flags", $LVFI_STRING)
    DllStructSetData($tInfo, "Text", $hSocket)
$iIT = _GUICtrlListView_FindItem($ListViewClients, -1, $tInfo,$hSocket)
ConsoleWrite('@@(266) :(' & @MIN & ':' & @SEC & ')' & "$fan " & $fan & @CR) ;### Function Trace
; Items created using built-in function, pass the control ID
$fan = _GUICtrlListView_DeleteItem($ListViewClients, $iIT)
ConsoleWrite('@@(266) :(' & @MIN & ':' & @SEC & ')' & "$fan " & $fan & @CR) ;### Function Trace
ToolTip("SERVER: Client disconnected. Socket = " & $hSocket, 10, 30); Placing a tooltip right under the tooltips of the client.
EndFunc   ;==>Disconnect

lgvlgv,

See any problem here? :graduated:

$iIT = _GUICtrlListBox_FindString($ListViewClients, $hSocket, True)

ConsoleWrite('@@(266) :(' & @MIN & ':' & @SEC & ')' & "$iI & $hSocket " & $iIT &"-"&$hSocket& @CR) ;### Function Trace

$fan=_GUICtrlListView_DeleteItem($ListViewClients,$iIT)

$fan2 = _GUICtrlListView_GetItemTextString($ListViewClients, $iIT)

What type of control are we actually dealing with here? ;)

M23

still cant get it to work? Edited by lgvlgv
  • Moderators
Posted

lgvlgv,

You are overcomplicating the code: ;)

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#Include <GuiListView.au3>

$hGUI = GUICreate("Test", 500, 500)

$hLV = GUICtrlCreateListView("Col 1", 10, 10, 200, 300)
$hLV_Handle = GUICtrlGetHandle($hLV)

For $i = 0 To 9
    GUICtrlCreateListViewItem("Item " & $i, $hLV)
Next

$hInput = GUICtrlCreateInput("", 10, 400, 200, 20)
GUICtrlSendMsg(-1, $EM_SETCUEBANNER, True, "Enter the text of the item to delete")

$hButton = GUICtrlCreateButton("Delete", 10, 450, 80, 30)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hButton
            $sText = GUICtrlRead($hInput)
            $iIndex = _GUICtrlListView_FindText($hLV_Handle, $sText)
            _GUICtrlListView_DeleteItem($hLV_Handle, $iIndex)
    EndSwitch

WEnd

You actually only need one line: :)

_GUICtrlListView_DeleteItem($hLV_Handle, _GUICtrlListView_FindText($hLV_Handle, GUICtrlRead($hInput)))

Does that help? :graduated:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

The thing is that i want the program (server part) to automatic add new connected computer to a list <---- This is ok and working.

But when they disconnects or lose connection i want them removed from the list automatic... and the thing i have to find and remove is the Item that have $socket

  • Moderators
Posted

lgvlgv,

the thing i have to find and remove is the Item that have $socket

In the snippet you posted you have this line:

DllStructSetData($tInfo, "Text", $hSocket)

So I presume you have the text of the item to find and delete stored in the variable $hsocket.

My example shows how to find and delete an item from a ListView when all you have is the text - so what is the problem? :graduated:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted (edited)

We

lgvlgv,

In the snippet you posted you have this line:

DllStructSetData($tInfo, "Text", $hSocket)

So I presume you have the text of the item to find and delete stored in the variable $hsocket.

My example shows how to find and delete an item from a ListView when all you have is the text - so what is the problem? :graduated:

M23

u have to speak to me like a 5 year old ;) or u speak over my head :)

how do i find the ITem with $socket when i search throgh hole list?

the "GUICtrlRead($hInput)" is based on input from guie or im i wrong?

_GUICtrlListView_DeleteItem($hLV_Handle, _GUICtrlListView_FindText($hLV_Handle, GUICtrlRead($hInput)))

/thx Lasse

PS. it has to be done automatic when a client disconnect, the socket are returned to me when i lose a connection all that has to be done is to delete that item that contains the socket from the list. (socket is uniq)

Edited by lgvlgv
Posted

i tryed this whit ur help but the item still remains in the list?

Func Disconnect($hSocket, $iError); Damn, we lost a client. Time of death: @Hour & @Min & @Sec :P
Local $shit = ""
; Items created using built-in function, pass the control ID
$shit= _GUICtrlListView_DeleteItem($ListViewClients, _GUICtrlListView_FindText($ListViewClients, $hSocket))
ConsoleWrite('@@(266) :(' & @MIN & ':' & @SEC & ')' & "$shit " & $shit & @CR) ;### Function Trace
ToolTip("SERVER: Client disconnected. $shit = " & $shit, 10, 30); Placing a tooltip right under the tooltips of the client.
EndFunc   ;==>Disconnect

result:

@@(266) :(57:32)1: lgvCHA-C001192.168.123.98

@@(266) :(57:32)16443: lgv

@@(266) :(57:36)$shit False

Posted

i added som console info and it turns out that

_GUICtrlListView_FindText($ListViewClients, $hSocket) returns -1 (fail)

@@(266) :(06:19)1: lgvCHA-C001192.168.123.98

@@(266) :(06:19)16443: lgv

@@(266) :(06:24)$hSocket: 1644

@@(266) :(06:24)$shit: False $shit2: -1

  • Moderators
Posted

lgvlgv,

u have to speak to me like a 5 year old

Surely not? ;)

OK, a couple of questions: :graduated:

- 1. Is $hsocket the text we are tring to find?

- 2. If it is the text, is the value in the first column of the ListView?

Now try and run this to see if we can locate the problem:

Func Disconnect($hSocket, $iError); Damn, we lost a client. Time of death: @Hour & @Min & @Sec :P
Local $shit = ""
; Items created using built-in function, pass the control ID
Local $iIndex = _GUICtrlListView_FindText($ListViewClients, $hSocket)
$shit &= "Index = " & $iIndex & " - " & _GUICtrlListView_DeleteItem($ListViewClients, $iIndex)
ConsoleWrite('@@(266) :(' & @MIN & ':' & @SEC & ')' & "$shit " & $shit & @CR) ;### Function Trace
ToolTip("SERVER: Client disconnected. $shit = " & $shit, 10, 30); Placing a tooltip right under the tooltips of the client.
EndFunc   ;==>Disconnect

Post the reslulting line from the console and we will then see if the problem is in finding the item or deleting it. :)

Be patient - we will get there in the end. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

OK, a couple of questions: :graduated:

- 1. Is $hsocket the text we are tring to find? <-------------------------------------- Yes and it reads the socket number when i type it to console..

- 2. If it is the text, is the value in the first column of the ListView?<----------- This is the last record looks like this -> $ListViewClients = GUICtrlCreateListView("UserName|ComputerName|IpAddress|Ping|PCID|Socket", 0, 40, 377, 561)

Posted

lgvlgv,

Surely not? ;)

OK, a couple of questions: :graduated:

- 1. Is $hsocket the text we are tring to find?

- 2. If it is the text, is the value in the first column of the ListView?

Now try and run this to see if we can locate the problem:

Func Disconnect($hSocket, $iError); Damn, we lost a client. Time of death: @Hour & @Min & @Sec :P
Local $shit = ""
; Items created using built-in function, pass the control ID
Local $iIndex = _GUICtrlListView_FindText($ListViewClients, $hSocket)
$shit &= "Index = " & $iIndex & " - " & _GUICtrlListView_DeleteItem($ListViewClients, $iIndex)
ConsoleWrite('@@(266) :(' & @MIN & ':' & @SEC & ')' & "$shit " & $shit & @CR) ;### Function Trace
ToolTip("SERVER: Client disconnected. $shit = " & $shit, 10, 30); Placing a tooltip right under the tooltips of the client.
EndFunc   ;==>Disconnect

Post the reslulting line from the console and we will then see if the problem is in finding the item or deleting it. :)

Be patient - we will get there in the end. ;)

M23

returns:

@@(266) :(21:06)1: lgvCHA-C001192.168.123.98

@@(266) :(21:06)16443: lgv

@@(266) :(21:09)$shit Index = -1 - False

  • Moderators
Posted

lgvlgv,

As the text we are looking for is not in the first column we need to use _GUICtrlListView_FindInText. ;)

Try this and see what you get:

Func Disconnect($hSocket, $iError); Damn, we lost a client. Time of death: @Hour & @Min & @Sec :P
Local $shit = ""
; Items created using built-in function, pass the control ID
Local $iIndex = _GUICtrlListView_FindInText($ListViewClients, $hSocket)
$shit &= "Index = " & $iIndex & " - " & _GUICtrlListView_DeleteItem($ListViewClients, $iIndex)
ConsoleWrite('@@(266) :(' & @MIN & ':' & @SEC & ')' & "$shit " & $shit & @CR) ;### Function Trace
ToolTip("SERVER: Client disconnected. $shit = " & $shit, 10, 30); Placing a tooltip right under the tooltips of the client.
EndFunc   ;==>Disconnect

I hope you are having fun! :)

M23

P.S. What are you using to create the ListView - the native GUICtrlCreateListView command or the UDF _GUICtrlListView_Create function? If the latter then use GUICtrlGetHandle($ListViewClients) in that snippet. :graduated:

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

hmm cant use the script quote?

Func Disconnect($hSocket, $iError); Damn, we lost a client. Time of death: @Hour & @Min & @Sec :graduated:

Local $shit = ""

; Items created using built-in function, pass the control ID

Local $iIndex = _GUICtrlListView_FindInText($ListViewClients, $hSocket)

$shit &= "Index = " & $iIndex & " - " & _GUICtrlListView_DeleteItem($ListViewClients, $iIndex)

ConsoleWrite('@@(266) :(' & @MIN & ':' & @SEC & ')' & "$shit " & $shit & @CR) ;### Function Trace

ToolTip("SERVER: Client disconnected. $shit = " & $shit, 10, 30); Placing a tooltip right under the tooltips of the client.

EndFunc ;==>Disconnect

@@(266) :(37:48)1: lgvCHA-C001192.168.123.98

@@(266) :(37:48)16443: lgv

@@(266) :(37:52)$shit Index = 0 - False

THIS IS HOW I ADD THE RECORD

Dim $aItems[1][6]

For $iI = 0 To UBound($aItems) - 1

$aItems[$iI][0] = $packetcount2[0]

$aItems[$iI][1] = $packetcount2[1]

$aItems[$iI][2] = $packetcount2[2]

$aItems[$iI][3] = "test"

$aItems[$iI][4] = $packetcount2[3]

$aItems[$iI][5] = $hSocket

Next

; Local $allclients = _TCP_Server_ClientList()

ConsoleWrite('@@(266) :(' & @MIN & ':' & @SEC & ')' & $allclients[1] & "3: " & $aItems[0][0] & @CR) ;### Function Trace

_GUICtrlListView_AddArray($ListViewClients, $aItems)

$packetcount2 = ""

$aItems = ""

  • Moderators
Posted

lgvlgv,

$shit Index = 0 - False

That shows that the item is being found - 0 is a valid index.

Try running this and see if it deletes rows when you enter the SubItem text:

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#Include <GuiListView.au3>

$hGUI = GUICreate("Test", 500, 500)

Global $aItems[10][2]

For $i = 0 To 9
    $aItems[$i][0] = "Item " & $i
    $aItems[$i][1] = "SubItem 1" & $i
Next

$hLV = GUICtrlCreateListView("Col 1|Col 2", 10, 10, 200, 300)
$hLV_Handle = GUICtrlGetHandle($hLV)
_GUICtrlListView_SetColumnWidth($hLV, 0, 100)
_GUICtrlListView_SetColumnWidth($hLV, 1, $LVSCW_AUTOSIZE_USEHEADER )

_GUICtrlListView_AddArray($hLV, $aItems)

$hInput = GUICtrlCreateInput("", 10, 400, 200, 20)
GUICtrlSendMsg(-1, $EM_SETCUEBANNER, True, "Enter the text of the item/subitem to delete")

$hButton = GUICtrlCreateButton("Delete", 10, 450, 80, 30)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hButton
            $sText = GUICtrlRead($hInput)
            $iIndex = _GUICtrlListView_FindInText($hLV_Handle, $sText)
            _GUICtrlListView_DeleteItem($hLV_Handle, $iIndex)
    EndSwitch

WEnd

If this script works for you then I am running out of ideas as to why your other script does not. :graduated:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

it works :graduated:

Can it have anything to do with that i stored the value as an array?

like this

Dim $aItems[1][6]

For $iI = 0 To UBound($aItems) - 1

$aItems[$iI][0] = $packetcount2[0]

$aItems[$iI][1] = $packetcount2[1]

$aItems[$iI][2] = $packetcount2[2]

$aItems[$iI][3] = "test"

$aItems[$iI][4] = $packetcount2[3]

$aItems[$iI][5] = $hSocket

Next

Local $allclients = _TCP_Server_ClientList()

ConsoleWrite('@@(266) :(' & @MIN & ':' & @SEC & ')' & $allclients[1] & "3: " & $aItems[0][0] & @CR) ;### Function Trace

_GUICtrlListView_AddArray($ListViewClients, $aItems)

$packetcount2 = ""

$aItems = ""

  • Moderators
Posted

lgvlgv,

Post your entire script so I can take a look and see if anything strikes me. :graduated:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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
×
×
  • Create New...