Jump to content

Problems with GUICtrlSendMsg()


 Share

Recommended Posts

Can I use the GUICtrlSendMsg () methode in the GUIOnEventMode?

I try to delete a few Strings from a list and insert it at another list, but it doesn´t work.

Nothing happens. Does anybody know the problem?

GUICtrlSendMsg ($list_ac, $LB_DELETESTRING, $ei[$i], 0)
GUICtrlSendMsg ($list_cc, $LB_INSERTSTRING, $ei[$i], $et[$i]))

Thanx V.

Link to comment
Share on other sites

This is the complete code. I try to simulate a window of a programm, to save a default setting for the further work. My problem is in the Choose()-methode.

If you click the choose-button (>>), the choosen elements of the ac_list, shell be deleten at $list_ac and insert at $list_cc and if you click at the <<-Button, the same shell happen converse.

; AutoIt v3
; 22.04.2005 - gui_default
; Simulation of the data-export-window of the deweca-software
; Autor: A

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

If(Not IsDeclared("LB_ADDSTRING")) Then Global Const $LB_ADDSTRING = 0x180
If(Not IsDeclared("LB_DELETESTRING")) Then Global Const $LB_DELETESTRING = 0x182
If(Not IsDeclared("LB_INSERTSTRING")) Then Global Const $LB_INSERTSTRING = 0x181
If(Not IsDeclared("LB_ERR")) Then Global Const $LB_ERR = -1
If(Not IsDeclared("LB_GETCOUNT")) Then Global Const $LB_GETCOUNT = 0x18B
If(Not IsDeclared("LB_GETSEL")) Then Global Const $LB_GETSEL = 0x0187
If(Not IsDeclared("LB_GETTEXT")) Then Global Const $LB_GETTEXT = 0x0189

$zylinder_anzahl = 1; Zylinderanzahl übergeben !!!!!!!!
Global $LBS_EXTENDEDSEL = 0x0800

Opt("GUIOnEventMode", 1)

; Beendet die Endlosschleife und startet das nächste Control
$loop = 0

; GUI
$window = GuiCreate("Data Export", 554, 453)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")

; Label: Comment
GuiCtrlCreateLabel("Comment", 19, 7)

; Textfeld Kommentar
GuiCtrlCreateInput("", 19, 24, 511, 22)

; X-Achse
GuiCtrlCreateGroup("&X-Axis",19, 54, 511, 64)
GuiCtrlCreateLabel("Type", 40, 70)
$type_combo = GuiCtrlCreateCombo("Cycles",40,86,172,60)
GUICtrlSetData(-1,"Crankangle")
GUICtrlCreateGroup ("",-99,-99,1,1);close group
GUICtrlSetOnEvent($type_combo,"TypeChosen")

; Exportauswahl
GuiCtrlCreateGroup("Export settings",19, 126, 150, 97)
GuiCtrlCreateCombo("Text",27,142,132,120)
GUICtrlSetData(-1,"ASCII (Concerto)|Diadem|Flexpro|Excel")
;Zyklenanzahl
$num_cycles = GuiCtrlCreateCombo("all cycles",27,166,132,120)
GUICtrlSetData(-1,"cycles from x to y|first y cycles|last y cycles")
$x_input = GuiCtrlCreateInput("1", 43, 190, 48, 19)
GuiCtrlCreateLabel("-", 96, 190)
$y_input = GuiCtrlCreateInput("10", 107, 190, 48, 19)
GUISetFont (7)
$x_label = GuiCtrlCreateLabel("x-min(1)", 43, 208)
$y_label = GuiCtrlCreateLabel("y-min(100)", 107, 208)
GUISetFont (9)
GUICtrlCreateGroup ("",-99,-99,1,1);close group
GUICtrlSetState($x_input,$GUI_DISABLE)
GUICtrlSetState($y_input,$GUI_DISABLE)
GUICtrlSetState($x_label,$GUI_DISABLE)
GUICtrlSetState($y_label,$GUI_DISABLE)
GUICtrlSetOnEvent($num_cycles,"NumCycles")

; Global export settings
GuiCtrlCreateGroup("Global export settings",172, 126, 358, 97)
GuiCtrlCreateCheckbox("Export header and engine parameters", 178, 150, 250, 22)
GuiCtrlSetState(-1, $GUI_UNCHECKED)
$checkbox_2 = GuiCtrlCreateCheckbox("Export cycles average", 178, 174, 250, 16)
GuiCtrlSetState(-1, $GUI_UNCHECKED)
GUICtrlSetOnEvent($checkbox_2,"CycleAverage")
$checkbox_3 = GuiCtrlCreateCheckbox("Export crankangle cycle by cycle (e.g. -30 .. 90; -30 .. 90; ... )", 178, 190, 310, 22)
GuiCtrlSetState(-1, $GUI_UNCHECKED)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlCreateGroup ("",-99,-99,1,1);close group



