Guten Tag,
wie im Titel beschrieben möchte ich bei Auftreten des $WM_PAINT-Ereignisses die GUI nur teilweise neu zeichnen, da mir das Neuzeichnen aller Elemente zu lange dauert und unnötiges Flickern auslöst...
Ich habe das in einem kleinen Beipsiel versucht zu erklären (siehe Anhang).
Hier trotzdem nochmal der Quellcode:
Spoiler anzeigen
#include-once
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
#include <WinAPI.au3>
Opt("GUIOnEventMode", 1) ; Wechsle in den OnEvent Modus
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]$h_Wnd = GUICreate('GUI', 800, 600, -1, -1,$WS_POPUP );
GUISetOnEvent($GUI_EVENT_CLOSE, "_exitMain")
$Lbl_Title = GUICtrlCreateLabel('', 0, 0, 800, 25, -1, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetState ( $Lbl_Title, $GUI_ONTOP )
_GDIPlus_Startup()
$hFormat = _GDIPlus_StringFormatCreate ()
$hFamily = _GDIPlus_FontFamilyCreate ("Arial")
$hBrush = _GDIPlus_BrushCreateSolid (0xFFFFFFFF)
$hFont = _GDIPlus_FontCreate ($hFamily, 12, 0,2)
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($h_Wnd)
$hImg_Title = _GDIPlus_ImageLoadFromFile("Title.png")
GUISetState()
_Redraw_GUI()
GUIRegisterMsg($WM_PAINT, "_Redraw_GUI")
While True
Sleep(1000)
WEnd
Func _exitMain()
_CollectGarbage()
_GDIPlus_Shutdown()
Exit
EndFunc
Func _Redraw_GUI()
_WinAPI_RedrawWindow($h_Wnd, 0, 0, $RDW_UPDATENOW)
_GDIPlus_GraphicsDrawImageRectRect($hGraphic, $hImg_Title, 0,0,_GDIPlus_ImageGetWidth($hImg_Title)-1,_GDIPlus_ImageGetHeight($hImg_Title),0,0,800,25)
$hBrush = _GDIPlus_BrushCreateSolid (0xFFFFFFFF)
$tLayout = _GDIPlus_RectFCreate ( 20, 8, 450, 18)
_GDIPlus_GraphicsDrawStringEx ($hGraphic, "This is my Title - Exit with {ESC}", $hFont, $tLayout, $hFormat, $hBrush)
_GDIPlus_GraphicsDrawImageRectRect($hGraphic, $hImg_Title, 0,0,_GDIPlus_ImageGetWidth($hImg_Title)-1,_GDIPlus_ImageGetHeight($hImg_Title),100,200,100,100)
$tLayout = _GDIPlus_RectFCreate ( 105, 205, 90, 30)
_GDIPlus_GraphicsDrawStringEx ($hGraphic, "This is GUIpart 1", $hFont, $tLayout, $hFormat, $hBrush)
_GDIPlus_GraphicsDrawImageRectRect($hGraphic, $hImg_Title, 0,0,_GDIPlus_ImageGetWidth($hImg_Title)-1,_GDIPlus_ImageGetHeight($hImg_Title),600,200,100,100)
$tLayout = _GDIPlus_RectFCreate ( 605, 205, 90, 30)
_GDIPlus_GraphicsDrawStringEx ($hGraphic, "This is GUIpart 2", $hFont, $tLayout, $hFormat, $hBrush)
$hBrush = _GDIPlus_BrushCreateSolid (0xFF000000)
$tLayout = _GDIPlus_RectFCreate ( 200, 405, 400, 100)
_GDIPlus_GraphicsDrawStringEx ($hGraphic, "When parts of the GUI are hidden by other Windows and this GUI is activated again, how can I optimize the _RedrawGUI() to only redraw the previous hidden parts?"&@lf&@lf& _
"Try Moving the GUI party out of the desktop, and then moving back. You will see the flicker/delay when redraw occurs...I want to minimize that.", $hFont, $tLayout, $hFormat, $hBrush)
_WinAPI_RedrawWindow($h_Wnd, 0, 0, $RDW_VALIDATE)
Return $GUI_RUNDEFMSG
EndFunc
Func _CollectGarbage()
_GDIPlus_StringFormatDispose($hFormat)
_GDIPlus_FontFamilyDispose($hFamily)
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_FontDispose($hFont)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_ImageDispose($hImg_Title)
Endfunc
Für einen Hinweis wäre ich dankbar
Grüße
JStaxton