Jump to content

Recommended Posts

Posted

Hi

I have a problem with my program and i tried to solve it without any luck. The problem is when i did select items from listbox and push the "OK" button "$Button1" a message come out with the list of the selected items. If i click again on the "OK" button the list of the items will be doubled (without any change in the selected items) and so on. I tried to make a second array and fill up with the first one data s  and compare later  with the first one but it did not work. Any ideas?

#include <Array.au3>
#include <file.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>
#include <Constants.au3>
 #include <WinAPI.au3>
 #include <ListViewConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global $qw
$qw=_FileListToArray("C:\users","*", $FLTA_FOLDERS)

Form1_main()

Func Form1_main()
#Region ### START Koda GUI section ### Form=f:\autoit\autoit-sajat\form1-1.kxf
$Form1= GUICreate("Group1", 315, 245, 192, 124)
global $List1 = GUICtrlCreateList("", 16, 16, 140, 220,BitOR($LBS_SORT, $WS_HSCROLL, $WS_VSCROLL, $WS_BORDER, $LBS_HASSTRINGS, $LBS_MULTIPLESEL))
$Button1 = GUICtrlCreateButton("OK", 168, 16, 57, 25)
$Button2 = GUICtrlCreateButton("Cancel", 240, 16, 57, 25)
$GUI= GUICtrlCreateButton("....", 168, 48, 57, 25)
Global $Button4 = GUICtrlCreateButton("Pass", 240, 48, 43, 25)
Global $Label1 = GUICtrlCreateLabel("P", 288, 48, 11, 17)
GUICtrlSetState(-1, $GUI_DISABLE)
$listview = GUICtrlCreateListView("", 168, 80, 129, 149, BitOR($LVS_SHOWSELALWAYS, $LVS_NOCOLUMNHEADER, $WS_EX_TRANSPARENT,$LVS_EX_CHECKBOXES,$LVS_EX_FLATSB))
GUICtrlSetState(-1, $GUI_DISABLE)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

; Add strings

Local $sItems

; Finish strings

list_fresh($qw)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE,$Button2
            Exit

        Case $Button1

            $aItems = _GUICtrlListBox_GetSelItems($List1)
                For $iI = 1 To $aItems[0]
                    $sItems &= @CR & $aItems[$iI] & ', ' & _GUICtrlListBox_GetText($List1,$aItems[$iI])
                Next
                MsgBox($MB_SYSTEMMODAL, "Information", "Items Selected: " & $sItems)
        Case $GUI
            GUISetState(@SW_DISABLE, $Form1)
            GUISetState(@SW_ENABLE, $Form1)
            GUISetState(@SW_RESTORE,$Form1)
        Case $Button4
            passw()

    EndSwitch
WEnd
EndFunc

Func passw()
;CodeWizard generated code Start ---
            ;InputBox features: Title=No, Prompt=Yes, Default Text=No, Input Length=6, Pwd Char=-, Width=80, Height=30, Left=500, Top=500
            $sInputBoxAnswer = InputBox("","  ","","-6","80","30","550","180")
            Select
                Case @Error = 0 ;OK - The string returned is valid
                    if $sInputBoxAnswer=="00000000" Then
                        GUICtrlSetState($Label1, $GUI_ENABLE)
                    Else
                        GUICtrlSetState($Label1, $GUI_DISABLE)
                    EndIf
                    $read=$sInputBoxAnswer
                    ;MsgBox($MB_SYSTEMMODAL,"",$read)
                Case @Error = 1 ;The Cancel button was pushed

                Case @Error = 3 ;The InputBox failed to open
            ;CodeWizard generated code End ---
        EndSelect
EndFunc

Func list_fresh($qw)
      _GUICtrlListBox_BeginUpdate($List1)
    For $iI = 1 To $qw[0]
        _GUICtrlListBox_AddString($List1, $qw[$iI])
    Next
    _GUICtrlListBox_EndUpdate($List1)
EndFunc

Thanks for the help.

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
×
×
  • Create New...