Jump to content

GUICtrlCreateList


Recommended Posts

  • Moderators

Is it possible once the user clicks a row of data within the list that it will generate a response. For example allowing a button to become visable.

Sure... Have a test GUI example or do we make one ourselves for the example?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

First off sorry for posting in the wrong place.

The script i am doing is as follows

#INCLUDE <Process.au3>
#INCLUDE <File.au3>
#INCLUDE <GUIConstants.au3>
#INCLUDE <GetFileProperty.au3>
#Include <Array.au3>

dim $i,$m,$avArray[30]

; Script Start - Add your code below here

Opt("GUICoordMode",1)
$F = GuiCreate("",800,600,-1,-1,+$WS_SYSMENU);,$WS_EX_TOPMOST
    GUICtrlCreatePic ("winpe.bmp",0,0,@DesktopWidth,@DesktopHeight)
    GUICtrlSetState(-1,$GUI_DISABLE)

    GUICtrlCreateLabel("Systems Integration Image Utility",10,10,400)
    GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT) 
    GUICtrlSetFont(-1,18)

    GUICtrlCreateLabel("Please Select Customer",10,70,400)
    GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT) 
    GUICtrlSetFont(-1,12)

    $Customer = GUICtrlCreateCombo("",10,100,250,40)

    $listcust=_FileListToArray("z:\","*.")
        For $n = 1 To $listcust[0]
            $i = $i & $listcust[$n] & "|"
        NEXT    
    GUICtrlSetData($Customer,$i)
    
    $listview = GUICtrlCreateListView ("Description          | Path |  File Name                       ",10,140,500,150,$LBS_NOTIFY)

    $bn = GUICtrlCreatebutton ("image",10,340,100)
    GUICtrlSetState (-1,$GUI_HIDE)

GUISetState(@SW_SHOW,$F)

WHILE 1
    $Msg=GUIGetMsg()

    IF $Msg = $Customer THEN
            $d = 1
            While $d <= 29
                GUICtrlDelete($avArray[$d])
                $d = $d + 1
            WEnd
            LOCAL $avArray[30]
            
            $search = _FileListToArray("z:\" & GUICtrlRead($Customer) & "\images\","*.*",2)
            
            For $n = 1 To $search[0]
                $file = _FileListToArray("z:\" & GUICtrlRead($Customer) & "\images\" & $search[$n] &"\","*.*",1)

                    For $x = 1 To $file[0]
                        IF StringInStr ($file[$x],"gho") OR StringInStr ($file[$x],"PQI") THEN
                            $desc = _GetFileProperty("Z:\"& GUICtrlRead($Customer) & "\Images\" & $search[$n] & "\"& $file[$x], "Title")
                            $path = "Z:\"& GUICtrlRead($Customer) & "\Images\" & $search[$n]
                            $filename = $file[$x]
                            $avArray[$n] = GUICtrlCreateListViewItem($desc & "|" & $path & "|" & $filename,$listview)

                        ENDIF
                    Next
            Next
            [b]GUICtrlSetState ($bn,$GUI_Show)[/b]
    ENDIF

    SELECT 
        Case $msg = $GUI_EVENT_CLOSE 
            Exit
            
        EndSelect
WEnd

Currently when you choose the customer the listview is populated with the options and then the button is shown. However i would like the button to only become visable when the user selects a record within the list.

As you will probably gather i not the best programmer in the world but i try.

Link to comment
Share on other sites

GUICreate("Test GUI")
$List = GUICtrlCreateList("", 10,10,140, 60)
GUICtrlSetData($List, "Toggle Button 1|Toggle Button 2")
$Btn1 = GUICtrlCreateButton("Button 1", 10, 160, 60, 30)
GuiCtrlSetState(-1, 144)
$Btn2 = GUICtrlCreateButton("Button 2", 100, 160, 60, 30)
GUICtrlSetState(-1, 144)

GUISetState()

While 1
   $Msg = GUIGetMsg()
   Switch $Msg
      Case -3;; Same as $GUI_EVENT_CLOSE
         Exit
      Case $List
         If StringInStr(GUICtrlRead($List), "Button 1") Then
            If GUICtrlGetState($Btn1) >80 Then
               GuiCtrlSetState($Btn1, 80)
            Else
               If GUICtrlGetState($Btn1) = 80 Then GUICtrlSetState($Btn1, 144)
            EndIf
         ElseIf StringInStr(GUICtrlRead($Msg), "Button 2") Then
            If GUICtrlGetState($Btn2) >80 Then
               GuiCtrlSetState($Btn2, 80)
            Else
               If GUICtrlGetState($Btn2) = 80 Then GUICtrlSetState($Btn2, 144)
            EndIf
         EndIf
   EndSwitch
WEnd

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

I don't think so, but deciding which forum can be tricky. In this particular case the OP is asking about the response to a click or selection in a control. Is that a GUI question or a general API question? How is the OP to decide if he doesn't know the answer? Anyway, what does 'General Help and Support' mean if it doesn't cover everything? Some topics by contrast are easy to categorize such as Example Scripts, ActiveX, Bug Reports and Chat.

Another problem is that if the same question is posted in both the General and the GUI Help and support forums then the one in General is very much more likely to be answered first.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

I don't think so, but deciding which forum can be tricky. In this particular case the OP is asking about the response to a click or selection in a control. Is that a GUI question or a general API question? How is the OP to decide if he doesn't know the answer? Anyway, what does 'General Help and Support' mean if it doesn't cover everything? Some topics by contrast are easy to categorize such as Example Scripts, ActiveX, Bug Reports and Chat.

Another problem is that if the same question is posted in both the General and the GUI Help and support forums then the one in General is very much more likely to be answered first.

(Im sorry this is off-topic)

You are of course right, it is complicated, but as this problem is about clicking on a GUI, not about a "under the hood" problem that you cant "see".

But as you said the General Help goes into the GUI problems.

I am sorry I bugged you from the first, I had boring ;) I am now gone :)

Edited by LinuZ
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...