_GUICtrlListView_GetItemTextArray

  • Hallo Autoit.de Mitlgieder,
    heute mal wieder ein Problem, dass nach Grübeln in der Shotbox, bisher noch nicht gelöst wurde.
    Es geht um _GUICtrlListView_GetItemTextArray; das zurückgegebene Array lass ich mir in _ArrayDisplay anzeigen - das aber bis auf das Elemet [0] leer ist.

    Hier das Script, könnt's auch gerne testen un ausprobieren, es werden keine weiteren Daten benötigt:

    Spoiler anzeigen
    [autoit]


    #include <ButtonConstants.au3>
    #include <SliderConstants.au3>
    #include <GuiSlider.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <Misc.au3>
    #include <GDIPlus.au3>
    #include <SliderConstants.au3>
    #include <GuiListView.au3>
    #include <Array.au3>

    [/autoit] [autoit][/autoit] [autoit]

    ;###User Options Start
    $sGridColor = 0xFF800000 ;Gitterfarbe in ARGB
    $sCoordfarbe = 0xFF99FFFF ;Koordinatensystemfarbe in ARGB
    $sBackgroundcolor = 0x000000 ;Hintergrundfarbe in RGB
    $sXColor = 0xFFFFFFFF ;Farbe der X, die beim Klicken erscheinen in ARGB
    $iLineWidth = 6 ;Graphenlinienbreite
    ;###User Options Ende

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;###Options Start
    Opt("GuiOnEventMode", 1)
    HotKeySet("{ESC}", "ende")
    OnAutoItExitRegister("ende")
    Const $iNullx = Round(@DesktopWidth / 2)
    Const $iNully = Round(@DesktopHeight / 2)
    $sTitle = "Funktionsgraph"
    $sTitle2 = "Einstellungsmenü"
    ;###Options Ende

    [/autoit] [autoit][/autoit] [autoit]

    ;###Gui Start
    $hGui = GUICreate($sTitle, @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, $WS_EX_TOOLWINDOW)
    GUISetBkColor($sBackgroundcolor, $hGui)
    GUISetState(@SW_SHOW, $hGui)
    ;Neue Gui:
    $hSettings = GUICreate($sTitle2, 350, 280, @DesktopWidth - 350, @DesktopHeight - 280, BitOR($WS_CAPTION, $WS_GROUP), $WS_EX_TOPMOST, $hGui)
    GUISetBkColor(0xFFFFFF, $hSettings)
    $cMousePos = GUICtrlCreateLabel("MousePos:", 0, 0, 300, 20)
    GUICtrlSetFont(-1, 10, 800, 0, "Tahoma")
    $cCGrid = GUICtrlCreateCheckbox("Grid", 0, 25, 50, 20)
    GUICtrlSetFont(-1, 10, 800, 0, "Tahoma")
    GUICtrlSetState(-1, $GUI_CHECKED)
    $cCUnitCircle = GUICtrlCreateCheckbox("Unit Circle", 52, 25, 85, 20)
    GUICtrlSetFont(-1, 10, 800, 0, "Tahoma")
    $cCScale = GUICtrlCreateCheckbox("Scale", 140, 25, 60, 20)
    GUICtrlSetFont(-1, 10, 800, 0, "Tahoma")
    GUICtrlSetState(-1, $GUI_CHECKED)
    GUICtrlCreateButton("Generate", 202, 25, 80, 20)
    GUICtrlSetOnEvent(-1, "generate")
    GUICtrlCreateButton("Add function", 0, 60, 90, 20)
    GUICtrlSetOnEvent(-1, "addfunc")
    GUICtrlCreateButton("Delete function", 95, 60, 100, 20)
    GUICtrlCreateButton("Quit", 200, 60, 100, 20)
    GUICtrlSetOnEvent(-1, "ende")
    $cObjektlist = GUICtrlCreateListView("Objekttyp |Wert |Farbe ", 0, 82, 300, 140)
    $cZoom = GUICtrlCreateSlider(310, 55, 25, 165, $TBS_VERT)
    GUICtrlSetLimit(-1, 200, 1)
    GUICtrlSetData($cZoom, 20)
    $cZoomlabel = GUICtrlCreateLabel("Zoom:" & @CRLF & GUICtrlRead($cZoom), 296, 0, 40, 60)
    GUICtrlSetFont(-1, 10, 800, 0, "Tahoma")
    For $i = 10 To 200 Step 10
    _GUICtrlSlider_SetTic($cZoom, $i)
    Next
    ControlFocus($sTitle2, "", $cObjektlist)
    GUISetState(@SW_SHOW, $hSettings)
    ;###Gui Ende

    [/autoit] [autoit][/autoit] [autoit]

    ;###GDIPlus Start
    _GDIPlus_Startup()
    $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
    $Pen1 = _GDIPlus_PenCreate($sGridColor, 1)
    $Pen2 = _GDIPlus_PenCreate($sCoordfarbe, 1)
    $Pen3 = _GDIPlus_PenCreate($sXColor, 1)
    $Brush1 = _GDIPlus_BrushCreateSolid(0xFFFFFFFF)
    ;###GDIPlus Ende

    [/autoit] [autoit][/autoit] [autoit]

    ;generate()

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $aPos = MouseGetPos()
    $iZoom = GUICtrlRead($cZoom) ;Zoom
    $iAbstand = Round(@DesktopHeight / $iZoom)
    GUICtrlSetData($cMousePos, "Mousepos: (" & Round(($aPos[0] - $iNullx) / $iAbstand, 2) & "|" & Round(calcytocoords($aPos[1]) / $iAbstand, 2) & ")")
    If _IsPressed(01) Then
    drawX()
    Do
    Until Not _IsPressed(01)
    EndIf
    GUICtrlSetData($cZoomlabel, "Zoom:" & @CRLF & GUICtrlRead($cZoom))
    Sleep(100)
    WEnd
    ende()

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func generate()
    GUISetBkColor($sBackgroundcolor, $hGui)
    $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
    If GUICtrlRead($cCGrid) = $GUI_CHECKED Then
    $bGrid = True
    Else
    $bGrid = False
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    If GUICtrlRead($cCScale) = $GUI_CHECKED Then
    $bScale = True
    Else
    $bScale = False
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    If GUICtrlRead($cCUnitCircle) = $GUI_CHECKED Then
    $bEinheitskreis = True
    Else
    $bEinheitskreis = False
    EndIf
    ;###Netz erstellen Start
    For $i = 1 To @DesktopWidth / $iAbstand ;Beschriftung
    If $bGrid = True Then
    _GDIPlus_GraphicsDrawLine($hGraphics, $iNullx + $iAbstand * $i, 0, $iNullx + $iAbstand * $i, @DesktopHeight, $Pen2) ;x rechts
    _GDIPlus_GraphicsDrawLine($hGraphics, 0, $iNully - $iAbstand * $i, @DesktopWidth, $iNully - $iAbstand * $i, $Pen2);y oben
    _GDIPlus_GraphicsDrawLine($hGraphics, 0, $iNully + $iAbstand * $i, @DesktopWidth, $iNully + $iAbstand * $i, $Pen2);y unten
    _GDIPlus_GraphicsDrawLine($hGraphics, $iNullx - $iAbstand * $i, 0, $iNullx - $iAbstand * $i, @DesktopWidth, $Pen2);x links
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    If $bScale = True Then
    _GDIPlus_GraphicsDrawLine($hGraphics, $iNullx + $iAbstand * $i, $iNully - 10, $iNullx + $iAbstand * $i, $iNully + 10, $Pen1) ;x rechts
    _GDIPlus_GraphicsDrawLine($hGraphics, $iNullx - 10, $iNully - $iAbstand * $i, $iNullx + 10, $iNully - $iAbstand * $i, $Pen1);y oben
    _GDIPlus_GraphicsDrawLine($hGraphics, $iNullx - 10, $iNully + $iAbstand * $i, $iNullx + 10, $iNully + $iAbstand * $i, $Pen1);y unten
    _GDIPlus_GraphicsDrawLine($hGraphics, $iNullx - $iAbstand * $i, $iNully - 10, $iNullx - $iAbstand * $i, $iNully + 10, $Pen1);x links
    EndIf
    Next
    _GDIPlus_GraphicsDrawLine($hGraphics, 0, $iNully, @DesktopWidth, $iNully, $Pen1) ;x-Achse
    _GDIPlus_GraphicsDrawLine($hGraphics, $iNullx, 0, $iNullx, @DesktopHeight, $Pen1);y-Achse
    If $bEinheitskreis = True Then
    _GDIPlus_GraphicsDrawEllipse($hGraphics, $iNullx - ($iAbstand * 1), $iNully - ($iAbstand * 1), $iAbstand * 2, $iAbstand * 2, $Pen1)
    EndIf

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    GUISetState(@SW_DISABLE, $hSettings)
    Sleep(1000)
    ;###Netz erstellen Ende
    $Y = _GUICtrlListView_GetItemTextArray($cObjektlist, 1)
    ;For $c = 0 To $Y[0]
    ; If $Y[$c][0] <> "" Then
    ; draw($Y[$c][0], $Y[$c][1])
    ; EndIf
    ;Next
    _ArrayDisplay($Y)
    GUISetState(@SW_ENABLE, $hSettings)
    ToolTip("Done!")
    Sleep(5000)
    ToolTip("")
    EndFunc ;==>generate

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func draw($sFunktion, $sColor)
    Local $Brush1 = _GDIPlus_BrushCreateSolid($sColor)
    $sFunktion = StringReplace($sFunktion, "x", "($i / $iAbstand)")
    ToolTip(StringReplace(StringReplace($sFunktion, "$i", "x"), " / xAbstand", ""))
    Sleep(2000)
    For $i = -(@DesktopWidth / 2) To @DesktopWidth / 2
    ToolTip("i = " & $i & "; X = " & Round(Calcxtocoords($i)) & "; Y = " & Round(calcytocoords(Execute($sFunktion))) & "; Funktionswert = " & Execute($sFunktion))
    _GDIPlus_GraphicsFillEllipse($hGraphics, Round(Calcxtocoords($i) - ($iLineWidth / 2)), Round(calcytocoords(Execute($sFunktion) * ($iAbstand)) - ($iLineWidth / 2)), $iLineWidth, $iLineWidth, $Brush1)
    Next
    EndFunc ;==>draw

    [/autoit] [autoit][/autoit] [autoit]

    Func drawX()
    $aPos = MouseGetPos()
    _GDIPlus_GraphicsDrawLine($hGraphics, $aPos[0] - 7, $aPos[1] - 7, $aPos[0] + 7, $aPos[1] + 7, $Pen3)
    _GDIPlus_GraphicsDrawLine($hGraphics, $aPos[0] + 7, $aPos[1] - 7, $aPos[0] - 7, $aPos[1] + 7, $Pen3)
    EndFunc ;==>drawX

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func addfunc()
    Do
    Local $sInputFunktion = InputBox("Function", "Enter a function, please!" & @CRLF & "Use x for the variable!" & @CRLF & "Y=", Default, Default, Default, Default, Default, Default, $hGui)
    Until $sInputFunktion <> "" Or @error
    If @error Then Return
    Do
    Local $sColor = _ChooseColor(2, 0x990000, Default, $hGui)
    Until $sColor <> -1 Or @error
    If @error Then Return
    $sColor = StringReplace($sColor, "0x", "0xFF")
    GUICtrlCreateListViewItem("Function|" & $sInputFunktion & "|" & $sColor, $cObjektlist)
    EndFunc ;==>addfunc

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func calcxtocoords($iX)
    Return $iX + $iNullx
    EndFunc ;==>calcxtocoords

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func calcytocoords($iY)
    Return (-$iY + $iNully)
    EndFunc ;==>calcytocoords

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func ende()
    _GDIPlus_PenDispose($Pen1)
    _GDIPlus_PenDispose($Pen2)
    _GDIPlus_PenDispose($Pen3)
    _GDIPlus_BrushDispose($Brush1)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    Exit
    EndFunc ;==>ende

    [/autoit]

    Vielen Dank für eure Hilfe im Vorraus,
    viele Grüße,
    stayawayknight


    Edit: Hat sich dank nuts gelöst; Fehler lag beim Index.
    Danke!

    Einmal editiert, zuletzt von stayawayknight (17. November 2010 um 22:18)

  • Hallo StayAwayKnight,

    Zitat von Hilfe

    Fehler: Array mit dem folgenden Format:
    [0] - Anzahl von Spalten im Array (0)

    dann wird wohl das ausgewählte (in deinem Fall das 1. Item nicht existieren) falls du das aktuell markierte möchtest musst du -1 nehmen bzw. den Parameter weglassen. Bedenke auch die Indices beginnen bei 0

    Edit: falls du das zuletzt erstellte möchtest musst du es so machen

    [autoit]

    $Y = _GUICtrlListView_GetItemTextArray($cObjektlist, _GUICtrlListView_GetItemCount($cObjektlist)-1)

    [/autoit]

    mfg autoBert

    Einmal editiert, zuletzt von autoBert (17. November 2010 um 22:26)