Hallo.
Ich versuche schon lange GDI+ zu lernen. Hier ist mal so ein Probe-Skript von mir.
Aber es funktioniert nicht. Kann mir jemand die Fehler erklären.
Spoiler anzeigen
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt('GUIOnEventMode', 1)
OnAutoItExitRegister("_Exit")
_GDIPlus_Startup()
[/autoit] [autoit][/autoit] [autoit]Global $iWidth = 300, $iHeight = 300, $iTitle = "Einfaches GDI+", $iBackground = 0xFF000000 + 0xF0F0F0
[/autoit] [autoit][/autoit] [autoit]$hGUI = GUICreate($iTitle, $iWidth, $iHeight)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
$hBitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $iTitle)
$hBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
GUIRegisterMsg($WM_PAINT, "WM_PAINT")
[/autoit] [autoit][/autoit] [autoit]GUISetState()
[/autoit] [autoit][/autoit] [autoit]While 1
_GDIPlus_GraphicsClear($hBuffer, $iBackground)
_DrawRect($hBuffer, Random(1, 250, 1))
[/autoit] [autoit][/autoit] [autoit]_WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_INTERNALPAINT)
WEnd
Func _Exit()
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_Shutdown()
Exit
EndFunc ;===> _Exit()
Func WM_PAINT()
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iWidth, $iHeight)
Return $GUI_RUNDEFMSG
EndFunc ;===> WM_PAINT()
Func _DrawRect($hGraphic, $x, $iWidth = 50 , $iHeight = 50)
_GDIPlus_GraphicsFillRect($hGraphic, $x, $x, $iWidth, $iHeight, 0)
EndFunc ;===> _DrawRect()