Jump to content

listview add delete items?


Recommended Posts

I wanted to know how to make a listview so i have 2 buttons (add)(delete) so that when i click add i can add a exe to the list and delete deletes the selected. also i want to add a button to read the line that the exe is on then run the program. Is there away to read it with out clicking it?

Link to comment
Share on other sites

_GUICtrlListView_AddItem

_GUICtrlListView_AddSubItem

_GUICtrlListView_DeleteColumn

_GUICtrlListView_DeleteItem

_GUICtrlListView_DeleteItemsSelected

_GUICtrlListView_GetItemSelected

_GUICtrlListView_GetItemText

As you see there ar alot of commands (probably more in the help file) for you to see and test the best one that suits you.

also i want to add a button to read the line that the exe is on then run the program. Is there away to read it with out clicking it?

can you one more time explain this sentence, sry but i dont understand what you need :/

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

Hi,

It's quick and very dirty because I had little time, so I did some cut and past from the help file. If you double click on a item it will show you a msgbox, just replace this with Run or RunAs, ec....

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=
$frm_Example1 = GUICreate("Example", 413, 266, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "frm_Example1Close")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "frm_Example1Minimize")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "frm_Example1Maximize")
GUISetOnEvent($GUI_EVENT_RESTORE, "frm_Example1Restore")
$List1 = _GUICtrlListBox_Create($frm_Example1,"", 8, 8, 393, 214)

$btn_Add = GUICtrlCreateButton("Add", 8, 232, 73, 25, $WS_GROUP)
GUICtrlSetOnEvent(-1, "btn_AddClick")
$btn_Remove = GUICtrlCreateButton("Remove", 88, 232, 73, 25, $WS_GROUP)
GUICtrlSetOnEvent(-1, "btn_RemoveClick")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")


While 1
    Sleep(100)
WEnd

Func btn_AddClick()
    $sFileToAdd = FileOpenDialog("Select File","c:\","All (*.*)")
    _GUICtrlListBox_AddString($List1, $sFileToAdd)
EndFunc
Func btn_RemoveClick()
    _GUICtrlListBox_DeleteString($List1,_GUICtrlListBox_GetCaretIndex($List1))
EndFunc
Func frm_Example1Close()
    Exit
EndFunc
Func frm_Example1Maximize()

EndFunc
Func frm_Example1Minimize()

EndFunc
Func frm_Example1Restore()

EndFunc

Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg
    Local $hWndFrom, $iIDFrom, $iCode, $hWndListBox
    If Not IsHWnd($List1) Then $hWndListBox = GUICtrlGetHandle($List1)
    $hWndFrom = $ilParam
    $iIDFrom = BitAND($iwParam, 0xFFFF) ; Low Word
    $iCode = BitShift($iwParam, 16) ; Hi Word

    Switch $hWndFrom
        Case $List1, $hWndListBox
            Switch $iCode
                Case $LBN_DBLCLK ; Sent when the user double-clicks a string in a list box
                   msgbox(0,"Selected data",_GUICtrlListBox_GetText($list1,_GUICtrlListBox_GetCaretIndex($List1)))
            EndSwitch
    EndSwitch
    ; Proceed the default Autoit3 internal message commands.
    ; You also can complete let the line out.
    ; !!! But only 'Return' (without any value) will not proceed
    ; the default Autoit3-message in the future !!!
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

Bye,

Tim

p.s. i used a listbox, but you can do the same thing with a listview of course :D

Link to comment
Share on other sites

_GUICtrlListView_AddItem

_GUICtrlListView_AddSubItem

_GUICtrlListView_DeleteColumn

_GUICtrlListView_DeleteItem

_GUICtrlListView_DeleteItemsSelected

_GUICtrlListView_GetItemSelected

_GUICtrlListView_GetItemText

As you see there ar alot of commands (probably more in the help file) for you to see and test the best one that suits you.

can you one more time explain this sentence, sry but i dont understand what you need :/

i mean i want to have a launch button so it will read the lictview line then launch the program

Link to comment
Share on other sites

Hi,

It's quick and very dirty because I had little time, so I did some cut and past from the help file. If you double click on a item it will show you a msgbox, just replace this with Run or RunAs, ec....

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=
$frm_Example1 = GUICreate("Example", 413, 266, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "frm_Example1Close")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "frm_Example1Minimize")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "frm_Example1Maximize")
GUISetOnEvent($GUI_EVENT_RESTORE, "frm_Example1Restore")
$List1 = _GUICtrlListBox_Create($frm_Example1,"", 8, 8, 393, 214)

$btn_Add = GUICtrlCreateButton("Add", 8, 232, 73, 25, $WS_GROUP)
GUICtrlSetOnEvent(-1, "btn_AddClick")
$btn_Remove = GUICtrlCreateButton("Remove", 88, 232, 73, 25, $WS_GROUP)
GUICtrlSetOnEvent(-1, "btn_RemoveClick")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")


While 1
    Sleep(100)
WEnd

Func btn_AddClick()
    $sFileToAdd = FileOpenDialog("Select File","c:\","All (*.*)")
    _GUICtrlListBox_AddString($List1, $sFileToAdd)
EndFunc
Func btn_RemoveClick()
    _GUICtrlListBox_DeleteString($List1,_GUICtrlListBox_GetCaretIndex($List1))
EndFunc
Func frm_Example1Close()
    Exit
EndFunc
Func frm_Example1Maximize()

EndFunc
Func frm_Example1Minimize()

EndFunc
Func frm_Example1Restore()

EndFunc

Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg
    Local $hWndFrom, $iIDFrom, $iCode, $hWndListBox
    If Not IsHWnd($List1) Then $hWndListBox = GUICtrlGetHandle($List1)
    $hWndFrom = $ilParam
    $iIDFrom = BitAND($iwParam, 0xFFFF) ; Low Word
    $iCode = BitShift($iwParam, 16) ; Hi Word

    Switch $hWndFrom
        Case $List1, $hWndListBox
            Switch $iCode
                Case $LBN_DBLCLK ; Sent when the user double-clicks a string in a list box
                   msgbox(0,"Selected data",_GUICtrlListBox_GetText($list1,_GUICtrlListBox_GetCaretIndex($List1)))
            EndSwitch
    EndSwitch
    ; Proceed the default Autoit3 internal message commands.
    ; You also can complete let the line out.
    ; !!! But only 'Return' (without any value) will not proceed
    ; the default Autoit3-message in the future !!!
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

Bye,

Tim

p.s. i used a listbox, but you can do the same thing with a listview of course :D

that is kinda what i want but how would i add a launch button so it will read line2 and then launch that program.

and then another button to launch the program that is in line1 can that be done with out clicking the item u want to launch?

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...