Tach zusammen
Ich bin gerade für mein Moddingforum ein kleines vor-release meines nächsten Programms am basteln (da es dort anscheinend dringend gebraucht wird).
Dafür wollte ich mal ein kleines Template für eine GUI bauen. So weit funktioniert das ganze auch relativ angenehm (sogar den Hover hab ich mit ein bisschen rumgeknorze zum laufen gebracht).
Leider funktioniert noch nicht ganz alles. Ich habe mit der GUICtrlPIC-UDF ein png mit transparenten teilen eingefügt, darüber hab ich nun den hover gelegt.
Nun sollte sich der Butten natürlich noch anklicken lassen aber leider läuft da was ein bisschen schief. Notfallsweise habe ich auch noch versucht das ganze mit einer Art Käfig hinzubekommen, d.h. sobald auf die GUI geklickt wird,
schaut das Programm ob sich der Cursor zwischen den Koordinaten des Buttens befindet. Leider auch hier ohne Erfolg...meine MsgBox erscheint nur, wenn ich ganz unten auf den Button klicke (so ca. 10 pixel vom unteren Buttenrand entfernt) oder direkt unter demm Button (die restlichen 30 pixel).
Ich glaube ich hab den Code schon ziehmlich versaut, aber ich hoffe, dass trotzdem noch jemand versteht, was/wo passieren soll. Die benötigten Daten hab ich euch mal angehängt, hier nur der Code (falls euch das bereits weiterhilft):
Spoiler anzeigen
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUICtrlPic.au3>
Global $ButtonX1 = ((@DesktopWidth / 2) - 313) + 480 ;Calculates the position where the button-area starts on the x-axis
Global $ButtonX2 = ((@DesktopWidth / 2) - 313) + (480 + 130) ;Calculates the position where the button-area ends on the x-axis
Global $ButtonY1 = ((@DesktopHeight / 2) - 206) + 360 ;Calculates the position where the button-area starts on the y-axis
Global $ButtonY2 = ((@DesktopHeight / 2) - 206) + (360 + 40) ;Calculates the position where the button-area ends on the y-axis
$Form2 = GUICreate("CryInstaller - ", 626, 412, -1, -1, BitOR($WS_SYSMENU,$WS_POPUP), BitOR($WS_EX_TOPMOST,$WS_EX_WINDOWEDGE)) ;Creates a new interface without any interaction-possibility
$Pic1 = GUICtrlCreatePic(@ScriptDir &"\Backgrnd.jpg", 0, 0, 626, 412) ;Creates the background picture
$Pic2 = _GUICtrlPic_Create(@ScriptDir &"\Button.png", 480, 360, 130, 40) ;Creates another picture (with a transparent channel)
GUISetState(@SW_SHOW) ;Shows the interface
Global $test = 0 ;Used later to prevent the hover from flickering
[/autoit] [autoit][/autoit] [autoit]While 1
_mover($Pic2, @ScriptDir &"\Button.png", @ScriptDir &"\Button_Hover.png") ;Creates a "hover"-effect on the button-picture
$nMsg = GUIGetMsg()
Switch $nMsg
Case $Pic1
If MouseGetPos(0) > $ButtonX1 And MouseGetPos(0) < $ButtonX2 Then ;If the cursor is inside of the button-picture (x-axis)
If MouseGetPos(1) > $ButtonY1 And MouseGetPos(1) < $ButtonY2 Then ;If the cursor is inside of the button-picture (y-axis)
MsgBox(0, "", "WIN")
EndIf
EndIf
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
[/autoit] [autoit][/autoit] [autoit]Func _mover($control, $bild1, $bild2) ;Function to create a "hover"-effect on the chosen picture
$mpos = GUIGetCursorInfo()
If (IsArray($mpos)) Then
If ($mpos[4] = $control) Then
If $test = 0 Then
$test = 1
_GUICtrlPic_SetImage($control, $bild2)
EndIf
Else
If $test = 1 Then
$test = 0
_GUICtrlPic_SetImage($control, $bild1)
EndIf
EndIf
EndIf
EndFunc