Hallo,
Ich möchte gerne eine 2.te GUI, mit dem Quelltext von UEZ (Star Wars Scroller by UEZ 2011) nutzen. Das Thema "Probleme mit dem schließen der 2. GUI) war schon des öfteren im Forum, leider, was ich auch versucht habe, es geht bei mir nicht. Ich scheine da was falsch zu verstehen.
Daher bitte nicht gleich mit Steinen werfen.
Wenn ich in meiner ersten Gui auf den Button "Info" klicke, erscheint die zweite GUI ordnungsgemäß und die Animation von UEZ startet bestens, die Funtion tut. Nur das schließen der GUI 2 funktioniert nicht.
Ich nutze zum erstellen von Gui2 folgenden Code:
Const $FlatnessDefault = 0.25
Const $width = 1000
Const $height = 700
$gui2 = GUICreate("Informationen", $width, $height, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_THICKFRAME))
GUISetBkColor(0xD7E4F2)
GUISetIcon("D:\!Autoit Software\ICON\logo_orange.ico", -1)
GUISetOnEvent($GUI_EVENT_CLOSE, __GUI_EVENT_CLOSE2__, $gui2)
GUISetState(@SW_HIDE);#Au3Stripper_Ignore_Funcs
Für die Info-Funktion (öffnen von GUI 2 und abspulen der Animation) nutze ich diesen Code:
Func __idButton_info__()
HotKeySet("{ESC}","Quit") ;Press ESC key to quit
GUISetState(@SW_HIDE, $g_hGUI)
GUISetState(@SW_SHOW, $gui2)
_GDIPlus_Startup()
$hGraphics = _GDIPlus_GraphicsCreateFromHWND($gui2)
$hBitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $hGraphics)
$hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)
$hBmp_back = _GDIPlus_BitmapCreateFromGraphics($width, $height, $hGraphics)
For $i = 1 To 3000
$x = Random(0, $width, 1)
$y = Random(0, $height, 1)
$c = Hex(Random(0x10, 0xF0, 1), 2)
DllCall($ghGDIPDll, "uint", "GdipBitmapSetPixel", "hwnd", $hBmp_back, "int", $x, "int", $y, "uint", "0xFF" & $c & $c & $c)
Next
_GDIPlus_GraphicsSetSmoothingMode($hContext, 2)
$hBrush = _GDIPlus_LineBrushCreate(0, 0, 0, $height, 0xFF000000, 0xFFFFFFFF, 0)
$speedy = 5
Local $sy = 1900
Local $dy = 150
$text = "Star Wars Scroller |Coded by| | UEZ 2011| |Everything is|Done using| |G D I +| | |Powered by| |AutoIt| | |" & ChrW(9787)
$aString = StringSplit($text, "|", 2)
Dim $aText[UBound($aString)][3]
For $i = 0 To UBound($aText) - 1
$aText[$i][0] = $aString[$i]
$aText[$i][1] = $sy + $i * $dy
Next
$hFamily = _GDIPlus_FontFamilyCreate ("Arial")
$tLayout = _GDIPlus_RectFCreate (0, 0, 0, 0)
$hFont = _GDIPlus_FontCreate ($hFamily, 50, 0)
For $i = 0 To UBound($aText) - 1
$aText[$i][0] = StringUpper($aText[$i][0])
$aInfo = _GDIPlus_GraphicsMeasureString($hGraphics, $aText[$i][0], $hFont, $tLayout, 0)
$aText[$i][2] = Floor($width / 1.9 - (DllStructGetData($aInfo[0], "Width") / 2))
Next
_GDIPlus_FontDispose ($hFont)
$hPath = _GDIPlus_PathCreate()
Dim $aPoints[5][2] = [ [4, 0], _ ;create trapezoid for the perspective
[$width / 2 - $width / 3, $height * 0.20], _ ;x1, y1
[$width / 2 + $width / 3, $height * 0.20], _ ;x2, y2
[0, $height * 0.75], _ ;x3, y3
[$width , $height * 0.75]] ;x4, y4
GUISetOnEvent(-3, "__GUI_EVENT_CLOSE2__", $gui2)
$1 = True
While Sleep(30)
_GDIPlus_GraphicsClear($hContext, 0x38000000)
_GDIPlus_GraphicsDrawImageRect($hContext, $hBmp_back, 0, 0, $width, $height)
For $i = 0 To UBound($aText) - 1
DllStructSetData($tLayout, "x", $aText[$i][2])
DllStructSetData($tLayout, "y", $aText[$i][1])
_GDIPlus_PathAddString($hPath, $aText[$i][0], $tLayout, $hFamily, 0, 80)
$aText[$i][1] -= $speedy
Next
If $1 Then
$aWB = _GDIPlus_PathGetWorldBounds($hPath)
$1 = False
EndIf
_GDIPlus_PathWarp($hPath, 0, $aPoints, 0, 0, $width, 1500)
_GDIPlus_GraphicsFillPath($hContext, $hPath, $hBrush)
_GDIPlus_PathReset($hPath)
_GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $width, $height)
If $aText[UBound($aText) - 1][1] < $aWB[3] / 16 Then $speedy *= 1.005
If $aText[UBound($aText) - 1][1] < $sy * -7 Then
For $i = 0 To UBound($aText) - 1
$aText[$i][1] = $sy + $i * $dy
Next
$speedy = 5
EndIf
WEnd
EndFunc ;==>__idButton_info__
Alles anzeigen
Zum beenden von GUI2 versuchte ich diesen Code.
Func __GUI_EVENT_CLOSE2__()
GUISetState(@SW_HIDE, $gui2)
_GDIPlus_FontFamilyDispose ($hFamily)
_GDIPlus_PathDispose($hPath)
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_GraphicsDispose($hContext)
_GDIPlus_BitmapDispose($hBmp_back)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_Shutdown
GUISetState(@SW_SHOW, $g_hGUI)
EndFunc ;__GUI_EVENT_CLOSE2__
Alles anzeigen
Ferner habe ich Opt('GUIOnEventMode', 1) und Opt('MustDeclareVars', 1) aktiv.
Und ich hatte in die Schleife (Code von UEZ) bereits $GUI_EVENT_CLOSE eingebaut, hat aber leider auch nicht funktioniert.
Hatte das mit "switch" auch schon mit "select" versucht.
Wäre Euch über den, zum Gui2 schließen bringenden Codeschnipsel sehr dankbar.