GDIPlus

  • Kurz und Knapp : Wie kann ich GDIPlus vor dem Wegwischen mittels anderer Fenster schützen ?

  • Mit GUIRegisterMsg vielleicht?

    Hier ein Beispiel, das ein Farbverlauf erstellt (ist nicht die beste Methode) und das Fenster entsprechend neu zeichnet:

    Spoiler anzeigen
    [autoit]


    ;Coded by UEZ
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <GUIConstants.au3>
    #include <GDIPlus.au3>

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

    Global Const $width = 640
    Global Const $height = 480
    Global $graphics, $backbuffer, $bitmap, $Pen, $i, $pi_div_180 = 4 * ATan(1) / 180

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

    Global $title = "GDI+ Color Gradient"

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

    Opt("GUIOnEventMode", 1)
    $hwnd = GUICreate($title, $width, $height, -1, -1) ;, BitOR($WS_SYSMENU,$WS_DLGFRAME,$WS_POPUP))
    GUISetOnEvent($GUI_EVENT_CLOSE, "Close")
    GUISetState()

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

    _GDIPlus_Startup()
    $graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)
    $bitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $graphics)
    $backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap)
    $pen = _GDIPlus_PenCreate(0xFF000000, 1)

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

    ;you can move this lines below until Do...Until loop to Do...Until loop and make some realtime effects
    $r = 0x00
    $g = 0x00
    $b = 0xFF
    $c = "0xFF" & Hex($r, 2) & Hex($g, 2) & Hex($b, 2)
    $i = 255 / $width

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

    _GDIPlus_GraphicsClear($backbuffer)

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

    For $x = 0 To $width
    _GDIPlus_GraphicsDrawLine($backbuffer, $x, 0, $x, $width, $pen)
    _GDIPlus_PenSetColor($pen, $c)
    $r += $i
    $g += $i
    $c = "0xEF" & Hex($r, 2) & Hex($g, 2) & Hex($b, 2)
    Next

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

    _GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, $width, $height)

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

    GUIRegisterMsg(0x0F, "MY_PAINT"); Register PAINT-Event 0x000F = $WM_PAINT (WindowsConstants.au3)
    GUIRegisterMsg(0x85, "MY_PAINT"); $WM_NCPAINT = 0x0085 (WindowsConstants.au3)Restore after Minimize.

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

    $b = 0

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

    Do

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

    Until False * Not Sleep(30)

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

    ;Func to redraw on PAINT MSG
    Func MY_PAINT($hWnd, $msg, $wParam, $lParam)
    ; The sequencial order of these two commands is important.
    _GDIPlus_GraphicsDrawImage($graphics, $bitmap, 0, 0)
    _WinAPI_RedrawWindow($hwnd, "", "", BitOR($RDW_INVALIDATE, $RDW_UPDATENOW, $RDW_FRAME)); , $RDW_ALLCHILDREN
    Return $GUI_RUNDEFMSG
    EndFunc ;==>MY_PAINT

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

    Func Close()
    _GDIPlus_PenDispose($pen)
    _GDIPlus_GraphicsDispose($backbuffer)
    _GDIPlus_BitmapDispose($bitmap)
    _GDIPlus_GraphicsDispose($graphics)
    _GDIPlus_Shutdown()
    WinClose($hwnd)
    Exit
    EndFunc

    [/autoit]

    Die Funktion MY_PAINT() zeichnet das Fenster neu!


    Meinst du das?

    Gruß,
    UEZ

    Auch am Arsch geht ein Weg vorbei...

    ¯\_(ツ)_/¯

  • Ja soetwas meinte ich ;)
    Aber wenn ich das Fenster schnell hinundher bewege dann stockt es sehr unangenehm ;(
    Hast du dafür auch noch eine Lösung ? :D

  • Vielleicht so was:

    Spoiler anzeigen
    [autoit]


    #AutoIt3Wrapper_UseUpx=n
    #include <GDIPlus.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>

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

    Opt("GUIOnEventMode", 1)
    Opt('MustDeclareVars', 1)

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

    Local $iX = 320
    Local $iY = 320
    Local $hWnd = GUICreate("GDI+ Test", $iX, $iY)
    GUISetState()
    GUISetOnEvent(-3, "_Close")

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

    _GDIPlus_Startup()
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hWnd)
    Local $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iX, $iY, $hGraphics)
    Local $hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    Local $pen_size = 128
    Local $hPen = _GDIPlus_PenCreate(0xFF00FF00, $pen_size)
    Local $sleep = 20
    _GDIPlus_GraphicsSetSmoothingMode($hBackbuffer, 2)

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

    GUIRegisterMsg($WM_TIMER, "Draw") ;$WM_TIMER = 0x0113
    DllCall("User32.dll", "int", "SetTimer", "hwnd", $hwnd, "int", 0, "int", $sleep, "int", 0)

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

    While Sleep(30)

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

    WEnd

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

    Func Draw()
    _GDIPlus_GraphicsClear($hBackbuffer)
    _GDIPlus_GraphicsDrawEllipse($hBackbuffer, $pen_size / 2, $pen_size / 2, $iX - $pen_size, $iY - $pen_size, $hPen)
    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $iX, $iY)
    EndFunc

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

    Func _Close()
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_GraphicsDispose($hBackbuffer)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    Exit
    EndFunc

    [/autoit]

    Gruß,
    UEZ

    Auch am Arsch geht ein Weg vorbei...

    ¯\_(ツ)_/¯