; Available channels
$list_cy_wb = "N"
For $i = 1 To $zylinder_anzahl
    $list_cy_wb = $list_cy_wb & "Max_" & $i & "|AMax_" & $i & "|_
    Pcorr_" & $i & "|E05_" & $i & "|E10_" & $i & "|E50_" & $i & "|_
    E90_" & $i & "|EX_" & $i & "|EXave_" & $i & "|EXmax_" & $i & "|_
    EXmin_" & $i &  "|EXstd_" & $i & "|SOC_" & $i & "|EOC_" & $i & "|_
    DOC_" & $i & "|IMEP_" & $i & "|PMEP_" & $i & "|NMEP_" & $i & "|_
    MF_" & $i & "|IWork_" & $i & "|IPower_" & $i & "|ITorqu_" & $i
Next
$list_cy_gew = ""
$list_cr_wb = "n"
For $i = 1 To $zylinder_anzahl
            $list_cr_wb = $list_cr_wb & "P_Cyl_" & $i & "|IH_" & $i & "|QH_" & $i & "|_
            VOL_" & $i
        Next
        $list_cr_wb = $list_cr_wb & "Z_Spannung|PMV_388|Z_Strom|PM_306,8|Lambda|Zündsignal|_
        Einspritz"
$list_cr_gew = ""


$ac_gewaehlt = ""
$cc_gewaehlt = ""
$ac_gewaehlt2 = ""
GuiCtrlCreateLabel("Available channels", 40, 229)
$list_ac = GuiCtrlCreateList("", 19, 243, 166, 160, BitOR($LBS_DISABLENOSCROLL,$WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_EXTENDEDSEL))
GuiCtrlSetData(-1, $list_cy_wb)

; Choosen channels
GuiCtrlCreateLabel("Chosen channels", 300, 229)
$list_cc = GuiCtrlCreateList("", 276, 243, 166, 160, BitOR($LBS_DISABLENOSCROLL,$WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_EXTENDEDSEL))
GuiCtrlSetData(-1, $list_cy_gew)

; >>- und <<-Buttons
$choose_button = GUICtrlCreateButton(">>", 192 ,243, 79, 19)
$choose_not_button = GUICtrlCreateButton("<<", 192, 267, 79, 19)
GUICtrlSetOnEvent($choose_button, "Choose")
GUICtrlSetOnEvent($choose_not_button, "ChooseNot")

; Cancel- und OK-Button (und default-checkbox)
GuiCtrlCreateCheckbox("make this the |default export", 450, 336, 87, 53)
GuiCtrlSetState(-1, $GUI_UNCHECKED)
$cancelButton = GUICtrlCreateButton("Cancel", 450 ,396, 91, 22)
$okButton = GUICtrlCreateButton("Ok", 450, 423, 91, 22)
GUICtrlSetState(-1,$GUI_FOCUS)
$ac_gewaehlt = GUICtrlSetOnEvent($okButton, "OKButton")
GUICtrlSetOnEvent($cancelButton, "Cancel")
GUISetState(@SW_SHOW)

;_________________________________________________________________________________________
;Endlosschleife für alle Controls
While 1
    Sleep(1000)
    If $loop = 1 Then
        $loop = 0
        GUISetState(@SW_HIDE)
        ExitLoop
    EndIf
Wend 
;_________________________________________________________________________________________

;Funktionen des Ok-Buttons, des Cancel-Buttons und der Schließen-Funktion
Func OKButton()
    $ac_gewaehlt = GUICtrlRead($list_ac)
    $ac_gewaehlt2 = _GUICtrlListBoxGetSelItemsText($list_ac)
    $loop = 1
EndFunc


Func CLOSEClicked()
;MsgBox(0, "Abbruch", "Programm wird beendet!")
  Exit
EndFunc

Func Cancel()
;MsgBox(0, "Abbruch", "Programm wird beendet!")
  Exit
EndFunc

