GDI+

    • Offizieller Beitrag

    Beispiel ?

  • Du musst WM_PAINT-message verwenden.

    Windows sendet diese message an dein GUI, wenn es sich neuzeichnen soll.

    [autoit]

    #include <GDIPlus.au3>
    #include <WindowsConstants.au3>

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

    _GDIPlus_Startup()
    $hGUI = GUICreate("GUI")
    GUISetState()

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

    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsDrawRect($hGraphic, 50, 50, 100, 100)

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

    GUIRegisterMsg($WM_PAINT, "WM_PAINT")

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

    While GUIGetMsg() <> -3
    WEnd

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

    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()

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

    Func WM_PAINT($hWnd, $Msg, $wParam, $lParam)
    _GDIPlus_GraphicsDrawRect($hGraphic, 50, 50, 100, 100)
    EndFunc ;==>WM_PAINT

    [/autoit]

    lgE

  • So wird's auch beim wiederherstellen neugezeichnet:

    Spoiler anzeigen
    [autoit]

    #include <GDIPlus.au3>
    #include <WindowsConstants.au3>
    #include <GUIConstantsEx.au3>

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

    Opt("GUIOnEventMode", 1)

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

    _GDIPlus_Startup()
    $hGUI = GUICreate("GUI")
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Ende")
    GUISetOnEvent($GUI_EVENT_RESTORE, "WM_PAINT")
    GUISetState()

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

    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsDrawRect($hGraphic, 50, 50, 100, 100)

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

    GUIRegisterMsg($WM_PAINT, "WM_PAINT")

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

    While 1
    Sleep(10000)
    WEnd

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

    Func WM_PAINT($hWnd, $Msg, $wParam, $lParam)
    _GDIPlus_GraphicsDrawRect($hGraphic, 50, 50, 100, 100)
    EndFunc ;==>WM_PAINT

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

    Func _Ende()
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
    Exit
    EndFunc

    [/autoit]
  • ähm sorry wenn ich hier meine frage reinposte :whistling:
    ich wollte nur wissen wie ich eine mit _GDIPlus_GraphicsDrawLine "gemalte" linie wieder kürzer mache?
    ich blick da iwie net durch^^ (noch nicht)

    Padmak

  • naja weils bei mir so ausschaut

    Spoiler anzeigen
    [autoit]


    #include <WindowsConstants.au3>
    #include <GDIPlus.au3>
    #include <GuiStatusBar.au3>
    #include <String.au3>
    #include <GUIConstantsEx.au3>
    #include-once
    #RequireAdmin
    #NoTrayIcon
    ;Scripted by Padmak, http://www.autoit.de
    Local $StatusBar1_PartsWidth[4] = [85, 225, 380, 200]
    _GDIPlus_Startup()
    ;Standardzeugs
    $Form1 = GUICreate("Slider Test", 550, 400, 193, 125)
    $hWnd = WinGetHandle("Slider Test")
    $Slider1 = GUICtrlCreateSlider(8, 8, 484, 45)
    $Progress1 = GUICtrlCreateProgress(8, 64, 484, 17)
    $Label1 = GUICtrlCreateLabel("Aktueller Stand in %:", 8, 96, 101, 17)
    $Input1 = GUICtrlCreateInput("", 8, 120, 97, 21)
    $Label2 = GUICtrlCreateLabel("Selbst ändern:", 152, 96, 72, 17)
    $Input2 = GUICtrlCreateInput("", 152, 120, 73, 21)
    $Button1 = GUICtrlCreateButton("Go", 264, 120, 75, 25, 0)
    $Button2 = GUICtrlCreateButton("Beenden", 344, 120, 75, 25, 0)
    $Label3 = GUICtrlCreateLabel("0 %", 8, 160, 61, 17)
    $Label4 = GUICtrlCreateLabel("", 8, 184, 500, 28)
    $slider = GUICtrlRead($Slider1)
    GUICtrlSetFont(-1, 10, 800, 0, "Comic Sans MS")
    GUICtrlCreateUpdown($Input2)
    GUICtrlSetLimit($Input2, 100, 0)
    GUICtrlSetData($Input2, "0")
    GUICtrlSetState($Input2, $GUI_FOCUS)
    ;Standartzeugs ende
    ;Statusbar
    $StatusBar1 = _GUICtrlStatusBar_Create($Form1)
    _GUICtrlStatusBar_SetParts($StatusBar1, $StatusBar1_PartsWidth)
    _GUICtrlStatusBar_SetText($StatusBar1, "Aktuelle %: " & $slider)
    _GUICtrlStatusBar_SetText($StatusBar1, "Aktuelle Uhrzeit: " & @HOUR & ":" & @MIN & ":" & @SEC, 1)
    _GUICtrlStatusBar_SetText($StatusBar1, "Aktuelles Datum: " & @MDAY & ":" & @MON & ":" & @YEAR, 2)
    _GUICtrlStatusBar_SetText($StatusBar1, "Aktueller Benutzer: " & @UserName, 3)
    ;Statusbar ende
    ;Gdi+
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd)
    $hPen = _GDIPlus_PenCreate(0xFF000000, 2)
    $Pen = _GDIPlus_PenCreate(0xFFFFFFFF, 2)
    _GDIPlus_PenSetWidth($hPen, 6)
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 250, 10, 250, $hPen)
    ;Gdi+ ende
    GUISetState()

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    _GDIPlus_Shutdown()
    Case $Button1
    $data = GUICtrlRead($Input2)
    If $data > 100 Then
    $data = 100
    GUICtrlSetData($Input2, $data)
    EndIf
    GUICtrlSetData($Progress1, $data)
    GUICtrlSetData($Slider1, $data)
    Case $Button2
    Exit
    EndSwitch
    $slider = GUICtrlRead($Slider1)
    $test = GUICtrlRead($Progress1)
    If $slider <> $test Then
    GUICtrlSetData($Progress1, $slider)
    GUICtrlSetData($Input1, $slider)
    $data = GUICtrlRead($Input2)
    If $data > 100 Then
    GUICtrlSetData($Input2, 100)
    ElseIf $data < 0 Then
    GUICtrlSetData($Input2, 0)
    EndIf
    GUICtrlSetData($Label3, $slider & " %")
    GUICtrlSetData($Label4, _StringRepeat("|", $slider))
    _GUICtrlStatusBar_SetText($StatusBar1, "Aktuelle %: " & $slider)
    _GUICtrlStatusBar_SetText($StatusBar1, "Aktuelle Uhrzeit: " & @HOUR & ":" & @MIN & ":" & @SEC, 1)
    _GUICtrlStatusBar_SetText($StatusBar1, "Aktuelles Datum: " & @MDAY & ":" & @MON & ":" & @YEAR, 2)
    _GUICtrlStatusBar_SetText($StatusBar1, "Aktueller Benutzer: " & @UserName, 3)
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 250, $slider * 5, 250, $hPen)
    _GDIPlus_GraphicsDrawLine($hGraphic, _GDIPlus_PenGetWidth($hPen), 250, _GDIPlus_PenGetWidth($hPen), 250, $Pen)
    EndIf
    Sleep(50)
    WEnd

    [/autoit]


    is son bisschen übung^^
    und nun möchte ich dass die linie unten mit dem rest mitwandert
    im moment wird sie nur größer
    dankeschön schonmal^^

    Padmak

  • Probiers ma mit dem:

    [autoit]

    $hPenBk = _GDIPlus_PenCreate(_GetBkColor(), 2)
    _GDIPlus_PenSetWidth($hPenBk, 6)

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

    _GDIPlus_GraphicsDrawLine($hGraphic, 10+($Slider * 5), 250, 10+(100*5) , 250, $hPenBk)
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 250, 10 + ($Slider * 5), 250, $hPen)

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

    Func _GetBkColor()
    Local $Color=Hex(BitAND(BitShift(String(Binary(_WinAPI_GetSysColor($COLOR_3DFACE))), 8), 0xFFFFFF))
    Return "0xFF" & StringTrimLeft($Color,2)
    EndFunc

    [/autoit]

    lgE