Sign in to follow this  
Followers 0
Rawox

ListView Problems

3 posts in this topic

Hey,,

I have two listviews ($Listau3 and $Listexe) and an inputbox ($SelectedScript). My script lets the user select a folder and the au3 files are loaded in the first listview and the exes are loaded in the other listview. If a user selects a script in one of the listviews the name must be in the inputbox ($SelectedScrupt).

The problem is when I click an au3 file and after that I select an executable and then an au3 again it still displays the executable I selected earlier... Is there any way how I can fix this?

If GUICtrlRead ( $Listau3 ) > 0 Then
    $Readau3 = GUICtrlRead ( GUICtrlRead ( $Listau3 ) )
    $Readau3r = StringSplit ( $Readau3, "|" )
    GUICtrlSetData ( $SelectedScript, $Readau3r[1] )
EndIf
If GUICtrlRead ( $Listexe ) > 0 Then
    $Readexe = GUICtrlRead ( GUICtrlRead ( $Listexe ) )
    $Readexer = StringSplit ( $Readexe, "|" )
    GUICtrlSetData ( $SelectedScript, $Readexer[1] )
EndIf

Share this post


Link to post
Share on other sites



Does no-one has the answer? I already tried everything :D

Share this post


Link to post
Share on other sites

Rawox,

Your problem is that the 2 If sections are both run each time - so once you have selected something in the .exe list, GUICtrlRead ( $Listexe ) > 0 is always true and your script will always set the value of the Input to the value of the .exe list, even if it had just been set to the value of the .au3 list.

You need to find out which list was last actioned - ControlGetFocus is one way of doing that. Here is some code to play with - it works perfectly for me:

#include <GUIConstantsEx.au3>
#Include <File.au3>

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

$hLB1 = GUICtrlCreateList("",  10, 10, 200, 200)
$hLB2 = GUICtrlCreateList("", 250, 10, 200, 200)

$hIB = GUICtrlCreateInput("", 10, 300, 200, 20)

GUISetState()

$aList = _FileListToArray(@ScriptDir, "*.au3", 1)
For $i = 1 To $aList[0]
    GUICtrlSetData($hLB1, $aList[$i])
Next
$aList = _FileListToArray(@ScriptDir, "*.exe", 1)
For $i = 1 To $aList[0]
    GUICtrlSetData($hLB2, $aList[$i])
Next

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

    If ControlGetFocus($hGUI) = "ListBox1" Then
        $sRead_LB = GUICtrlRead($hLB1)
        GUICtrlSetData($hIB, $sRead_LB)
    ElseIf ControlGetFocus($hGUI) = "ListBox2" Then
        $sRead_LB = GUICtrlRead($hLB2)
        GUICtrlSetData($hIB, $sRead_LB)
    EndIf

WEnd

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

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