;Funktion für die Wahl des Typs der Exportierten Datei
Func TypeChosen()
    $t = GUICtrlRead($type_combo)
    If $t = "Cycles" Then
        GuiCtrlSetData($list_ac, "|N")
        For $i = 1 To $zylinder_anzahl
            GuiCtrlSetData($list_ac, "Max_" & $i & "|AMax_" & $i & "|_
            Pcorr_" & $i & "|E05_" & $i & "|E10_" & $i & "|E50_" & $i & "|_
            E90_" & $i & "|EX_" & $i & "|EXave_" & $i & "|EXmax_" & $i & "|_
            EXmin_" & $i &  "|EXstd_" & $i & "|SOC_" & $i & "|EOC_" & $i & "|_
            DOC_" & $i & "|IMEP_" & $i & "|PMEP_" & $i & "|NMEP_" & $i & "|_
            MF_" & $i & "|IWork_" & $i & "|IPower_" & $i & "|ITorqu_" & $i)
        Next
        GUICtrlSetState($checkbox_3,$GUI_DISABLE)
    ElseIf $t = "Crankangle" Then
        GuiCtrlSetData($list_ac, "|n")
        For $i = 1 To $zylinder_anzahl
            GuiCtrlSetData($list_ac, "P_Cyl_" & $i & "|IH_" & $i & "|QH_" & $i & "|_
            VOL_" & $i)
        Next
        GuiCtrlSetData($list_ac, "Z_Spannung|PMV_388|Z_Strom|PM_306,8|Lambda|Zündsignal|_
        Einspritz")
        GUICtrlSetState($checkbox_3,$GUI_ENABLE)
    EndIf
EndFunc

Func NumCycles()
    $nc = GUICtrlRead($num_cycles)
    Select
        Case $nc = "all cycles"
            GUICtrlSetState($x_input,$GUI_DISABLE)
            GUICtrlSetState($x_label,$GUI_DISABLE)
            GUICtrlSetState($y_input,$GUI_DISABLE)            
            GUICtrlSetState($y_label,$GUI_DISABLE)
        Case $nc = "cycles from x to y"
            GUICtrlSetState($x_input,$GUI_ENABLE)
            GUICtrlSetState($x_label,$GUI_ENABLE)
            GUICtrlSetState($y_input,$GUI_ENABLE)
            GUICtrlSetState($y_label,$GUI_ENABLE)
        Case $nc = "first y cycles"
            GUICtrlSetState($x_input,$GUI_DISABLE)
            GUICtrlSetState($x_label,$GUI_DISABLE)
            GUICtrlSetState($y_input,$GUI_ENABLE)
            GUICtrlSetState($y_label,$GUI_ENABLE)
        Case $nc = "last y cycles"
            GUICtrlSetState($x_input,$GUI_DISABLE)
            GUICtrlSetState($x_label,$GUI_DISABLE)
            GUICtrlSetState($y_input,$GUI_ENABLE)
            GUICtrlSetState($y_label,$GUI_ENABLE)
    EndSelect
EndFunc

Func CycleAverage()
    $ca = GUICtrlRead($checkbox_2)
    $ccc = GUICtrlGetState($checkbox_3)
        If $ca = $GUI_CHECKED Then
            GUICtrlSetState($num_cycles,$GUI_DISABLE)
            GUICtrlSetState($x_input,$GUI_DISABLE)
            GUICtrlSetState($x_label,$GUI_DISABLE)
            GUICtrlSetState($y_input,$GUI_DISABLE)            
            GUICtrlSetState($y_label,$GUI_DISABLE)
            GUICtrlSetState($checkbox_3,$ccc)
        ElseIf $ca = $GUI_UNCHECKED Then
            GUICtrlSetState($num_cycles,$GUI_ENABLE)
            GUICtrlSetState($x_input,$GUI_ENABLE)
            GUICtrlSetState($x_label,$GUI_ENABLE)
            GUICtrlSetState($y_input,$GUI_ENABLE)            
            GUICtrlSetState($y_label,$GUI_ENABLE)
            GUICtrlSetState($checkbox_3,$ccc)
        EndIf
EndFunc

;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    
Func Choose()
    $et = _GUICtrlListBoxGetSelItemsText($list_ac)
    $ei = _GUIListBoxGetSelItems($list_ac)
    If _ArrayToString ($et,",") = "" Then
        GUICtrlSendMsg ($list_ac, $LB_DELETESTRING, $ei[1], 0)
        GUICtrlSendMsg ($list_cc, $LB_INSERTSTRING, $ei[1], $et)
    Else
        For $i = 1 To _ArrayLength($et)
            GUICtrlSendMsg ($list_ac, $LB_DELETESTRING, $ei[$i], 0)
            GUICtrlSendMsg ($list_cc, $LB_INSERTSTRING, $ei[$i], $et[$i])
        Next
    EndIf
EndFunc

;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Func ChooseNot()
    $cet = _GUICtrlListBoxGetSelItemsText($list_cc)
    $cei = _GUIListBoxGetSelItems($list_ac)
    MsgBox(0,"$cet",_ArrayToString ($cet,","))
    MsgBox(0,"$cei",_ArrayToString ($cei,","))
    If _ArrayToString ($cei,",") = "" Then
        GUICtrlSendMsg ($list_cc, $LB_DELETESTRING, $cei[1], 0)
        GUICtrlSendMsg ($list_ac, $LB_INSERTSTRING, $cei[1], $cet)
    Else    
        For $i = 1 To _ArrayLength($cet)
            GUICtrlSendMsg ($list_cc, $LB_DELETESTRING, $cei[$i], 0)
            GUICtrlSetData ($list_ac, $cet[$i])
        Next
    EndIf
EndFunc
;--------------------------------------------------------------------------------------------------------

;Funktion zum Abrufen aller ausgewählten Listbox-Elemente
Func _GUICtrlListBoxGetSelItemsText($h_listbox)
    Local $i, $list = "", $a_text[1], $ret
    For $i = 0 To GuiCtrlSendMsg($h_listbox,$LB_GETCOUNT,0,0) - 1;0 to GetCount
        $ret = GuiCtrlSendMsg($h_listbox,$LB_GETSEL,$i,0)
        If( $ret > 0 )Then
            If(StringLen($list) > 0) Then
                $list = $list & ',' & $i 
            Else
                $list = $i
            EndIf
        ElseIf( $ret == $LB_ERR) Then 
            Return $LB_ERR
        EndIf
    Next;$list should now equal the selected items

    If(StringLen($list) > 0) Then
        Local $a_indices = StringSplit( $list, "," );StringSplit(GetSelItems...
        If @error Then Return $LB_ERR
            Redim $a_text[UBound($a_indices)]
            $a_text[0] = UBound($a_text) - 1
        For $i = 1 to $a_indices[0]
            $a_text[$i] = GuiCtrlRecvMsg($h_listbox,$LB_GETTEXT,$a_indices[$i],1)
        Next
        Return $a_text
    Else
        Return $LB_ERR
    EndIf
EndFunc
;_____________________________________________________________________________________________


Func _GUIListBoxGetSelItems($h_listbox)
    Local $i, $list = "", $ret
    For $i = 0 To GuiCtrlSendMsg($h_listbox,$LB_GETCOUNT,0,0) - 1
        $ret = GuiCtrlSendMsg($h_listbox,$LB_GETSEL,$i,0)
        If( $ret > 0 )Then
            If(StringLen($list) > 0) Then
                $list = $list & ',' & $i 
            Else
                $list = $i
            EndIf
        ElseIf( $ret == $LB_ERR) Then 
            Return $LB_ERR
        EndIf
    Next
    If(StringLen($list) > 0) Then
        Return StringSplit($list,",")
    Else
        Return $LB_ERR
    EndIf
EndFunc
;_____________________________________________________________________________________________


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

Func _ArrayLength($this_array)
    $length = 0
    $help_array = $this_array
    While 1
        If _ArrayToString ($help_array,",") == "" Then ExitLoop
        $length = $length + 1
        _ArrayPop($help_array)
    WEnd
    Return $length
EndFunc

If _ArrayToString ($ac_gewaehlt2,",") = "" Then
    MsgBox(0,"Element_einzeln",$ac_gewaehlt)
Else
    MsgBox(0,"Elemente_mehrere",_ArrayToString ($ac_gewaehlt2,","))
    for $i = 0 to _ArrayLength ($ac_gewaehlt2)
        MsgBox(0,"Elemente",$ac_gewaehlt2[$i])
    Next
EndIf

;MsgBox(0,"",)
;MsgBox(0,"",)
Edited by volvox
Link to comment
Share on other sites

It works now, if somebody want´s to know...

; AutoIt v3
; 22.04.2005 - gui_default
; Simulation der GUI des datenexports bei Deweca v6
; Autor: A

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

If(Not IsDeclared("LB_ADDSTRING")) Then Global Const $LB_ADDSTRING = 0x180
If(Not IsDeclared("LB_DELETESTRING")) Then Global Const $LB_DELETESTRING = 0x182
If(Not IsDeclared("LB_INSERTSTRING")) Then Global Const $LB_INSERTSTRING = 0x181
If(Not IsDeclared("LB_ERR")) Then Global Const $LB_ERR = -1
If(Not IsDeclared("LB_GETCOUNT")) Then Global Const $LB_GETCOUNT = 0x18B
If(Not IsDeclared("LB_GETSEL")) Then Global Const $LB_GETSEL = 0x0187
If(Not IsDeclared("LB_GETTEXT")) Then Global Const $LB_GETTEXT = 0x0189

$zylinder_anzahl = 1; Zylinderanzahl übergeben !!!!!!!!
Global $LBS_EXTENDEDSEL = 0x0800

Opt("GUIOnEventMode", 1)

; Beendet die Endlosschleife und startet das nächste Control
$loop = 0

; GUI
$window = GuiCreate("Data Export", 554, 453)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")

; Label: Comment
GuiCtrlCreateLabel("Comment", 19, 7)

; Textfeld Kommentar
GuiCtrlCreateInput("", 19, 24, 511, 22)

; X-Achse
GuiCtrlCreateGroup("&X-Axis",19, 54, 511, 64)
GuiCtrlCreateLabel("Type", 40, 70)
$type_combo = GuiCtrlCreateCombo("Cycles",40,86,172,60)
GUICtrlSetData(-1,"Crankangle")
GUICtrlCreateGroup ("",-99,-99,1,1);close group
GUICtrlSetOnEvent($type_combo,"TypeChosen")

; Exportauswahl
GuiCtrlCreateGroup("Export settings",19, 126, 150, 97)
GuiCtrlCreateCombo("Text",27,142,132,120)
GUICtrlSetData(-1,"ASCII (Concerto)|Diadem|Flexpro|Excel")
;Zyklenanzahl
$num_cycles = GuiCtrlCreateCombo("all cycles",27,166,132,120)
GUICtrlSetData(-1,"cycles from x to y|first y cycles|last y cycles")
$x_input = GuiCtrlCreateInput("1", 43, 190, 48, 19)
GuiCtrlCreateLabel("-", 96, 190)
$y_input = GuiCtrlCreateInput("10", 107, 190, 48, 19)
GUISetFont (7)
$x_label = GuiCtrlCreateLabel("x-min(1)", 43, 208)
$y_label = GuiCtrlCreateLabel("y-min(100)", 107, 208)
GUISetFont (9)
GUICtrlCreateGroup ("",-99,-99,1,1);close group
GUICtrlSetState($x_input,$GUI_DISABLE)
GUICtrlSetState($y_input,$GUI_DISABLE)
GUICtrlSetState($x_label,$GUI_DISABLE)
GUICtrlSetState($y_label,$GUI_DISABLE)
GUICtrlSetOnEvent($num_cycles,"NumCycles")

; Global export settings
GuiCtrlCreateGroup("Global export settings",172, 126, 358, 97)
GuiCtrlCreateCheckbox("Export header and engine parameters", 178, 150, 250, 22)
GuiCtrlSetState(-1, $GUI_UNCHECKED)
$checkbox_2 = GuiCtrlCreateCheckbox("Export cycles average", 178, 174, 250, 16)
GuiCtrlSetState(-1, $GUI_UNCHECKED)
GUICtrlSetOnEvent($checkbox_2,"CycleAverage")
$checkbox_3 = GuiCtrlCreateCheckbox("Export crankangle cycle by cycle (e.g. -30 .. 90; -30 .. 90; ... )", 178, 190, 310, 22)
GuiCtrlSetState(-1, $GUI_UNCHECKED)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlCreateGroup ("",-99,-99,1,1);close group



; Available channels
$list_cy_wb = _ArrayCreate ("N")
$count = 1
For $i = 1 To $zylinder_anzahl
    _ArrayInsert ( $list_cy_wb, $count, "Max_" & $i)
    $count = $count+1
    _ArrayInsert ( $list_cy_wb, $count, "AMax_" & $i)
    $count = $count+1
    _ArrayInsert ( $list_cy_wb, $count, "Pcorr_" & $i)
    $count = $count+1
    _ArrayInsert ( $list_cy_wb, $count, "E05_" & $i)
    $count = $count+1
    _ArrayInsert ( $list_cy_wb, $count, "E10_" & $i)
    $count = $count+1
    _ArrayInsert ( $list_cy_wb, $count, "E50_" & $i)
    $count = $count+1
    _ArrayInsert ( $list_cy_wb, $count, "E90_" & $i)
    $count = $count+1
    _ArrayInsert ( $list_cy_wb, $count, "EX_" & $i)
    $count = $count+1
    _ArrayInsert ( $list_cy_wb, $count, "EXave_" & $i)
    $count = $count+1
    _ArrayInsert ( $list_cy_wb, $count, "EXmax_" & $i)
    $count = $count+1
    _ArrayInsert ( $list_cy_wb, $count, "EXmin_" & $i)
    $count = $count+1
    _ArrayInsert ( $list_cy_wb, $count, "EXstd_" & $i)
    $count = $count+1
    _ArrayInsert ( $list_cy_wb, $count, "SOC_" & $i)
    $count = $count+1
    _ArrayInsert ( $list_cy_wb, $count, "EOC_" & $i)
    $count = $count+1
    _ArrayInsert ( $list_cy_wb, $count, "DOC_" & $i)
    $count = $count+1
    _ArrayInsert ( $list_cy_wb, $count, "IMEP_" & $i)
    $count = $count+1
    _ArrayInsert ( $list_cy_wb, $count, "PMEP_" & $i)
    $count = $count+1
    _ArrayInsert ( $list_cy_wb, $count, "NMEP_" & $i)
    $count = $count+1
    _ArrayInsert ( $list_cy_wb, $count, "MF_" & $i)
    $count = $count+1
    _ArrayInsert ( $list_cy_wb, $count, "IWork_" & $i)
    $count = $count+1
    _ArrayInsert ( $list_cy_wb, $count, "IPower_" & $i)
    $count = $count+1
    _ArrayInsert ( $list_cy_wb, $count, "ITorqu_" & $i)
    $count = $count+1
Next
$list_cy_gew = _ArrayCreate ("")
$ccount = 1
$list_cr_wb = _ArrayCreate ("n")
For $i = 1 To $zylinder_anzahl
    _ArrayInsert ($list_cr_wb, $ccount, "P_Cyl_" & $i)
    $ccount = $ccount+1
    _ArrayInsert ($list_cr_wb, $ccount, "IH_" & $i)
    $ccount = $ccount+1
    _ArrayInsert ($list_cr_wb, $ccount, "QH_" & $i)
    $ccount = $ccount+1
    _ArrayInsert ($list_cr_wb, $ccount, "VOL_" & $i)
    $ccount = $ccount+1        
Next
_ArrayInsert ($list_cr_wb, $ccount, "Z_Spannung")
$ccount = $ccount+1
_ArrayInsert ($list_cr_wb, $ccount, "PMV_388")
$ccount = $ccount+1
_ArrayInsert ($list_cr_wb, $ccount, "Z_Strom")
$ccount = $ccount+1
_ArrayInsert ($list_cr_wb, $ccount, "PM_306,8")
$ccount = $ccount+1
_ArrayInsert ($list_cr_wb, $ccount, "Lambda")
$ccount = $ccount+1
_ArrayInsert ($list_cr_wb, $ccount, "Zündsignal")
$ccount = $ccount+1
_ArrayInsert ($list_cr_wb, $ccount, "Einspritz")
$ccount = $ccount+1

$list_cr_gew = _ArrayCreate ("")


$ac_gewaehlt = ""
$cc_gewaehlt = ""
$ac_gewaehlt2 = ""
GuiCtrlCreateLabel("Available channels", 40, 229)
$list_ac = GuiCtrlCreateList("", 19, 243, 166, 160, BitOR($LBS_DISABLENOSCROLL,$WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_EXTENDEDSEL))
GuiCtrlSetData(-1, _ArrayToString ($list_cy_wb,"|"))

; Choosen channels
GuiCtrlCreateLabel("Chosen channels", 300, 229)
$list_cc = GuiCtrlCreateList("", 276, 243, 166, 160, BitOR($LBS_DISABLENOSCROLL,$WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_EXTENDEDSEL))
;GuiCtrlSetData(-1, "")

; >>- und <<-Buttons
$choose_button = GUICtrlCreateButton(">>", 192 ,243, 79, 19)
$choose_not_button = GUICtrlCreateButton("<<", 192, 267, 79, 19)
GUICtrlSetOnEvent($choose_button, "Choose")
GUICtrlSetOnEvent($choose_not_button, "ChooseNot")

; Cancel- und OK-Button (und default-checkbox)
GuiCtrlCreateCheckbox("make this the |default export", 450, 336, 87, 53)
GuiCtrlSetState(-1, $GUI_UNCHECKED)
$cancelButton = GUICtrlCreateButton("Cancel", 450 ,396, 91, 22)
$okButton = GUICtrlCreateButton("Ok", 450, 423, 91, 22)
GUICtrlSetState(-1,$GUI_FOCUS)
$ac_gewaehlt = GUICtrlSetOnEvent($okButton, "OKButton")
GUICtrlSetOnEvent($cancelButton, "Cancel")
GUISetState(@SW_SHOW)

;_________________________________________________________________________________________
;Endlosschleife für alle Controls
While 1
    Sleep(1000)
    If $loop = 1 Then
        $loop = 0
        GUISetState(@SW_HIDE)
        ExitLoop
    EndIf
Wend 
;_________________________________________________________________________________________

;Funktionen des Ok-Buttons, des Cancel-Buttons und der Schließen-Funktion
Func OKButton()
    $ac_gewaehlt = GUICtrlRead($list_ac)
    $ac_gewaehlt2 = _GUICtrlListBoxGetSelItemsText($list_ac)
    $loop = 1
EndFunc


Func CLOSEClicked()
;MsgBox(0, "Abbruch", "Programm wird beendet!")
  Exit
EndFunc

Func Cancel()
;MsgBox(0, "Abbruch", "Programm wird beendet!")
  Exit
EndFunc

;Funktion für die Wahl des Typs der Exportierten Datei
Func TypeChosen()
    $t = GUICtrlRead($type_combo)
    If $t = "Cycles" Then
        GuiCtrlSetData($list_ac, "|" & _ArrayToString ($list_cy_wb,"|"))
;        GuiCtrlSetData($list_cc, "|" & _ArrayToString ($list_cy_gew,"|"))
        GUICtrlSetState($checkbox_3,$GUI_DISABLE)
    ElseIf $t = "Crankangle" Then
        GuiCtrlSetData($list_ac, "|" & _ArrayToString ($list_cr_wb,"|"))
;        GuiCtrlSetData($list_cc, "|" & _ArrayToString ($list_cr_gew,"|"))
        GUICtrlSetState($checkbox_3,$GUI_ENABLE)
    EndIf
EndFunc

Func NumCycles()
    $nc = GUICtrlRead($num_cycles)
    Select
        Case $nc = "all cycles"
            GUICtrlSetState($x_input,$GUI_DISABLE)
            GUICtrlSetState($x_label,$GUI_DISABLE)
            GUICtrlSetState($y_input,$GUI_DISABLE)            
            GUICtrlSetState($y_label,$GUI_DISABLE)
        Case $nc = "cycles from x to y"
            GUICtrlSetState($x_input,$GUI_ENABLE)
            GUICtrlSetState($x_label,$GUI_ENABLE)
            GUICtrlSetState($y_input,$GUI_ENABLE)
            GUICtrlSetState($y_label,$GUI_ENABLE)
        Case $nc = "first y cycles"
            GUICtrlSetState($x_input,$GUI_DISABLE)
            GUICtrlSetState($x_label,$GUI_DISABLE)
            GUICtrlSetState($y_input,$GUI_ENABLE)
            GUICtrlSetState($y_label,$GUI_ENABLE)
        Case $nc = "last y cycles"
            GUICtrlSetState($x_input,$GUI_DISABLE)
            GUICtrlSetState($x_label,$GUI_DISABLE)
            GUICtrlSetState($y_input,$GUI_ENABLE)
            GUICtrlSetState($y_label,$GUI_ENABLE)
    EndSelect
EndFunc

Func CycleAverage()
    $ca = GUICtrlRead($checkbox_2)
    $ccc = GUICtrlGetState($checkbox_3)
        If $ca = $GUI_CHECKED Then
            GUICtrlSetState($num_cycles,$GUI_DISABLE)
            GUICtrlSetState($x_input,$GUI_DISABLE)
            GUICtrlSetState($x_label,$GUI_DISABLE)
            GUICtrlSetState($y_input,$GUI_DISABLE)            
            GUICtrlSetState($y_label,$GUI_DISABLE)
            GUICtrlSetState($checkbox_3,$ccc)
        ElseIf $ca = $GUI_UNCHECKED Then
            GUICtrlSetState($num_cycles,$GUI_ENABLE)
            GUICtrlSetState($x_input,$GUI_ENABLE)
            GUICtrlSetState($x_label,$GUI_ENABLE)
            GUICtrlSetState($y_input,$GUI_ENABLE)            
            GUICtrlSetState($y_label,$GUI_ENABLE)
            GUICtrlSetState($checkbox_3,$ccc)
        EndIf
EndFunc
    
Func Choose()
    $et = _GUICtrlListBoxGetSelItemsText($list_ac)
    $ei = _GUIListBoxGetSelItems($list_ac)
    $t = GUICtrlRead($type_combo)
    If $t = "Cycles" Then
        If _ArrayToString ($et,",") = "" Then
            _ArrayDelete ($list_cy_wb, $ei[1])
            _ArrayInsert ($list_cy_gew, 0, GUICtrlRead ($list_ac))
        Else
            For $i = 1 To _ArrayLength($et)-1
                _ArrayDelete ($list_cy_wb, $ei[$i])
                _ArrayInsert ($list_cy_gew, 0, $et[$i])                
            Next
        EndIf
        GUICtrlSetData ($list_ac, "|" &  _ArrayToString ($list_cy_wb,"|"))
        GUICtrlSetData ($list_cc, "|" &  _ArrayToString ($list_cy_gew,"|"))
    ElseIf $t = "Crankangle" Then
        If _ArrayToString ($et,",") = "" Then
            _ArrayDelete ($list_cr_wb, $ei[1])
            _ArrayInsert ($list_cr_gew, 0, GUICtrlRead ($list_ac))
        Else
            For $i = 1 To _ArrayLength($et)-1
                _ArrayDelete ($list_cr_wb, $ei[$i])
                _ArrayInsert ($list_cr_gew, 0, $et[$i])                
            Next
        EndIf
        GUICtrlSetData ($list_ac, "|" &  _ArrayToString ($list_cy_wb,"|"))
        GUICtrlSetData ($list_cc, "|" &  _ArrayToString ($list_cy_gew,"|"))
    EndIf
EndFunc

Func ChooseNot()
    $cet = _GUICtrlListBoxGetSelItemsText($list_cc)
    $cei = _GUIListBoxGetSelItems($list_cc)
    $t = GUICtrlRead($type_combo)
    If $t = "Cycles" Then
        If _ArrayToString ($cet,",") = "" Then
            _ArrayDelete ($list_cy_gew, $cei[1])
            _ArrayInsert ($list_cy_wb, 0, GUICtrlRead ($list_cc))
        Else
            For $i = 1 To _ArrayLength($cet)-1
                _ArrayDelete ($list_cy_gew, $cei[$i])
                _ArrayInsert ($list_cy_wb, 0, $cet[$i])                
            Next
        EndIf
        GUICtrlSetData ($list_ac, "|" &  _ArrayToString ($list_cy_wb,"|"))
        GUICtrlSetData ($list_cc, "|" &  _ArrayToString ($list_cy_gew,"|"))
    ElseIf $t = "Crankangle" Then
        If _ArrayToString ($cet,",") = "" Then
            _ArrayDelete ($list_cr_gew, $cei[1])
            _ArrayInsert ($list_cr_wb, 0, GUICtrlRead ($list_cc))
        Else
            For $i = 1 To _ArrayLength($cet)-1
                _ArrayDelete ($list_cr_gew, $cei[$i])
                _ArrayInsert ($list_cr_wb, 0, $cet[$i])                
            Next
        EndIf
        GUICtrlSetData ($list_ac, "|" &  _ArrayToString ($list_cr_wb,"|"))
        GUICtrlSetData ($list_cc, "|" &  _ArrayToString ($list_cr_gew,"|"))
    EndIf
EndFunc
;--------------------------------------------------------------------------------------------------------

;Funktion zum Abrufen aller ausgewählten Listbox-Elemente
Func _GUICtrlListBoxGetSelItemsText($h_listbox)
    Local $i, $list = "", $a_text[1], $ret
    For $i = 0 To GuiCtrlSendMsg($h_listbox,$LB_GETCOUNT,0,0) - 1;0 to GetCount
        $ret = GuiCtrlSendMsg($h_listbox,$LB_GETSEL,$i,0)
        If( $ret > 0 )Then
            If(StringLen($list) > 0) Then
                $list = $list & ',' & $i 
            Else
                $list = $i
            EndIf
        ElseIf( $ret == $LB_ERR) Then 
            Return $LB_ERR
        EndIf
    Next;$list should now equal the selected items

    If(StringLen($list) > 0) Then
        Local $a_indices = StringSplit( $list, "," );StringSplit(GetSelItems...
        If @error Then Return $LB_ERR
            Redim $a_text[UBound($a_indices)]
            $a_text[0] = UBound($a_text) - 1
        For $i = 1 to $a_indices[0]
            $a_text[$i] = GuiCtrlRecvMsg($h_listbox,$LB_GETTEXT,$a_indices[$i],1)
        Next
        Return $a_text
    Else
        Return $LB_ERR
    EndIf
EndFunc
;_____________________________________________________________________________________________


Func _GUIListBoxGetSelItems($h_listbox)
    Local $i, $list = "", $ret
    For $i = 0 To GuiCtrlSendMsg($h_listbox,$LB_GETCOUNT,0,0) - 1
        $ret = GuiCtrlSendMsg($h_listbox,$LB_GETSEL,$i,0)
        If( $ret > 0 )Then
            If(StringLen($list) > 0) Then
                $list = $list & ',' & $i 
            Else
                $list = $i
            EndIf
        ElseIf( $ret == $LB_ERR) Then 
            Return $LB_ERR
        EndIf
    Next
    If(StringLen($list) > 0) Then
        Return StringSplit($list,",")
    Else
        Return $LB_ERR
    EndIf
EndFunc
;_____________________________________________________________________________________________


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

Func _ArrayLength($this_array)
    $length = 0
    $help_array = $this_array
    While 1
        If _ArrayToString ($help_array,",") == "" Then ExitLoop
        $length = $length + 1
        _ArrayPop($help_array)
    WEnd
    $length = $length+1
    Return $length
EndFunc

If _ArrayToString ($ac_gewaehlt2,",") = "" Then
    MsgBox(0,"Element_einzeln",$ac_gewaehlt)
Else
    MsgBox(0,"Elemente_mehrere",_ArrayToString ($ac_gewaehlt2,","))
    for $i = 0 to _ArrayLength ($ac_gewaehlt2)-1
        MsgBox(0,"Elemente",$ac_gewaehlt2[$i])
    Next
EndIf

;MsgBox(0,"",)
;MsgBox(0,"",)
Edited by volvox
Link to comment
Share on other sites

the following would have worked

GUICtrlSendMsg ($list_ac, $LB_DELETESTRING, Int($ei[1]), 0)

at looking at this code, i did find a bug in my beta function for returning indices.

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

Might want to take a look at these functions modified, you'll probably have to work your ArrayToString function back in if you still need it.

;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    
Func Choose()
    $et = GUICtrlListBoxGetSelItemsText($list_ac)
    $ei = _GUIListBoxGetSelItems($list_ac)
     If IsArray($ei) Then
        For $i = 1 To $ei[0]
            GUICtrlSendMsg ($list_cc, $LB_INSERTSTRING, -1, $et[$i])
        Next
        For $i = $ei[0] To 1 Step -1
            GUICtrlSendMsg ($list_ac, $LB_DELETESTRING, $ei[$i], 0)
        Next
    EndIf
EndFunc

;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Func ChooseNot()
    $cet = GUICtrlListBoxGetSelItemsText($list_cc)
    $cei = _GUIListBoxGetSelItems($list_cc)
     If IsArray($cei) Then
        For $i = 1 To $cei[0]
            GUICtrlSetData ($list_ac, $cet[$i])
        Next
        For $i = $cei[0] To 1 Step -1
            GUICtrlSendMsg ($list_cc, $LB_DELETESTRING, $cei[$i], 0)
        Next
    EndIf
EndFunc
;--------------------------------------------------------------------------------------------------------

;Funktion zum Abrufen aller ausgewählten Listbox-Elemente
Func GUICtrlListBoxGetSelItemsText($h_listbox)
    Local $i, $s_list = "", $i_ret
    For $i = 0 To GUICtrlSendMsg($h_listbox, $LB_GETCOUNT, 0, 0) - 1
        $i_ret = GUICtrlSendMsg($h_listbox, $LB_GETSEL, $i, 0)
        If ($i_ret > 0) Then
            If (StringLen($s_list) > 0) Then
                $s_list = $s_list & ',' & $i
            Else
                $s_list = $i
            EndIf
        ElseIf ($i_ret == $LB_ERR) Then
            Return $LB_ERR
        EndIf
    Next;$s_list should now equal the selected items
    
    If (StringLen($s_list) > 0) Then
        Local $a_text = StringSplit($s_list, ",")
        For $i = 1 To $a_text[0]
            $a_text[$i] = GUICtrlRecvMsg($h_listbox, $LB_GETTEXT, $a_text[$i], 1)
        Next
        Return $a_text
    Else
        Return $LB_ERR
    EndIf
EndFunc
;_____________________________________________________________________________________________


Func _GUIListBoxGetSelItems($h_listbox)
    Local $i, $list = "", $ret
    For $i = 0 To GuiCtrlSendMsg($h_listbox,$LB_GETCOUNT,0,0) - 1
        $ret = GuiCtrlSendMsg($h_listbox,$LB_GETSEL,$i,0)
        If( $ret > 0 )Then
            If(StringLen($list) > 0) Then
                $list = $list & ',' & $i 
            Else
                $list = $i
            EndIf
        ElseIf( $ret == $LB_ERR) Then 
            Return $LB_ERR
        EndIf
    Next
    If(StringLen($list) > 0) Then
        Local $a_items = StringSplit($list,",")
        For $i = 1 To $a_items[0]
            $a_items[$i] = Int($a_items[$i])
        Next
        Return $a_items
    Else
        Return $LB_ERR
    EndIf
EndFunc

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