Jump to content
Sign in to follow this  
Trystian

ListViewItem Select & GUIOnEventMode = 1

Recommended Posts

Trystian

Hello all,

First post here. Please don't flame me for being a newb, all my fire extinguishers are empty. :)

I'm trying to make an application which takes the selected ListView Item and populates an Inputbox. Unfortunately, it's not updating the Inputbox when I select a different ListView Item from the ListView Control. Is there any way to do this with Event Mode on?

Thanks in advance,

-Trystian

Sample:

#include <GuiConstants.au3>
Opt("GUIOnEventMode", 1)

GuiCreate("Video Selector", 730, 420,(@DesktopWidth-730)/2, (@DesktopHeight-420)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
Global $ListView_1 = GuiCtrlCreateListView("Filename.Ext" & "|Size(Mb)|Date Modified", 20, 100, 380, 305); Filename ListViewbox
GUICtrlSetOnEvent($ListView_1,"fcnSelected")
GUICtrlCreateListViewItem ("Test1.avi" & "|" & "350" & "|" & "03/21/05 10:00",$ListView_1); Add ListView Contents
GUICtrlCreateListViewItem ("Test2.avi" & "|" & "350" & "|" & "03/21/05 10:00",$ListView_1); Add ListView Contents
GUICtrlCreateListViewItem ("Test3.avi" & "|" & "350" & "|" & "03/21/05 10:00",$ListView_1); Add ListView Contents

Global $Input_1 = GuiCtrlCreateInput("Filename.ext", 430, 185, 285, 20); Selected Filename

While 1
    Sleep(5000)
WEnd

Func fcnSelected()

        Global $strSelFile
        $strSelFile = StringSplit(GUICtrlRead(GUICtrlRead($ListView_1)),"|")

        GUICtrlSetData ($Input_1, $strSelFile[1])
            
EndFunc

Share this post


Link to post
Share on other sites
GaryFrost

I haven't seen a way of doing that on event

but the following might work for you.

#include <GuiConstants.au3>
;~ Opt("GUIOnEventMode", 1)

GuiCreate("Video Selector", 730, 420,(@DesktopWidth-730)/2, (@DesktopHeight-420)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
Global $ListView_1 = GuiCtrlCreateListView("Filename.Ext" & "|Size(Mb)|Date Modified", 20, 100, 380, 305); Filename ListViewbox
;~ GUICtrlSetOnEvent($ListView_1,"fcnSelected")
GUICtrlCreateListViewItem ("Test1.avi" & "|" & "350" & "|" & "03/21/05 10:00",$ListView_1); Add ListView Contents
GUICtrlCreateListViewItem ("Test2.avi" & "|" & "350" & "|" & "03/21/05 10:00",$ListView_1); Add ListView Contents
GUICtrlCreateListViewItem ("Test3.avi" & "|" & "350" & "|" & "03/21/05 10:00",$ListView_1); Add ListView Contents

Global $Input_1 = GuiCtrlCreateInput("Filename.ext", 430, 185, 285, 20); Selected Filename

Do
    $MSG = GUIGetMsg()
    Select
        Case $MSG = $GUI_EVENT_PRIMARYDOWN
            if(ControlListView("Video Selector", "", $ListView_1, "GetSelectedCount"))Then
                fcnSelected()
            EndIf
    EndSelect
Until $MSG = $GUI_EVENT_CLOSE

Func fcnSelected()

        Global $strSelFile
        $strSelFile = StringSplit(GUICtrlRead(GUICtrlRead($ListView_1)),"|")

        GUICtrlSetData ($Input_1, $strSelFile[1])
            
EndFunc

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites
Trystian

I was hoping onEvent mode had some way to handle this issue.

Your solution does work well gafrost, thank you for the rapid response.

Now to convert the rest of my application from onEvent Mode to MessageLoop mode. :)

Once again, Thanx.

-Trystian

I haven't seen a way of doing that on event

but the following might work for you.

#include <GuiConstants.au3>
;~ Opt("GUIOnEventMode", 1)

GuiCreate("Video Selector", 730, 420,(@DesktopWidth-730)/2, (@DesktopHeight-420)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
Global $ListView_1 = GuiCtrlCreateListView("Filename.Ext" & "|Size(Mb)|Date Modified", 20, 100, 380, 305); Filename ListViewbox
;~ GUICtrlSetOnEvent($ListView_1,"fcnSelected")
GUICtrlCreateListViewItem ("Test1.avi" & "|" & "350" & "|" & "03/21/05 10:00",$ListView_1); Add ListView Contents
GUICtrlCreateListViewItem ("Test2.avi" & "|" & "350" & "|" & "03/21/05 10:00",$ListView_1); Add ListView Contents
GUICtrlCreateListViewItem ("Test3.avi" & "|" & "350" & "|" & "03/21/05 10:00",$ListView_1); Add ListView Contents

Global $Input_1 = GuiCtrlCreateInput("Filename.ext", 430, 185, 285, 20); Selected Filename

Do
    $MSG = GUIGetMsg()
    Select
        Case $MSG = $GUI_EVENT_PRIMARYDOWN
            if(ControlListView("Video Selector", "", $ListVie
w_1, "GetSelectedCount"))Then
                fcnSelected()
            EndIf
    EndSelect
Until $MSG = $GUI_EVENT_CLOSE

Func fcnSelected()

        Global $strSelFile
        $strSelFile = StringSplit(GUICtrlRead(GUICtrlRead($ListView_1)),"|")

        GUICtrlSetData ($Input_1, $strSelFile[1])
            
EndFunc

<{POST_SNAPBACK}>

Share this post


Link to post
Share on other sites
jpm

I was hoping onEvent mode had some way to handle this issue.

Your solution does work well gafrost, thank you for the rapid response.

Now to convert the rest of my application from onEvent Mode to MessageLoop mode.   :)

Once again, Thanx.

-Trystian

<{POST_SNAPBACK}>

just add
GUICtrlSetOnEvent(-1,"fcnSelected")

after creating the GUICtrlCreateListViewItem

no too elegant but remenber item are control that can be set independanly so react independantly.

edit: you miss a GuiSetState() before the while loop

Edited by jpm

Share this post


Link to post
Share on other sites
sylvanie

I was hoping onEvent mode had some way to handle this issue.

Your solution does work well gafrost, thank you for the rapid response.

Now to convert the rest of my application from onEvent Mode to MessageLoop mode.  :)

