Jump to content

GUICtrlCreateListView action on click


vickerps
 Share

Recommended Posts

Does anyone know a way to get action of say making a button visable when a user clicks on GUICtrlCreateListView. It doesn't really matter what GUICtrlCreateListViewItem they click on as long it allows the button to become visable.

#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
    ENDIF

    SELECT 
        Case $msg = $GUI_EVENT_CLOSE 
            Exit

        Case $msg = $listview 
             GUICtrlSetState ($bn,$GUI_SHOW)
    
        EndSelect
WEnd
Link to comment
Share on other sites

Don`t sure, what this that you need, but:

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>

$Gui = GUICreate("Test", 320, 220)

$hListView = _GUICtrlListView_Create($GUI, "Items|SubItems1|SubItems2", 10, 10, 300, 170, BitOR($LVS_EDITLABELS, $LVS_REPORT), $WS_EX_CLIENTEDGE)
_GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_SUBITEMIMAGES, $LVS_EX_FULLROWSELECT))

$hButton = GUICtrlCreateButton("Button", 10, 190, 60, 20)
GUICtrlSetState(-1, $GUI_HIDE)

GUISetState()

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

While 1
    $msg = GUIGetMsg()
    Switch $msg
    Case $GUI_EVENT_CLOSE
        ExitLoop
    EndSwitch
WEnd

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    Local $tNMHDR, $HwndFrom, $iCode
    
    $tNMHDR   = DllStructCreate($tagNMHDR, $ilParam)
    $HwndFrom = DllStructGetData($tNMHDR, "HwndFrom")
    $iCode    = DllStructGetData($tNMHDR, "Code")
    
    Switch $HwndFrom
    Case $hListView
        Switch $iCode
        Case $NM_CLICK
            GUICtrlSetState($hButton, $GUI_SHOW)
        EndSwitch
    EndSwitch
    
    Return $GUI_RUNDEFMSG
EndFunc
Link to comment
Share on other sites

Hi Rasim

Thanks for that at least it give me something to play with now. I was creating my list by using the standard GuiCtrlCreateList which i would perfer to keep using if possible.

What i am trying to do is create a front screen for loading ghost image. The app will take a list of folders that exist on our server and put them in a combo box and when a user select one of the folders from the combo box it will display every ghost image within that folder in the List box(GuiCreateList). When the user chooses the image he want to load by selecting it i then want at that point a button to appear (saying load) that when pressed starts ghost. here is what i have done so far.

#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,40)
    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(-1,$i)

    $listview = GUICtrlCreateListView ("Description          | Path                                 |  File Name                    ",10,140,400,150,$LVS_SINGLESEL+$LVS_NOSORTHEADER)

    $info = GUICtrlCreateLabel("qpqqpqpqpqpq",450,150,325,200)
    GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT) 
    GUICtrlSetFont(-1,12)

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


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
        ;GUICtrlSetState ($bn,$GUI_Show)
    ENDIF

   Switch $Msg
        Case $GUI_EVENT_CLOSE 
            Exit
            
        Case $bn
            $split = StringSplit(GUICtrlRead(GUICtrlRead($listview)),"|")
            RunWait("z:\ghost32.exe -clone,mode=restore,src=" & $split[2] & "\" & $split[3] & ",dst=1,szeF -sure","",@SW_HIDE)                  

        Case $bnt
            $splittemp = StringSplit(GUICtrlRead(GUICtrlRead($listview)),"|")
            
            $comments = _GetFileProperty($splittemp[2] & "\" & $splittemp[3], "Comments")
            GUICtrlSetData($info,$comments )

        Case $listview
            GUICtrlSetState ($bn,$GUI_Show)
    EndSwitch
        
WEnd
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...