Problem mit WS_EX_COMPOSITED

  • Schönen Abend alle.

    Und hier gleich zu meinem Problem:

    Ich habe ein Script geschrieben, was einen String in GDI+ darstellt. Mit dem Hotkey 1 soll man das Bild bewegen können. Das klappt ja auch soweit ganz gut. Nur flackert es dann halt total. Ich hab es dann mit VM_COMPOSITED versucht, was aber nur zufolge hatte, dass garnichtsmehr angezeigt wird.

    Source ohne WS_EX_COMPOSITED
    [autoit]

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

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

    Global $Y = 0, _
    $dll = DllOpen("user32.dll")

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

    Global Const $WS_EX_COMPOSITED = 0x2000000

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

    HotKeySet("1", "_test")

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

    _GDIPlus_Startup()

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

    $hWnd = GUICreate("GDI+ Example", 300, 200, -1, -1, BitOR($WS_CAPTION, $WS_SYSMENU));, $WS_EX_COMPOSITED)
    GUISetState()

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

    GUIRegisterMsg(0xF, "MY_PAINT")

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

    $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hWnd)
    $hBrush = _GDIPlus_BrushCreateSolid(0xFF009900)
    $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    $hFont = _GDIPlus_FontCreate($hFamily, 36)
    $hLayout = _GDIPlus_RectFCreate(0, 0, 300, 200)
    $hStringFormat = _GDIPlus_StringFormatCreate()
    _GDIPlus_StringFormatSetAlign($hStringFormat, 1)
    DllCall($dll, "lparam", "SendMessage", "hwnd", $hWnd, "int", 0xF, "wparam", 0, "lparam", 0)

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

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

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

    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_StringFormatDispose($hStringFormat)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()

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

    Func MY_PAINT($hWnd, $msg, $wParam, $lParam)
    DllCall($ghGDIPDll, "int", "GdipGraphicsClear", "hwnd", $hGraphics, "int", 0xFF000000)
    DllCall($ghGDIPDll, "int", "GdipDrawString", "hwnd", $hGraphics, "wstr", "AutoIT Rocks", "int", -1, "hwnd", $hFont, "ptr", DllStructGetPtr($hLayout), "hwnd", $hStringFormat, "hwnd", $hBrush)
    Return $GUI_RUNDEFMSG
    EndFunc ;==>MY_PAINT

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

    Func _test()
    $Y = $Y + 1
    $hLayout = _GDIPlus_RectFCreate(0, $Y, 300, 200)
    DllCall($dll, "lparam", "SendMessage", "hwnd", $hWnd, "int", 0x0000000F, "wparam", 0, "lparam", 0)
    EndFunc ;==>_test

    [/autoit]
    Source mit VS_EX_COMPOSITED
    [autoit]

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

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

    Global $Y = 0, _
    $dll = DllOpen("user32.dll")

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

    Global Const $WS_EX_COMPOSITED = 0x2000000

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

    HotKeySet("1", "_test")

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

    _GDIPlus_Startup()

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

    $hWnd = GUICreate("GDI+ Example", 300, 200, -1, -1, BitOR($WS_CAPTION, $WS_SYSMENU), $WS_EX_COMPOSITED)
    GUISetState()

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

    GUIRegisterMsg(0xF, "MY_PAINT")

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

    $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hWnd)
    $hBrush = _GDIPlus_BrushCreateSolid(0xFF009900)
    $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    $hFont = _GDIPlus_FontCreate($hFamily, 36)
    $hLayout = _GDIPlus_RectFCreate(0, 0, 300, 200)
    $hStringFormat = _GDIPlus_StringFormatCreate()
    _GDIPlus_StringFormatSetAlign($hStringFormat, 1)
    DllCall($dll, "lparam", "SendMessage", "hwnd", $hWnd, "int", 0xF, "wparam", 0, "lparam", 0)

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

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

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

    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_StringFormatDispose($hStringFormat)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()

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

    Func MY_PAINT($hWnd, $msg, $wParam, $lParam)
    DllCall($ghGDIPDll, "int", "GdipGraphicsClear", "hwnd", $hGraphics, "int", 0xFF000000)
    DllCall($ghGDIPDll, "int", "GdipDrawString", "hwnd", $hGraphics, "wstr", "AutoIT Rocks", "int", -1, "hwnd", $hFont, "ptr", DllStructGetPtr($hLayout), "hwnd", $hStringFormat, "hwnd", $hBrush)
    Return $GUI_RUNDEFMSG
    EndFunc ;==>MY_PAINT

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

    Func _test()
    $Y = $Y + 1
    $hLayout = _GDIPlus_RectFCreate(0, $Y, 300, 200)
    DllCall($dll, "lparam", "SendMessage", "hwnd", $hWnd, "int", 0x0000000F, "wparam", 0, "lparam", 0)
    EndFunc ;==>_test

    [/autoit]

    Danke schonmal für die Antworten!

    MfG,
    H2112

    Edit:
    Hab Win XP ServicPack 3

    Edit2:
    Problem hat sich gelöst, antwort im Vorletzten Post.

    Zitat

    [Heute, 11:39] Raupi: Soll ich es dir machen?
    [Heute, 11:47] BugFix: "Soll ich es dir machen? " - also Raupi !! bitte nicht so öffentlich :rofl:

    Zitat

    [Heute, 11:51] BugFix: und ich werde es mir jetzt machen - das Mittagessen :P

    AMsg UDF v1.00.00 IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII 100%
    OwnStyle UDF Version 1.10.00 IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII 100%

    3 Mal editiert, zuletzt von H2112 (21. Oktober 2009 um 18:00)

    • Offizieller Beitrag

    Dein Problem mit dem geflackere kann ich nicht nachvollziehen, bei mir flackert nichts.
    Welches Windows benutzt du? Hab es auf Vista getestet.

    Probier mal das Script.

    Spoiler anzeigen
    [autoit]

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

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

    Global $Y = 0, _
    $dll = DllOpen("user32.dll")

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

    Global Const $WS_EX_COMPOSITED = 0x2000000

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

    HotKeySet("1", "_test")

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

    _GDIPlus_Startup()

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

    $hWnd = GUICreate("GDI+ Example", 300, 200, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPCHILDREN, $WS_CLIPSIBLINGS))
    GUISetState()

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

    GUIRegisterMsg(0xF, "MY_PAINT")

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

    $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hWnd)
    $hBrush = _GDIPlus_BrushCreateSolid(0xFF009900)
    $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    $hFont = _GDIPlus_FontCreate($hFamily, 36)
    $hLayout = _GDIPlus_RectFCreate(0, 0, 300, 200)
    $hStringFormat = _GDIPlus_StringFormatCreate()
    _GDIPlus_StringFormatSetAlign($hStringFormat, 1)
    DllCall($dll, "lparam", "SendMessage", "hwnd", $hWnd, "int", 0xF, "wparam", 0, "lparam", 0)

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

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

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

    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_StringFormatDispose($hStringFormat)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()

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

    Func MY_PAINT($hWnd, $msg, $wParam, $lParam)
    DllCall($ghGDIPDll, "int", "GdipGraphicsClear", "hwnd", $hGraphics, "int", 0xFF000000)
    DllCall($ghGDIPDll, "int", "GdipDrawString", "hwnd", $hGraphics, "wstr", "AutoIT Rocks", "int", -1, "hwnd", $hFont, "ptr", DllStructGetPtr($hLayout), "hwnd", $hStringFormat, "hwnd", $hBrush)
    Return $GUI_RUNDEFMSG
    EndFunc ;==>MY_PAINT

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

    Func _test()
    $Y = $Y + 1
    $hLayout = _GDIPlus_RectFCreate(0, $Y, 300, 200)
    DllCall($dll, "lparam", "SendMessage", "hwnd", $hWnd, "int", 0x0000000F, "wparam", 0, "lparam", 0)
    EndFunc ;==>_test

    [/autoit]

    Edit: Der Titel deines Threads ist leicht verwirrend. Du solltest WS_EX_COMPOSITED verwenden und nicht WM_COMPOSITED.

  • Danke für die schnelle Antwort. :)

    Ich hab Win XP ServicePack 3.

    Dein Script flackert genauso wie das meine.

    Zitat

    [Heute, 11:39] Raupi: Soll ich es dir machen?
    [Heute, 11:47] BugFix: "Soll ich es dir machen? " - also Raupi !! bitte nicht so öffentlich :rofl:

    Zitat

    [Heute, 11:51] BugFix: und ich werde es mir jetzt machen - das Mittagessen :P

    AMsg UDF v1.00.00 IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII 100%
    OwnStyle UDF Version 1.10.00 IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII 100%

  • Ja Danke, das hat zwar nich mein Problem gelöst, aber hat in Erfahrung gebracht, dass Win XP anscheinend anders mit GDI+ arbeitet als Win Vista.

    Zitat

    [Heute, 11:39] Raupi: Soll ich es dir machen?
    [Heute, 11:47] BugFix: "Soll ich es dir machen? " - also Raupi !! bitte nicht so öffentlich :rofl:

    Zitat

    [Heute, 11:51] BugFix: und ich werde es mir jetzt machen - das Mittagessen :P

    AMsg UDF v1.00.00 IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII 100%
    OwnStyle UDF Version 1.10.00 IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII 100%

    Einmal editiert, zuletzt von H2112 (20. Oktober 2009 um 21:05)

  • Das ist irgendwie komisch. :/

    Kann mir denn jemand zeigen, wie das mit WS_EX_COMPOSITED funktionierd?

    Zitat

    [Heute, 11:39] Raupi: Soll ich es dir machen?
    [Heute, 11:47] BugFix: "Soll ich es dir machen? " - also Raupi !! bitte nicht so öffentlich :rofl:

    Zitat

    [Heute, 11:51] BugFix: und ich werde es mir jetzt machen - das Mittagessen :P

    AMsg UDF v1.00.00 IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII 100%
    OwnStyle UDF Version 1.10.00 IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII 100%

  • @simon: Jetzt wird zwar etwas angezeigt, aber das flackern ist immer noch da.

    Zitat

    [Heute, 11:39] Raupi: Soll ich es dir machen?
    [Heute, 11:47] BugFix: "Soll ich es dir machen? " - also Raupi !! bitte nicht so öffentlich :rofl:

    Zitat

    [Heute, 11:51] BugFix: und ich werde es mir jetzt machen - das Mittagessen :P

    AMsg UDF v1.00.00 IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII 100%
    OwnStyle UDF Version 1.10.00 IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII 100%

  • Hi,

    Windows XP hat ein Problem mit dem Fensterstil WS_EX_COMPOSITED.
    In der Titelleiste, z.B., werden die Schaltflächen des Systemmenüs (minimieren, maximieren, schliessen) nicht mehr "gehighlighted".

    EDIT:
    Probiere doch einmal, ob das hier hilft...

    [autoit]


    GUIRegisterMsg ($WM_ERASEBKGND, "OnEraseBkGnd")

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

    ;...

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

    Func OnEraseBkGnd ($hwnd, $message, $wParam, $lParam)

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

    Return 1

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

    EndFunc

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


    Gruß
    Greenhorn


    Einmal editiert, zuletzt von Greenhorn (20. Oktober 2009 um 21:40)

  • Ich glaub ich habe dei Lösung, alos bei mir flackert es jetzt nicht mehr :)

    Spoiler anzeigen
    [autoit]

    ;Von Hendrik Norkowski (Jam00 auf autoit.de)
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <GUIConstants.au3>
    #include <GDIPlus.au3>

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

    $hWnd = GUICreate ("GDI+ Example",300,200,Default,Default,BitOR($WS_SYSMENU,$WS_DLGFRAME,$WS_POPUP))
    GUISetBkColor (0x000000)
    GUISetState ()
    $Y = 0
    _GDIPlus_Startup()
    $hGraphics = _GDIPlus_GraphicsCreateFromHWND ($hWnd)
    $bitmap = _GDIPlus_BitmapCreateFromGraphics(300, 200, $hGraphics)
    $backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap)
    _GDIPlus_GraphicsSetSmoothingMode($backbuffer, 2)
    $hBrush = _GDIPlus_BrushCreateSolid(0xFF009900)
    _GDIPlus_BitmapCreateFromGraphics(300, 200, $hGraphics)
    $hFormat = _GDIPlus_StringFormatCreate ()
    _GDIPlus_StringFormatSetAlign($hFormat, 1)
    $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    $Font = _GDIPlus_FontCreate($hFamily, 48)
    $Rect = _GDIPlus_RectFCreate (0,0,300,200)
    _GDIPlus_GraphicsDrawStringEx ($backbuffer, "Hallo Welt!", $Font, $Rect, $hFormat, $hBrush)
    _GDIPlus_GraphicsDrawImageRect($hGraphics, $bitmap, 0, 0, 300, 200)

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

    HotKeySet ("1","_Down")
    Do
    Sleep (100)
    Until GUIGetMsg () = -3

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

    Func _Down ()
    HotKeySet ("1")
    $Y += 1
    DllStructSetData($Rect, "x", 0)
    DllStructSetData($Rect, "y",$Y )
    _GDIPlus_GraphicsClear($backbuffer, 0x90000000)
    _GDIPlus_GraphicsDrawStringEx ($backbuffer, "Hallo Welt!", $Font, $Rect, $hFormat, $hBrush)
    _GDIPlus_GraphicsDrawImageRect($hGraphics, $bitmap, 0, 0, 300, 200)
    HotKeySet ("1","_Down")
    EndFunc

    [/autoit]

    mfg. Jam00

  • Danke. :D
    Das funktioniert wunderbar.

    Thema gelöst!

    Zitat

    [Heute, 11:39] Raupi: Soll ich es dir machen?
    [Heute, 11:47] BugFix: "Soll ich es dir machen? " - also Raupi !! bitte nicht so öffentlich :rofl:

    Zitat

    [Heute, 11:51] BugFix: und ich werde es mir jetzt machen - das Mittagessen :P

    AMsg UDF v1.00.00 IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII 100%
    OwnStyle UDF Version 1.10.00 IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII 100%