Jump to content

Problems with 'ControlListView' & "GetSelected", 1


Recommended Posts

I'm unable to read from a 'GUICtrlCreateListView' using the function 'ControlListView' with the command "GetSelected", 1.

The function always returns a '1' no matter what I try.

Any ideas?

Here is the code:

;----------------------------------------------------------------------------

;AutoIt Version: 3.1

;Language:      English

;Platform:      Win9x / NT / XP

;Author:        Justin Taylor

;---------------------------------------------------------------------------

#include <GuiConstants.au3>

#include <Array.au3>

#region --- Variables ---

$script_name = "Program Installer"

Dim $file_array[200]Dim $file_count = 0

Dim $control_handles[200]

Dim $control_count = 0 ;Contains # of controls

#region --- EndVariables ---

GuiCreate( $script_name, 281, 571,(@DesktopWidth-281)/2, (@DesktopHeight-571)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS )

$Label_1 = GuiCtrlCreateLabel( "Script will be created including the specified *.exe files.", 10, 10, 260, 20 )

$script_name = GuiCtrlCreateInput( @ScriptDir &"\AutoInstall.au3", 10, 460, 200, 20 )

$Label_3 = GuiCtrlCreateLabel( "Script Location:", 10, 440, 190, 20 )

$Label_4 = GuiCtrlCreateLabel( "Installation Location (created if non-existent):", 10, 490, 210, 20 )

$script_location = GuiCtrlCreateInput( @DesktopCommonDir, 10, 510, 260, 20 )

$create = GuiCtrlCreateButton( "Create", 120, 540, 70, 20 )

$close = GuiCtrlCreateButton( "Close", 200, 540, 70, 20 )

$browse = GuiCtrlCreateButton( "Browse...", 220, 460, 50, 20 )

$list = GUICtrlCreateListView( "Program List", 10, 30, 260, 400, $LVS_SHOWSELALWAYS ) ;Allow Multiselect

;~ $list = GUICtrlCreateListView( "Program List", 10, 30, 260, 400 ) ;TEST

;For TEST prposes

GUICtrlCreateListViewItem( "Item0", $list )

GUICtrlCreateListViewItem( "Item1", $list )

GUICtrlCreateListViewItem( "Item2", $list )

GUICtrlCreateListViewItem( "Item3", $list )

GUICtrlCreateListViewItem( "Item4", $list )

GUICtrlCreateListViewItem( "Item5", $list )

GUICtrlCreateListViewItem( "Item6", $list )

;Show the gui

GuiSetState()

While 1

$msg = GuiGetMsg()

Select

  Case $msg = $browse

  ;Open File selecton dialog

 

  Case $msg = $create

 

  ;Retrieve all selected program names

;Always errors out!!!!

MsgBox( 262208, "Selected items are:", ControlListView( $script_name, "", $list, "GetSelected", 1 ))

;First item ID:

;~ msgbox(262144, "", Guictrlread( $list ))

;First item:

;~  MsgBox( 262208, "Text is:", guictrlread( Guictrlread( $list ) ) )

  ;Generate code for script

 

 

  Case $msg = $close

  ExitLoop

 

  Case $msg = $GUI_EVENT_CLOSE

  ExitLoop

 

  Case Else

  ;;;

EndSelect

WEnd

Exit

Link to comment
Share on other sites

you re-used the variable $script_name

;----------------------------------------------------------------------------
;AutoIt Version: 3.1
;Language:    English
;Platform:    Win9x / NT / XP
;Author:        Justin Taylor
;---------------------------------------------------------------------------

#include <GuiConstants.au3>
#include <Array.au3>

#region --- Variables ---
$script_name = "Program Installer"
Dim $file_array[200]
Dim $file_count = 0
Dim $control_handles[200] 
Dim $control_count = 0;Contains # of controls

#region --- EndVariables ---

$GUI = GuiCreate( $script_name, 281, 571,(@DesktopWidth-281)/2, (@DesktopHeight-571)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS )

$Label_1 = GuiCtrlCreateLabel( "Script will be created including the specified *.exe files.", 10, 10, 260, 20 )
$script_name = GuiCtrlCreateInput( @ScriptDir &"\AutoInstall.au3", 10, 460, 200, 20 )
$Label_3 = GuiCtrlCreateLabel( "Script Location:", 10, 440, 190, 20 )
$Label_4 = GuiCtrlCreateLabel( "Installation Location (created if non-existent):", 10, 490, 210, 20 )
$script_location = GuiCtrlCreateInput( @DesktopCommonDir, 10, 510, 260, 20 )
$create = GuiCtrlCreateButton( "Create", 120, 540, 70, 20 )
$close = GuiCtrlCreateButton( "Close", 200, 540, 70, 20 )
$browse = GuiCtrlCreateButton( "Browse...", 220, 460, 50, 20 )
$list = GUICtrlCreateListView( "Program List", 10, 30, 260, 400, $LVS_SHOWSELALWAYS );Allow Multiselect
;~ $list = GUICtrlCreateListView( "Program List", 10, 30, 260, 400 );TEST

;For TEST prposes
GUICtrlCreateListViewItem( "Item0", $list )
GUICtrlCreateListViewItem( "Item1", $list )
GUICtrlCreateListViewItem( "Item2", $list )
GUICtrlCreateListViewItem( "Item3", $list )
GUICtrlCreateListViewItem( "Item4", $list )
GUICtrlCreateListViewItem( "Item5", $list )
GUICtrlCreateListViewItem( "Item6", $list )


;Show the gui
GuiSetState()

While 1
$msg = GuiGetMsg()
Select
  Case $msg = $browse
 ;Open File selecton dialog
  
  Case $msg = $create
  
 ;Retrieve all selected program names


;Always errors out!!!!
MsgBox( 262208, "Selected items are:", ControlListView( $GUI, "", $list, "GetSelected", 1 ))


;First item ID:
;~ msgbox(262144, "", Guictrlread( $list ))

;First item:
;~  MsgBox( 262208, "Text is:", guictrlread( Guictrlread( $list ) ) )


 ;Generate code for script
  
  
  Case $msg = $close
  ExitLoop
  
  Case $msg = $GUI_EVENT_CLOSE
  ExitLoop
  
  Case Else
 ;;;
EndSelect
WEnd

Exit

SciTE for AutoItDirections for Submitting Standard UDFs

 

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

 

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