Hover Button Lässt sich nicht auswählen

  • 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
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <GUICtrlPic.au3>

    [/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit]

    $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

    [/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit]
  • Die steht ja unter dem Link 8| aber ok

    Spoiler anzeigen
    [autoit]

    ;#INDEX# =======================================================================================================================
    ; Title .........: GUICtrlPic
    ; AutoIt Version : 3.3.6.1
    ; Description ...: Ergänzende Funktionen für Pic-Controls
    ; Author(s) .....: Großvater
    ; Dll ...........: GDI32.dll, GDIPlus.dll
    ; ===============================================================================================================================

    [/autoit] [autoit][/autoit] [autoit]

    ; #CURRENT# =====================================================================================================================
    ; _GUICtrlPic_Create
    ; _GUICtrlPic_SetImage
    ; _GUICtrlPic_LoadImage
    ; _GUICtrlPic_ScaleBitmap
    ; _GUICtrlPic_GradientFill
    ; _GUICtrlPic_Invert
    ; ===============================================================================================================================

    [/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ====================================================================================================================
    ; Name...........: _GUICtrlPic_Create
    ; Description ...: Pic-Control für alle von GDIPlus unterstützten Formate ggf. mit Transparenz erstellen.
    ; Syntax.........: _GUICtrlPic_Create($sPicPath, $iLeft, $iTop[, $iWidth = 0[, $iHeight = 0[, $uStyles = -1[, $uExStyles = -1[, $bKeepAspectRatio = False]]]]])
    ; Parameters ....: Die Parameter entsprechen bis auf den letzten der AU3-Funktion GUICtrlCreatePic()
    ; $bKeepAspectRatio - Seitenverhältnis bei der Größenanpassung beachten:
    ; |True - ja
    ; |False - nein
    ; |Default - nein
    ; Return values .: Im Erfolgsfall: ControlID aus GUICtrlCreatePic()
    ; Im Fehlerfall: False, @error und @extended enthalten ergänzende fehlerbeschreibende Werte.
    ; Author ........: Großvater (http://www.autoit.de)
    ; Modified.......:
    ; Remarks .......:
    ; Related .......:
    ; Link ..........:
    ; Example .......:
    ; ===============================================================================================================================
    Func _GUICtrlPic_Create($sPicPath, $iLeft, $iTop, $iWidth = 0, $iHeight = 0, $uStyles = -1, $uExStyles = -1, $bKeepAspectRatio = False)
    Local Const $IMAGE_BITMAP = 0x0000
    Local Const $STM_SETIMAGE = 0x0172
    Local $aResult, $hBitmap, $hImage, $Height, $Width, $CtrlID
    Local $aBitmap = _GUICtrlPic_LoadImage($sPicPath)
    If @error Then Return SetError(@error, @extended, False)
    $hBitmap = $aBitmap[0]
    $Width = $aBitmap[1]
    $Height = $aBitmap[2]
    If $iWidth = 0 And $iHeight = 0 Then
    $iWidth = $Width
    $iHeight = $Height
    Else
    $hBitmap = _GUICtrlPic_ScaleBitmap($hBitmap, $iWidth, $iHeight, $Width, $Height, $bKeepAspectRatio)
    If @error Then Return SetError(@error, @extended, False)
    EndIf
    $CtrlID = GUICtrlCreatePic("", $iLeft, $iTop, $iWidth, $iHeight, $uStyles, $uExStyles)
    GUICtrlSendMsg($CtrlID, $STM_SETIMAGE, $IMAGE_BITMAP, $hBitmap)
    DllCall("Gdi32.dll", "BOOL", "DeleteObject", "Handle", $hBitmap)
    Return $CtrlID
    EndFunc ;==>_GUICtrlPic_Create

    [/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ====================================================================================================================
    ; Name...........: _GUICtrlPic_SetImage
    ; Description ...: Neues Bild in Pic-Control erstellen.
    ; Syntax.........: _GUICtrlPic_SetImage($idPic, $sPicPath[, $bKeepAspectRatio = False])
    ; Parameters ....: $idPic - ID des PIC-Controls
    ; $sPicPath - vollständiger Pfad der Bilddatei
    ; $bKeepAspectRatio - Seitenverhältnis bei der Größenanpassung beachten:
    ; |True - ja
    ; |False - nein
    ; |Default - nein
    ; Return values .: Im Erfolgsfall: True
    ; Im Fehlerfall: False, @error und @extended enthalten ggf. ergänzende fehlerbeschreibende Werte
    ; Author ........: Großvater (http://www.autoit.de)
    ; Modified.......:
    ; Remarks .......:
    ; Related .......:
    ; Link ..........:
    ; Example .......:
    ; ===============================================================================================================================
    Func _GUICtrlPic_SetImage($idPic, $sPicPath, $bKeepAspectRatio = False)
    Local Const $IMAGE_BITMAP = 0x0000
    Local Const $STM_SETIMAGE = 0x0172
    Local Const $STM_GETIMAGE = 0x0173
    Local $aSize, $hBM, $hBitmap, $Height, $Width
    Local $aBitmap = _GUICtrlPic_LoadImage($sPicPath)
    If @error Or $aBitmap[0] = 0 Then Return SetError(@error, @extended, False)
    $hBitmap = $aBitmap[0]
    $Width = $aBitmap[1]
    $Height = $aBitmap[2]
    $aSize = WinGetClientSize(GUICtrlGetHandle($idPic))
    $hBitmap = _GUICtrlPic_ScaleBitmap($hBitmap, $aSize[0], $aSize[1], $Width, $Height, $bKeepAspectRatio)
    $hBM = GUICtrlSendMsg($idPic, $STM_GETIMAGE, $IMAGE_BITMAP, 0)
    If $hBM Then DllCall("Gdi32.dll", "BOOL", "DeleteObject", "Handle", $hBM)
    GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hBitmap)
    DllCall("Gdi32.dll", "BOOL", "DeleteObject", "Handle", $hBitmap)
    GUICtrlSetState($idPic, $GUI_SHOW)
    Return True
    EndFunc ;==>_GUICtrlPic_SetImage

    [/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ====================================================================================================================
    ; Name...........: _GUICtrlPic_LoadImage
    ; Description ...: Bilddatei laden und HBITMAP erzeugen
    ; Syntax.........: _GUICtrlPic_LoadImage($sPicPath)
    ; Parameters ....: $sPicPath - vollständiger Pfad der Bilddatei
    ; Return values .: Im Erfolgsfall: Array mit drei Einträgen, Array[0] enthält ein HBITMAP-Handle,
    ; Array[1] die Breite und Array[2] die Höhe der Bitmap
    ; Im Fehlerfall: False, @error und @extended enthalten ggf. ergänzende fehlerbeschreibende Werte
    ; Author ........: Großvater (http://www.autoit.de)
    ; Modified.......:
    ; Remarks .......: Die Funktion kann auch einzeln genutzt werden, um eine Bitmap zu laden und dann per
    ; GUICtrlSendMsg($idPIC, $STM_SETIMAGE, $IMAGE_BITMAP, $hBitmap) einem Pic-Control zuzuweisen.
    ; Related .......:
    ; Link ..........:
    ; Example .......:
    ; ===============================================================================================================================
    Func _GUICtrlPic_LoadImage($sPicPath)
    Local $aResult, $hBitmap, $hImage, $Height, $Width
    Local $aBitmap[3] = [0, 0, 0]
    Local $hGDIPDll = DllOpen("GDIPlus.dll")
    If $hGDIPDll = -1 Then Return SetError(1, 2, $aBitmap)
    Local $tInput = DllStructCreate("UINT Version;ptr Callback;BOOL NoThread;BOOL NoCodecs")
    Local $pInput = DllStructGetPtr($tInput)
    Local $tToken = DllStructCreate("ULONG_PTR Data")
    Local $pToken = DllStructGetPtr($tToken)
    DllStructSetData($tInput, "Version", 1)
    $aResult = DllCall($hGDIPDll, "INT", "GdiplusStartup", "Ptr", $pToken, "Ptr", $pInput, "Ptr", 0)
    If @error Then Return SetError(@error, @extended, $aBitmap)
    $aResult = DllCall($hGDIPDll, "INT", "GdipLoadImageFromFile", "WStr", $sPicPath, "Ptr*", 0)
    If @error Or $aResult[2] = 0 Then
    Local $Error = @error, $Extended = @extended
    DllCall($hGDIPDll, "None", "GdiplusShutdown", "Ptr", DllStructGetData($tToken, "Data"))
    DllClose($hGDIPDll)
    Return SetError($Error, $Extended, $aBitmap)
    EndIf
    $hImage = $aResult[2]
    $aResult = DllCall($hGDIPDll, "INT", "GdipGetImageWidth", "Handle", $hImage, "UINT*", 0)
    $Width = $aResult[2]
    $aResult = DllCall($hGDIPDll, "INT", "GdipGetImageHeight", "Handle", $hImage, "UINT*", 0)
    $Height = $aResult[2]
    $aResult = DllCall($hGDIPDll, "INT", "GdipCreateHBITMAPFromBitmap", "Handle", $hImage, "Ptr*", 0, "DWORD", 0xFF000000)
    $hBitmap = $aResult[2]
    DllCall($hGDIPDll, "INT", "GdipDisposeImage", "Handle", $hImage)
    DllCall($hGDIPDll, "None", "GdiplusShutdown", "Ptr", DllStructGetData($tToken, "Data"))
    DllClose($hGDIPDll)
    $aBitmap[0] = $hBitmap
    $aBitmap[1] = $Width
    $aBitmap[2] = $Height
    Return $aBitmap
    EndFunc ;==>_GUICtrlPic_LoadImage

    [/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ====================================================================================================================
    ; Name...........: _GUICtrlPic_ScaleBitmap
    ; Description ...: Geladene Bitmap skalieren.
    ; Syntax.........: _GUICtrlPic_ScaleBitmap($hBitmap, $iNewW, $iNewH[, $iBitmapW[, $iBitmapH[, $bKeepAspectRatio = False]]])
    ; Parameters ....: $hBitmap - HBITMAP-Handle
    ; $iNewW - gewünschte Breite in Pixeln
    ; $iNewH - gewünschte Höhe in Pixeln
    ; $iBitmapW - aktuelle Breite der Bitmap (wird nur für das Skalieren im Seitenverhältnis benötigt
    ; $iBitmapH - aktuelle Höhe der Bitmap (wird nur für das Skalieren im Seitenverhältnis benötigt
    ; $bKeepAspectRatio - Seitenverhältnis bei der Größenanpassung beachten:
    ; |True - ja
    ; |False - nein
    ; |Default - nein
    ; Return values .: Im Erfolgsfall: HBITMAP-Handle für die skalierte Bitmap
    ; Im Fehlerfall: False, @error und @extended enthalten ggf. ergänzende fehlerbeschreibende Werte
    ; Author ........: Großvater (http://www.autoit.de)
    ; Modified.......:
    ; Remarks .......: Die Funktion kann auch einzeln genutzt werden, um eine Bitmap zu skalieren und dann per
    ; GUICtrlSendMsg($idPIC, $STM_SETIMAGE, $IMAGE_BITMAP, $hBitmap) einem Pic-Control zuzuweisen.
    ; Related .......:
    ; Link ..........:
    ; Example .......:
    ; ===============================================================================================================================
    Func _GUICtrlPic_ScaleBitmap($hBitmap, $iNewW, $iNewH, $iBitmapW, $iBitmapH, $bKeepAspectRatio = False)
    Local Const $IMAGE_BITMAP = 0x0000
    If $bKeepAspectRatio Then
    If $iBitmapW >= $iBitmapH Then
    $iBitmapH *= $iNewW / $iBitmapW
    $iBitmapW = $iNewW
    If $iBitmapH > $iNewH Then
    $iBitmapW *= $iNewH / $iBitmapH
    $iBitmapH = $iNewH
    EndIf
    Else
    $iBitmapW *= $iNewH / $iBitmapH
    $iBitmapH = $iNewH
    If $iBitmapW > $iNewW Then
    $iBitmapH *= $iNewW / $iBitmapW
    $iBitmapW = $iNewW
    EndIf
    EndIf
    Else
    $iBitmapW = $iNewW
    $iBitmapH = $iNewH
    EndIf
    Local $aResult = DllCall("User32.dll", "Handle", "CopyImage", _
    "Handle", $hBitmap, "UINT", $IMAGE_BITMAP, "INT", $iBitmapW, "INT", $iBitmapH, "UINT", 0x4 + 0x8)
    If @error Then Return SetError(@error, @extended, False)
    Return $aResult[0]
    EndFunc ;==>_GUICtrlPic_ScaleBitmap

    [/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ====================================================================================================================
    ; Name...........: _GUICtrlPic_GradientFill
    ; Description ...: Füllt ein Pic-Control mit einem zweifarbigen linearen Farbverlauf.
    ; Syntax.........: _GUICtrlPic_GradientFill($idCTRL, $C1, $C2[, $D = 1[, $3D = 3[, $GC = 0[, $BW = 0[, $BH = 0]]]]])
    ; Parameters ....: $idCTRL - ID des Pic-Controls aus GUIStrlCreatePic()
    ; $C1 - Startfarbe als 6-stelliger RGB-Hexstring ("RRGGBB")
    ; $C2 - Zielfarbe als 6-stelliger RGB-Hexstring ("RRGGBB")
    ; $D - Verlaufsrichtung:
    ; |0 - horizontal
    ; |1 - vertikal
    ; |2 - diagonal (links oben -> rechts unten)
    ; |3 - diagonal (rechts oben -> links unten)
    ; |Default - 0
    ; $3D - Verlaufsart:
    ; |1 - flacher Verlauf (Startfarbe -> Zielfarbe)
    ; |2 - "3D"-Verlauf (Startfarbe -> Zielfarbe -> Startfarbe)
    ; |3 - erhaben (wie 2, die Startfarbe bleibt aber im Randbereich)
    ; |Default - 1
    ; $GC - Gammakorrektur:
    ; |0 - ohne
    ; |1 - mit
    ; |Default - 0
    ; $BW - Breite des Verlaufs in Pixeln
    ; |Default - 0 (Breite des Controls)
    ; $BH - Höhe des Verlaufs in Pixeln
    ; |Default - 0 (Höhe des Controls)
    ; Return values .: Bei erfolgreicher Ausführung: Handle der erzeugten Bitmap (HBITMAP)
    ; Im Fehlerfall: False, @error wird auf 1 gesetzt
    ; Author ........: Großvater (http://www.autoit.de)
    ; Modified.......:
    ; Remarks .......: Das Control muss mit GUICtrlCreatePic() erzeugt worden sein, sonst geschieht nichts.
    ; Die Parameter $BW und $BH laden zum Experimentieren ein.
    ; Related .......:
    ; Link ..........:
    ; Example .......:
    ; ===============================================================================================================================
    Func _GUICtrlPic_GradientFill($idCTRL, $C1, $C2, $D = 1, $3D = 3, $GC = 0, $BW = 0, $BH = 0)
    Local Static $STM_SETIMAGE = 0x172
    Local Static $IMAGE_BITMAP = 0x0
    Local Static $BITSPIXEL = 0xC
    Local $hWnd
    If IsHWnd($idCTRL) Then
    $hWnd = $idCTRL
    Else
    $hWnd = GUICtrlGetHandle($idCTRL)
    EndIf
    Local $aResult = DllCall("User32.dll", "Int", "GetClassName", "Hwnd", $hWnd, _
    "Str", "", "Int", 256)
    If $aResult[2] <> "Static" Then
    Return False
    EndIf
    Local $GDIPDll = DllOpen("GDIPlus.dll")
    If $GDIPDll = -1 Then
    Return SetError(1, 0, False)
    EndIf
    Local $SI = DllStructCreate("UInt Version;Ptr Callback;Bool NoThread;Bool NoCodecs")
    Local $Token = DllStructCreate("ulong_ptr Data")
    DllStructSetData($SI, "Version", 1)
    $aResult = DllCall($GDIPDll, "Int", "GdiplusStartup", _
    "Ptr", DllStructGetPtr($Token), "Ptr", DllStructGetPtr($SI), "Ptr", 0)
    If @error Then
    DllClose($GDIPDll)
    Return SetError(1, 0, False)
    EndIf
    Local $GDIPToken = DllStructGetData($Token, "Data")
    Local $RECT = DllStructCreate("Long; Long; Long Right;Long Bottom")
    DllCall("User32.dll", "Bool", "GetClientRect", "Hwnd", $hWnd, _
    "Ptr", DllStructGetPtr($RECT))
    Local $W = DllStructGetData($RECT, "Right")
    Local $H = DllStructGetData($RECT, "Bottom")
    Switch $D
    Case 0, 1, 2, 3
    Case Else
    $D = 0
    EndSwitch
    Switch $3D
    Case 1, 2, 3
    Case Else
    $3D = 1
    EndSwitch
    Switch $GC
    Case 0, 1
    Case Else
    $GC = 0
    EndSwitch
    If $BW = 0 Then $BW = $W
    If $BH = 0 Then $BH = $H
    Local $pBITMAP = DllStructCreate("Ptr")
    DllCall($GDIPDll, "Int", "GdipCreateBitmapFromScan0", _
    "Int", $W, "Int", $H, "Int", 0, "Int", 0x26200A, "Ptr", 0, _
    "Ptr", DllStructGetPtr($pBITMAP))
    $pBITMAP = DllStructGetData($pBITMAP, 1)
    Local $pGRAPHICS = DllStructCreate("Ptr")
    DllCall($GDIPDll, "Int", "GdipGetImageGraphicsContext", _
    "Ptr", $pBITMAP, "Ptr", DllStructGetPtr($pGRAPHICS))
    $pGRAPHICS = DllStructGetData($pGRAPHICS, 1)
    DllCall($GDIPDll, "Int", "GdipSetSmoothingMode", "Ptr", $pGRAPHICS, "Int", 0)
    Local $RECTF = DllStructCreate("Float L;Float T;Float R;Float B")
    DllStructSetData($RECTF, "R", $BW)
    DllStructSetData($RECTF, "B", $BH)
    Local $Color1 = "0xFF" & $C1
    Local $Color2 = "0xFF" & $C2
    Local $pBRUSH = DllStructCreate("Ptr")
    DllCall($GDIPDll, "Int", "GdipCreateLineBrushFromRect", _
    "Ptr", DllStructGetPtr($RECTF), "Int", $Color1, "Int", $Color2, _
    "Int", $D, "Int", 0, "Ptr", DllStructGetPtr($pBRUSH))
    $pBRUSH = DllStructGetData($pBRUSH, 1)
    DllCall($GDIPDll, "Int", "GdipSetLineGammaCorrection", "Ptr", $pBRUSH, _
    "Int", $GC)
    Local $RELINT = DllStructCreate("Float[5]")
    Switch $3D
    Case 1
    DllStructSetData($RELINT, 1, 0.00, 1)
    DllStructSetData($RELINT, 1, 0.25, 2)
    DllStructSetData($RELINT, 1, 0.50, 3)
    DllStructSetData($RELINT, 1, 0.75, 4)
    DllStructSetData($RELINT, 1, 1.00, 5)
    Case 2
    DllStructSetData($RELINT, 1, 0.0, 1)
    DllStructSetData($RELINT, 1, 0.5, 2)
    DllStructSetData($RELINT, 1, 1.0, 3)
    DllStructSetData($RELINT, 1, 0.5, 4)
    DllStructSetData($RELINT, 1, 0.0, 5)
    Case Else
    DllStructSetData($RELINT, 1, 0.0, 1)
    DllStructSetData($RELINT, 1, 1.0, 2)
    DllStructSetData($RELINT, 1, 1.0, 3)
    DllStructSetData($RELINT, 1, 1.0, 4)
    DllStructSetData($RELINT, 1, 0.0, 5)
    EndSwitch
    Local $RELPOS = DllStructCreate("Float[5]")
    DllStructSetData($RELPOS, 1, 0.0, 1)
    If $3D <> 3 Then
    DllStructSetData($RELPOS, 1, 0.25, 2)
    Else
    DllStructSetData($RELPOS, 1, 0.15, 2)
    EndIf
    DllStructSetData($RELPOS, 1, 0.5, 3)
    If $3D <> 3 Then
    DllStructSetData($RELPOS, 1, 0.75, 4)
    Else
    DllStructSetData($RELPOS, 1, 0.85, 4)
    EndIf
    DllStructSetData($RELPOS, 1, 1.0, 5)
    DllCall($GDIPDll, "Int", "GdipSetLineBlend", _
    "Ptr", $pBRUSH, "Ptr", DllStructGetPtr($RELINT), _
    "Ptr", DllStructGetPtr($RELPOS), "Int", 5)
    DllCall($GDIPDll, "Int", "GdipFillRectangle", "Ptr", $pGRAPHICS, _
    "Ptr", $pBRUSH, "Float", 0, "Float", 0, "Float", $W, "Float", $H)
    Local $hBitmap = DllStructCreate("Ptr")
    DllCall($GDIPDll, "Int", "GdipCreateHBITMAPFromBitmap", _
    "Ptr", $pBITMAP, "Ptr", DllStructGetPtr($hBitmap), "Int", 0XFFFFFFFF)
    $hBitmap = DllStructGetData($hBitmap, 1)
    DllCall($GDIPDll, "Int", "GdipDeleteBrush", "Ptr", $pBRUSH)
    DllCall($GDIPDll, "Int", "GdipDisposeImage", "Ptr", $pBITMAP)
    DllCall($GDIPDll, "Int", "GdipDeleteGraphics", "Ptr", $pGRAPHICS)
    DllCall($GDIPDll, "None", "GdiplusShutdown", "Ptr", $GDIPToken)
    DllClose($GDIPDll)
    GUICtrlSendMsg($idCTRL, $STM_SETIMAGE, $IMAGE_BITMAP, $hBitmap)
    Return $hBitmap
    EndFunc ;==>_GUICtrlPic_GradientFill

    [/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ====================================================================================================================
    ; Name...........: _GUICtrlPic_Invert
    ; Description ...: Farben eines Pic-Controls invertieren.
    ; Syntax.........: _GUICtrlPic_LoadImage($sPicPath)
    ; Parameters ....: $idPic - ControlID aus GUICtrlCreatePic()
    ; Return values .: Keine
    ; Author ........: Großvater (http://www.autoit.de)
    ; Modified.......:
    ; Remarks .......:
    ; Related .......:
    ; Link ..........:
    ; Example .......:
    ; ===============================================================================================================================
    Func _GUICtrlPic_Invert($idPic)
    Local Const $IMAGE_BITMAP = 0x0000, $STM_SETIMAGE = 0x0172, $STM_GETIMAGE = 0x0173, $DSTINVERT = 0x00550009
    Local $aResult
    Local $hBitmap = GUICtrlSendMsg($idPic, $STM_GETIMAGE, $IMAGE_BITMAP, 0)
    Local $aSize = WinGetClientSize(GUICtrlGetHandle($idPic))
    Local $iWidth = $aSize[0], $iHeight = $aSize[1]
    Local $hGDI32 = DllOpen("Gdi32.dll")
    $aResult = DllCall($hGDI32, "Handle", "CreateCompatibleDC", "Handle", 0)
    Local $hDC = $aResult[0]
    $aResult = DllCall($hGDI32, "Handle", "SelectObject", "Handle", $hDC, "Handle", $hBitmap)
    $aResult = DllCall($hGDI32, "BOOL", "BitBlt", "Handle", $hDC, "INT", 0, "INT", 0, "INT", $iWidth, "INT", $iHeight, _
    "Handle", $hDC, "INT", 0, "INT", 0, "DWORD", $DSTINVERT)
    $aResult = DllCall($hGDI32, "BOOL", "DeleteDC", "Handle", $hDC)
    DllClose($hGDI32)
    GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hBitmap)
    EndFunc ;==>_GUICtrlPic_Invert
    ; ===============================================================================================================================

    [/autoit]

    Bild1: Ich beim debuggen

  • Na ja, eig meinte ich als Download-Datei mit in die Zip-Datei, wäre ja einfacher!? xD, missverständnis, xD

  • Also sobald ich Install anklicke kommt eine MessageBox mit Win. Na einmalklicken und direkt auf den Install-Button, nicht drüber drunter oder daneben. Das Win ist allerdings im Hintergund, sodass ich dieses nicht so einfach anklicken kann. Aber ich muss nirgendswo 10 pixel unten drunter klicken... Ich teste aber nochmal.

    Also es klappt soweit, nur man kann innerhalb der zwei vorgefertigen "Grafiken" 10 pixel auch klicken. Muss aber nicht...

  • Das mit der MsgBox im Hintergrund ist korrekt, die GUI hat das parameter "Topmost" deshalb steht sie über allen anderen Fenstern.
    Also bei mir ist es so:
    - Ich klicke normal in der Mitte auf den Button > nichts passiert
    - Ich klicke etwa 10 Pixel über dem Roten Bilderrand auf den Button > die MsgBox kommt
    - Ich klicke komplett unter den Button (immer noch auf der GUI) > die MsgBox kommt auch

    Ich weiss nicht ob ich bei der Koordinatenberechnung (die vier ersten Variablen) einen Fehler gemacht habe)...falls jemandem eine andere Möglichkeit einfällt wäre ich natürlich begeistert denn so wie ich das jetzt mache, wird es ein bisschen kompliziert und die Syntax grenzt ans illegale ^^

    Edit: Ich habe 2 Monitore...ich weiss nicht ob es daran liegen könne...glaub ich aber nicht, standartmässig wird ja immer nur der 1. für Programmzwecke verwendet wenn es nicht anderst spezifiziert wird oder?

    Bild1: Ich beim debuggen

  • Nun, wieso ist es bei Dir so und bei mir so wie Du es haben möchtest?


    Nun ich hab in der Form mit autoit noch keine schlechten erfahrungen mit 2 bildschirmen gemacht. Als ich anfing hatte ich 2 bildschirme mit 2560x1440 und 1920 x 1200.


    Edit: Teste es doch mal auf nem Laptop. Ich kann wenn Du willst es mal mit meinem XP-Laptop testen, xD

  • Joah...habe leider im Moment kein Laptop zur Verfügung.
    Also verstehe ich das richtig, das du den Butten anklicken kannst (egal wo) und es funktioniert?

    Edit: Bei mir funktioniert es, wenn ich in den Y-Koordinaten die Zahl 360 durch 340 ersetzt...aber das macht doch absolut keinen Sinn, der Button beginnt ja erst 20 Pixel später ?(
    Naja jedenfalls funktionierts jetzt...vieleicht muss ich das aber zuhause wieder ändern...ich mach mich mal auf die Suche nach einer sinnvolleren Möglichkeit, diesen Button anklickbar zu machen :D

    Bild1: Ich beim debuggen

    Einmal editiert, zuletzt von General Kaboom (28. August 2012 um 14:44)

  • Du kannst alternativ auch die Position der Maus AUF der Gui mit GUIGetCursorInfo() gekommen. Wenn du dann noch ein leeres Label unter deinem Button-Bild erzeugst kannst du mit dem selben Befehl abfragen ob die Maus auf dem Button ist. Wenn ja, fragste noch ab, ob die linke Maustaste gedrückt wurde und schon haste deine Msg-Box.

    Die Berechnung der X- und Y-Koordinaten kannst du dir dann vereinfachen ( also das in z.B. Zeile 6 ).
    Ich hoffe du weißt was ich meine ;)

    mfg
    Hauke

  • habs mal geändert. Die Styles der GUI kannste natürlich wieder hinzufügen:

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <Misc.au3>
    #include <GUICtrlPic.au3>

    [/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit]

    $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
    $Label = GUICtrlCreateLabel("", 480, 360, 130, 40)
    $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

    [/autoit] [autoit][/autoit] [autoit]

    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()
    $mPos = GUIGetCursorInfo()
    Select
    Case $mPos[0] >= 480 And $mPos[0] <= 610 And $mPos[1] >= 360 And $mPos[1] <= 400 And _IsPressed(01)
    MsgBox(0, "", "WIN")
    Case $nMsg = $GUI_EVENT_CLOSE
    Exit
    EndSelect
    ToolTip($mPos[0] & " - " & $mPos[1])
    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

    [/autoit]

    mfg
    Hauke