Hallo Leute,
habe mal wieder ein Problem mit GDI+ und zwar: Das Programm stürzt immer ab wenn ich auf den Button Fenster Schließen drücke.
#include <GDIPlus.au3>
#include <GUIConstants.au3>
#include <GUIRegion.au3>
#include <WindowsConstants.au3>
$BackgroundPath = "C:\Users\Pascal\Desktop\Neuer Ordner (2)\Backgrounds\gui_background5.jpg"
Global $GUIWidth = 500, $GUIHeight = 600, $GUIXPos = @DesktopWidth / 2 - 250, $GUIYPos = @DesktopHeight / 2 - 300
Global $Gui = GUICreate("GDI+", $GUIWidth, $GUIHeight)
Global $Background = _GDIPlus_ImageLoadFromFile($BackgroundPath), $Graphics = _GDIPlus_GraphicsCreateFromHWND($Gui), $BackgroundImage = _GDIPlus_GraphicsDrawImage($Graphics, $Background, 0, 0)
Opt("GUICloseOnESC",1)
[/autoit][autoit][/autoit][autoit]HotKeySet("{F5}","Info")
[/autoit][autoit][/autoit][autoit][/autoit][autoit]Func Info()
OnAutoItExitRegister("end")
$Gui = GUICreate("GDI+", $GUIWidth, $GUIHeight, $GUIXPos, $GUIYPos, $WS_POPUP, 0)
_GDIPlus_Startup()
[/autoit][autoit][/autoit][autoit]GUISetOnEvent(-3, "end")
GUIRegisterMsg(0x000F,"WM_PAINT")
GUISetState()
$Graphics = _GDIPlus_GraphicsCreateFromHWND($Gui)
$Background = _GDIPlus_ImageLoadFromFile($BackgroundPath)
$BackgroundImage = _GDIPlus_GraphicsDrawImage($Graphics, $Background, 0, 0)
$hBitmap = _GDIPlus_BitmapCreateFromGraphics($GUIWidth, $GUIHeight, $Graphics)
$hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
$ProgEnd = GUICtrlCreateButton("Programm Beenden!", 390, 560, 100, 30)
$WinClose = GUICtrlCreateButton("Fenster Schließen!", 390, 510, 100, 30)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
EndOnESC()
Case $ProgEnd
EndOnESC()
Case $WinClose
end()
EndSwitch
WEnd
EndFunc
Func end()
_GDIPlus_ImageDispose($BackgroundImage)
_GDIPlus_GraphicsDispose($Gui)
_GDIPlus_Shutdown()
Exit
EndFunc
Func WM_PAINT()
$Background = _GDIPlus_ImageLoadFromFile($BackgroundPath)
_GDIPlus_GraphicsDrawImage($Graphics, $Background, 0, 0)
EndFunc
Func EndOnESC()
Exit
EndFunc
while 1
WEnd
Hier das Skript.
PS: Ihr müsst das Bild durch irgend eins von euch ersetzen, damit ihr was auf der GUI seht. Und es ist beabsichtigt dass das Programm keinen Rahmen hat.