Sign in to follow this  
Followers 0
Ahmed97

put same item\data in listview

6 posts in this topic

Hello :)

Is there anyway to put same itemdata in listview?

this script fails, it adds item only once!

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 298, 294, 192, 124)
$List1 = GUICtrlCreateList("", 40, 40, 161, 136)
$Button1 = GUICtrlCreateButton("Button1", 80, 184, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            GUICtrlSetData($List1, "TEST")
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites



I'm a little confused about the question. The Script works fine for me? Do you mean like this?

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 298, 294, 192, 124)
$List1 = GUICtrlCreateListView("Item1|Item2", 40, 40, 161, 136)
$Button1 = GUICtrlCreateButton("Button1", 80, 184, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            GUICtrlCreateListViewItem("Test 1|Test 2", $List1)
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites

 

I'm a little confused about the question. The Script works fine for me? Do you mean like this?

 

I mean whenever i press $button1 it adds "test" don't just replace it.

if the button adds random itemdata it will be added, but if it sends only same itemdata it just puts it 1 time.

whatever i want do this cuz i'm making script listing all opened windows let's say there's 2 WINDOWs called "Test - Notepad" & "Test - Notepad" too

to list these 2 windows i need to get their handle and add them to the listview and it works.

but what about listing it with their names?? 

here's the problem ^_^

hope u understand me.

Share this post


Link to post
Share on other sites

Try this:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 298, 294, 192, 124)
$List1 = GUICtrlCreateList("", 40, 40, 161, 136)
$Button1 = GUICtrlCreateButton("Button1", 80, 184, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Global $sValue
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            $sValue &= GUICtrlRead($List1) & "|Test"
            GUICtrlSetData($List1, $sValue)
    EndSwitch
WEnd

I would use _GUICtrlListView* instead.

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Try this:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 298, 294, 192, 124)
$List1 = GUICtrlCreateList("", 40, 40, 161, 136)
$Button1 = GUICtrlCreateButton("Button1", 80, 184, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Global $sValue
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            $sValue &= GUICtrlRead($List1) & "|Test"
            GUICtrlSetData($List1, $sValue)
    EndSwitch
WEnd

I would use _GUICtrlListView* instead.

Br,

UEZ

 

Thanks UEZ it works.

another question: how to do this when listing WINDOWs with same name

this didn't work. The udf repeats the items, and the "guictrlsetdata" writes only once :S

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
#include <guilistview.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 240, 259, 192, 124)
$List1 = GUICtrlCreateList("", 16, 24, 201, 175)
;~ $list1 = _GUICtrlListView_Create($Form1, "", 16, 24, 192, 124,  $LVS_LIST)
$Button1 = GUICtrlCreateButton("Show all Notepad Win", 48, 208, 131, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
FirstCheck()
    EndSwitch
WEnd


Func FirstCheck()
    GUICtrlSetData($List1, "")
    $Wins = WinList("[CLASS:Notepad]")
    For $i = 1 To $Wins[0][0]
        GUICtrlSetData($List1, "|"&$Wins[$i][0], 1)
;~      _GUICtrlListView_AddItem($List1, $Wins[$i][0])
    Next
EndFunc   ;==>FirstCheck

Another thing and sorry for annoying

can i put some data in an item in the listview?

e.g. "item1 in listview if i read it, it returns some values"

why am i asking this, because the above code i want every WindowName showed in list holds it's "handle" is this possible?

Share this post


Link to post
Share on other sites

Here we go:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
#include <GUIListview.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 240, 259, 192, 124)
$List1 = GUICtrlCreateListView("Windows Name|Handle", 16, 24, 201, 175)
$hList1 = GUICtrlGetHandle($List1)
$Button1 = GUICtrlCreateButton("Show all Notepad Win", 48, 208, 131, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            FirstCheck()
    EndSwitch
WEnd


Func FirstCheck()
    $Wins = WinList("[CLASS:Notepad]")
    For $i = 1 To $Wins[0][0]
        _GUICtrlListView_AddItem($hList1, $Wins[$i][0])
        _GUICtrlListView_AddSubItem($hList1, $i - 1, $Wins[$i][1], 1)
    Next
EndFunc   ;==>FirstCheck

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

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