Hey, ich möchte gerne für mein Defender spiel (wobei ich auch noch hilfe benötige, (gibs auch ein Thred hier im forum) da es irgendwie laggt) ein Titelbildschirm machen.
Ich habe mir bereits ein Hintergrund in GIMP gemacht, & wollte jz mit _GDIPlus_GraphicsDrawStringEx die anderen String erstellen. Sie sollen den Titel :"Start" & "Optionen" & "Beenden" haben. Doch leider kenne ich mich damit auch noch nicht so gut aus ich habe bereits von name22 ein schönes beispiel Skript bekommen. Damit habe ich wenigstens die ansätze verstanden. Doch leider schaffe ich es nicht bei 2 (oder mehr) Strings die Aktionen zu Registrieren. (Ich habe die Variablen ebend flott hinzugefügt, wollte jz keine Arrys dafür erstellen (weiß nicht ob die da sogar besser wären))
Ich glaube mein Problem liegt einfach nur an der Case & If abfrage, da er auch 2 mal die MsgBox aufruft wenn ich den 2ten String anklicke. Doch ich weiß leider nichtmal was $GUI_EVENT_PRIMARYDOWN ist
Spoiler anzeigen
#include <GDIPlus.au3>
#include <GUIConstants.au3>
#include <WindowsConstants.au3>
;- Author: name22 (http://www.autoit.de)
[/autoit] [autoit][/autoit] [autoit]$iX = 50
$iY = 30
$XX = 150
$YY = 30
$sFont = "Arial"
$iFontSize = 20
$sString = "AutoIt"
$hWnd = GUICreate("Beispiel", 500, 100)
GUISetState()
_GDIPlus_Startup()
[/autoit] [autoit][/autoit] [autoit]$hGraphics = _GDIPlus_GraphicsCreateFromHWND($hWnd)
_GDIPlus_GraphicsSetSmoothingMode($hGraphics, 2)
$hBrush = _GDIPlus_BrushCreateSolid(0xFFF4567F)
$hBrush1 = _GDIPlus_BrushCreateSolid(0xFF0000FF)
$hStringFormat = _GDIPlus_StringFormatCreate()
$hFamily = _GDIPlus_FontFamilyCreate($sFont)
$hFont = _GDIPlus_FontCreate($hFamily, $iFontSize)
$tLayout = _GDIPlus_RectFCreate($iX, $iY) ;X und Y Koordinaten angeben, Breite und Höhe ist irrelevant und kann 0 bleiben
$tLayout1 = _GDIPlus_RectFCreate($XX, $YY) ;X und Y Koordinaten angeben, Breite und Höhe ist irrelevant und kann 0 bleiben
$aInfo = _GDIPlus_GraphicsMeasureString($hGraphics, $sString, $hFont, $tLayout, $hStringFormat) ;Misst die Breite/Höhe des angegebenen Strings mit der Schrift in $hFont
$aInfo1 = _GDIPlus_GraphicsMeasureString($hGraphics, $sString, $hFont, $tLayout1, $hStringFormat) ;Misst die Breite/Höhe des angegebenen Strings mit der Schrift in $hFont
;Die gewollten Daten stecken in einem DLLStruct in $aInfo[0] die anderen Array Elemente enthalten weitere Daten die hier nicht benötigt werden.
;Wie das Struct aufgebaut ist, steht in der Hilfe zu $tagGDIPRECTF
$iWidth = DllStructGetData($aInfo[0], "Width") ;Breite
$iHeight = DllStructGetData($aInfo[0], "Height") ;Höhe
$XWidth = DllStructGetData($aInfo1[0], "Width") ;Breite
$YHeight = DllStructGetData($aInfo1[0], "Height") ;Höhe
;Hier wird das DLLStruct für PtInRect erstellt
$tRect_AutoIt = DllStructCreate($tagRECT)
DllStructSetData($tRect_AutoIt, "Left", $iX) ;Linke Kante des Rechtecks
DllStructSetData($tRect_AutoIt, "Top", $iY) ;Obere Kante des Rechtecks
DllStructSetData($tRect_AutoIt, "Right", $iX + $iWidth) ;Rechte Kante des Rechtecks
DllStructSetData($tRect_AutoIt, "Bottom", $iY + $iHeight) ;Untere Kante des Rechtecks
DllStructSetData($tRect_AutoIt, "Left", $XX) ;Linke Kante des Rechtecks
DllStructSetData($tRect_AutoIt, "Top", $YY) ;Obere Kante des Rechtecks
DllStructSetData($tRect_AutoIt, "Right", $XX + $XWidth) ;Rechte Kante des Rechtecks
DllStructSetData($tRect_AutoIt, "Bottom", $YY + $YHeight) ;Untere Kante des Rechtecks
_Paint()
GUIRegisterMsg($WM_PAINT, "_Paint") ;Neuzeichnen, falls Fenster verdeckt wurde.
While True
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
Case $GUI_EVENT_PRIMARYDOWN ;Sobald die linke Maustaste innerhalb der Clientarea des Fensters geklickt wird, wird diese Nachricht gesendet.
$tPoint_MousePos = _WinAPI_GetMousePos(True, $hWnd);Mausposition wird in einem DLLStruct zurückgegeben. Die Parameter geben an, dass die Koordinaten rel. zum Fenster sein sollen.
If _WinAPI_PtInRect($tRect_AutoIt, $tPoint_MousePos) Then MsgBox(64, "Event", "Mausklick auf 'AutoIt' registriert.")
If _WinAPI_PtInRect($tRect_AutoIt, $tPoint_MousePos) Then MsgBox(64, "Event", "Mausklick auf 'AutoIt' registriert.")
EndSwitch
WEnd
Func _Paint()
_GDIPlus_GraphicsClear($hGraphics, 0xFFFFFFFF)
_GDIPlus_GraphicsDrawStringEx($hGraphics, $sString, $hFont, $tLayout, $hStringFormat, $hBrush) ;String zeichnen
_GDIPlus_GraphicsDrawStringEx($hGraphics, $sString, $hFont, $tLayout1, $hStringFormat, $hBrush1) ;String zeichnen
EndFunc
;Aufräumen - Wichtig!
_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_StringFormatDispose($hStringFormat)
_GDIPlus_FontFamilyDispose($hFamily)
_GDIPlus_FontDispose($hFont)
_GDIPlus_Shutdown()