Once again, Thanx.

-Trystian

<{POST_SNAPBACK}>

Hello, I think that it could be a solution :

#include <GuiConstants.au3>

Opt("GUIOnEventMode", 1)

GuiCreate("Video Selector", 730, 420,(@DesktopWidth-730)/2, (@DesktopHeight-420)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

Global $ListView_1 = GuiCtrlCreateListView("Filename.Ext" & "|Size(Mb)|Date Modified", 20, 100, 380, 305); Filename ListViewbox

;GUICtrlSetOnEvent($ListView_1,"fcnSelected")

GUISetOnEvent($GUI_EVENT_PRIMARYDOWN,"fcnSelected")

GUICtrlCreateListViewItem ("Test1.avi" & "|" & "350" & "|" & "03/21/05 10:00",$ListView_1); Add ListView Contents

GUICtrlCreateListViewItem ("Test2.avi" & "|" & "350" & "|" & "03/21/05 10:00",$ListView_1); Add ListView Contents

GUICtrlCreateListViewItem ("Test3.avi" & "|" & "350" & "|" & "03/21/05 10:00",$ListView_1); Add ListView Contents

Global $Input_1 = GuiCtrlCreateInput("Filename.ext", 430, 185, 285, 20); Selected Filename

GUISetState() ; don't forget !

While 1

    Sleep(5000)

WEnd

Func fcnSelected()

  Global $strSelFile

        $strSelFile = StringSplit(GUICtrlRead(GUICtrlRead($ListView_1)),"|")

        GUICtrlSetData ($Input_1, $strSelFile[1])

           

EndFunc

Isn't it ?

Share this post


Link to post
Share on other sites
GaryFrost

that'll work, but I would think you want to make sure that the primary down was for the control specified

GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "SpecialEvents")


Func SpecialEvents()
    Select
    Case @GUI_CTRLID = $GUI_EVENT_PRIMARYDOWN
        if(ControlGetFocus("Video Selector") == "SysListView321") then
            if(ControlListView("Video Selector", "", $ListView_1, "GetSelectedCount"))Then
                fcnSelected()
            EndIf
        EndIf
     EndSelect
EndFunc
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites
Trystian

This solution works perfectly for my needs. Thank you all for your help.

-Trystian

that'll work, but I would think you want to make sure that the primary down was for the control specified

GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "SpecialEvents")
Func SpecialEvents()
    Select
    Case @GUI_CTRLID = $GUI_EVENT_PRIMARYDOWN
        if(ControlGetFocus("Video Selector") == "SysListView321") then
            if(ControlListView("Video Selector", "", $ListView_1, "GetSelectedCount"))Then
                fcnSelected()
            EndIf
        EndIf
     EndSelect
EndFunc

<{POST_SNAPBACK}>

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.