GDI+ Draw Line Frage

  • Hi Com,

    ich habe mit GDI+ viele Linien gezeichnet und will diese einzeln löschen. Geht das ?

    hier ein Foto

    autoit.de/wcf/attachment/7451/


    und mein Skript

    Spoiler anzeigen
    [autoit]


    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <GDIPlus.au3>
    $hGUI = GUICreate("", 625, 443, 237, 168)
    GUISetState(@SW_SHOW)

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

    _GDIPlus_Startup()

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

    Dim $Drawed[5]
    $Drawed[0] = 70 ;x
    $Drawed[1] = 90 ;y
    $Drawed[2] = 200 ;Höhe
    $Drawed[3] = 300 ;Breite
    $Drawed[4] = _GDIPlus_GraphicsCreateFromHWND($hGUI)

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

    _GDIPlus_GraphicsDrawRect($Drawed[4], $Drawed[0], $Drawed[1], $Drawed[3], $Drawed[2])

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

    For $x = 0 to 300
    ;~ $x += 1
    $random = Random(50, 100, 1)
    _DiagramDrawVaule($Drawed, $x, $random)
    Next

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case -3
    Exit

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

    EndSwitch
    WEnd

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

    Func _DiagramDrawVaule($aVaules, $nCount, $nPerc)
    ;~ $x = $aVaules[0]
    ;~ $y = $aVaules[1]
    ;~ $Hoehe = $aVaules[2]
    ;~ $Breite = $aVaules[3]
    If $nCount < 1 Then Return False
    If $nPerc < 0 Then Return False
    Return _GDIPlus_GraphicsDrawLine($aVaules[4], _
    $aVaules[0] + $nCount , _
    $aVaules[1] + $aVaules[2], _
    $aVaules[0] + $nCount, _
    $aVaules[1] + $aVaules[2] - ($nPerc * 2))
    EndFunc ;==>_DiagramDrawVaule

    [/autoit]

    schon mal Danke vom vorraus

  • ich habs so probiert aber es wird nichts gezeichnet obwohn Drwa LIne und Pen Create was Positives zurück geben

    Spoiler anzeigen
    [autoit]


    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <GDIPlus.au3>
    $hGUI = GUICreate("", 625, 443, 237, 168)
    GUISetState(@SW_SHOW)

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

    _GDIPlus_Startup()

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

    Dim $Drawed[6]
    $Drawed[0] = 70 ;x
    $Drawed[1] = 90 ;y
    $Drawed[2] = 200 ;Höhe
    $Drawed[3] = 300 ;Breite
    $Drawed[4] = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $Drawed[5] = 0
    _GDIPlus_GraphicsDrawRect($Drawed[4], $Drawed[0], $Drawed[1], $Drawed[3], $Drawed[2])

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

    While 1
    $random = Random(50, 100, 1)
    $Drawed = _DiagramDrawVaule($Drawed, $random)
    WEnd

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case -3
    _GDIPlus_GraphicsDispose($Drawed[4])
    _GDIPlus_Shutdown()
    Exit
    EndSwitch
    WEnd

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

    Func _DiagramDrawVaule($aVaules, $nPerc)
    Local $sRet
    If $nPerc < 0 Then Return False
    $sRet = _GDIPlus_GraphicsDrawLine($aVaules[4], _
    $aVaules[0] + $aVaules[5], _
    $aVaules[1] + $aVaules[2], _
    $aVaules[0] + $aVaules[5], _
    $aVaules[1] + $aVaules[2] - ($nPerc * 2))
    If $sRet = True Then
    $aVaules[5] += 1
    If $aVaules[5] = $aVaules[3] + 1 Then
    $hPen = _GDIPlus_PenCreate(0x000000FF)
    ;~ MsgBox(0,0,_GDIPlus_PenGetColor($hPen))
    For $x = 1 To $aVaules[3]
    _GDIPlus_GraphicsDrawLine($aVaules[4], _
    $aVaules[0] + $x, _
    $aVaules[1] + $aVaules[2], _
    $aVaules[0] + $x, _
    $aVaules[1] + $aVaules[2] - (100 * 2), $hPen)
    Next
    _GDIPlus_PenDispose($hPen)
    $aVaules[5] = 0
    EndIf
    Return $aVaules
    EndIf
    EndFunc ;==>_DiagramDrawVaule

    [/autoit] [autoit][/autoit] [autoit][/autoit]
  • Probier mal so:

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <GDIPlus.au3>
    $hGUI = GUICreate("", 625, 443, 237, 168)
    GUISetState(@SW_SHOW)

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

    _GDIPlus_Startup()

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

    Dim $Drawed[6]
    $Drawed[0] = 70 ;x
    $Drawed[1] = 90 ;y
    $Drawed[2] = 200 ;Höhe
    $Drawed[3] = 300 ;Breite
    $Drawed[4] = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $Drawed[5] = 0
    _GDIPlus_GraphicsDrawRect($Drawed[4], $Drawed[0], $Drawed[1], $Drawed[3], $Drawed[2])

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

    For $i = 0 To 300
    $random = Random(50, 100, 1)
    $Drawed = _DiagramDrawVaule($Drawed, $random)
    Next

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

    Sleep(1000)

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

    For $i = 100 to 150
    _DiagramDelVaule($Drawed,$i)
    Next

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case -3
    _GDIPlus_GraphicsDispose($Drawed[4])
    _GDIPlus_Shutdown()
    Exit
    EndSwitch
    WEnd

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

    Func _DiagramDelVaule($aVaules,$iSel)
    Local $sRet
    ConsoleWrite(Hex(15790320,6) & @CRLF)
    $hPen = _GDIPlus_PenCreate(0xFFF0F0F0)
    $sRet = _GDIPlus_GraphicsDrawLine($aVaules[4],$aVaules[0]+$iSel,$aVaules[1]+1,$aVaules[0]+$iSel,$aVaules[1]+$aVaules[2]-1,$hPen)
    _GDIPlus_PenDispose($hPen)
    If $sRet = True Then
    Return $aVaules
    EndIf
    EndFunc ;==>_DiagramDrawVaule

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

    Func _DiagramDrawVaule($aVaules, $nPerc)
    Local $sRet
    If $nPerc < 0 Then Return False
    $sRet = _GDIPlus_GraphicsDrawLine($aVaules[4], _
    $aVaules[0] + $aVaules[5], _
    $aVaules[1] + $aVaules[2], _
    $aVaules[0] + $aVaules[5], _
    $aVaules[1] + $aVaules[2] - ($nPerc * 2))
    If $sRet = True Then
    $aVaules[5] += 1
    If $aVaules[5] = $aVaules[3] + 1 Then
    $hPen = _GDIPlus_PenCreate(0x000000FF)
    ;~ MsgBox(0,0,_GDIPlus_PenGetColor($hPen))
    For $x = 1 To $aVaules[3]
    _GDIPlus_GraphicsDrawLine($aVaules[4], _
    $aVaules[0] + $x, _
    $aVaules[1] + $aVaules[2], _
    $aVaules[0] + $x, _
    $aVaules[1] + $aVaules[2] - (100 * 2), $hPen)
    Next
    _GDIPlus_PenDispose($hPen)
    $aVaules[5] = 0
    EndIf
    Return $aVaules
    EndIf
    EndFunc ;==>_DiagramDrawVaule

    [/autoit]