Button mit Überrollefeckt

  • Wie kann ich einen Overrollefeckt machen?, also ich habe eine Gui mit einem Pic als Button gemancht, und möchte jetzt das wenn ich mit der Maus über das bild fahre, das das bild aus "Test_O.gif" gesetzt wird! Kann das jemand? Natürlich hab ich uach shon ein script angefangen:

    Spoiler anzeigen
    [autoit]

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

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

    #Region ### START Koda GUI section ### Form=
    $Form2 = GUICreate("Überrollefeckt", 212, 120, 515, 423)
    $Pic1 = GUICtrlCreatePic(@ScriptDir & "\Test.gif", 72, 39, 75, 25)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Pic1
    MsgBox (0,"Test","Pic1 wurde angeklickt!")
    EndSwitch
    WEnd

    [/autoit]

    mfg. Jam00

  • Wir hatten hier schonmal so ein ähnliches Thema dazu. ;)

    Aber hier nochmal:

    [autoit]

    #include<GUIConstantsEx.au3>

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

    $hGui = GUICreate(" My GUI Icons", 250, 250)
    $icon = GUICtrlCreateIcon("shell32.dll", -24, 20, 75, 32, 32)
    GUISetState()
    Global $old, $msg
    While 1
    $msg = GUIGetMsg()
    $aInfo = GUIGetCursorInfo($hGui)
    If $aInfo[4] = $icon Then
    If $aInfo[4] <> $old Then
    $old = $aInfo[4]
    GUICtrlSetPos($icon, 21, 76, 32, 32)
    EndIf
    Else
    If $aInfo[4] <> $old Then
    $old = $aInfo[4]
    GUICtrlSetPos($icon, 20, 75, 32, 32)
    EndIf
    EndIf
    If $msg = $icon Then
    GUICtrlSetImage($icon, "shell32.dll", -44)
    MsgBox(0,0,'angeklickt')
    GUICtrlSetImage($icon, "shell32.dll", -24)
    EndIf
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd

    [/autoit]

    du musst nur die GUICtrlsetpos zu Guictrlsetimage machen.

  • In der XSkin UDF gibts ne MouseOver-Funktion für die gesamte GUI und auch für Controls.

    Wenn du deine GUI nicht mit XSkin bauen willst musst du die Funktion halt entsprechend umbauen z.B. bei MouseOver für GUI

    [autoit]

    #include <GUIConstantsEx.au3>
    $YourGUI = GUICreate('asd', 100, 100)
    $XSolid = 1
    GUISetState()
    While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    Mouseover()
    Wend

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

    Func Mouseover()
    Local $XS_msg, $XS_Hvr, $XSlid0
    If WinActive($YourGUI) Then
    $XS_msg = GUIGetCursorInfo($YourGUI)
    $XS_Hvr = WinGetPos($YourGUI)
    If WinActive($YourGUI) And IsArray($XS_msg) And IsArray($XS_Hvr) Then
    If $XS_msg[0] < 0 Or $XS_msg[1] < 0 Or $XS_msg[0] > $XS_Hvr[2] Or $XS_msg[1] > $XS_Hvr[3] Then
    If $XSolid Then
    $XSolid = 0
    For $XS_fd = 254 To 100 Step - 5
    WinSetTrans($YourGUI, "", $XS_fd)
    Sleep(10)
    Next
    EndIf
    ElseIf $XSolid = 0 Then
    $XSolid = 1
    WinSetTrans($YourGUI, "", 255)
    EndIf
    EndIf
    EndIf
    EndFunc ;==>Mouseover

    [/autoit]
  • [autoit]

    #include <GUIConstantsEx.au3>
    $YourGUI = GUICreate('asd', 100, 100)
    $YourButton = GUICtrlCreateButton('Button', 0, 0)
    $XSolid = 1
    $over_color = 0x7B7B7E
    $color = 0x95989B
    $bc = $color
    GUICtrlSetBkColor($YourButton, $color)
    GUISetState()
    While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    Mouseover()
    Wend

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

    Func Mouseover()
    Local $XS_msg, $XS_Hvr, $XSlid0
    If WinActive($YourGUI) Then
    $XS_msg = GUIGetCursorInfo($YourGUI)
    ;Controls
    If IsArray($XS_msg) And $XS_msg[4] = $YourButton Then
    If $bc = $color Then
    GUICtrlSetBkColor($YourButton, $over_color)
    $bc = $over_color
    EndIf
    Else
    If $bc = $over_color Then
    GUICtrlSetBkColor($YourButton, $color)
    $bc = $color
    EndIf
    EndIf

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

    ;Whole GUI
    $XS_Hvr = WinGetPos($YourGUI)
    If WinActive($YourGUI) And IsArray($XS_msg) And IsArray($XS_Hvr) Then
    If $XS_msg[0] < 0 Or $XS_msg[1] < 0 Or $XS_msg[0] > $XS_Hvr[2] Or $XS_msg[1] > $XS_Hvr[3] Then
    If $XSolid Then
    $XSolid = 0
    For $XS_fd = 254 To 100 Step - 5
    WinSetTrans($YourGUI, "", $XS_fd)
    Sleep(10)
    Next
    EndIf
    ElseIf $XSolid = 0 Then
    $XSolid = 1
    WinSetTrans($YourGUI, "", 255)
    EndIf
    EndIf
    EndIf
    EndFunc ;==>Mouseover

    [/autoit]


    für GUI und Controls

  • @Padmak

    meinst diese UDF? :

    Spoiler anzeigen
    [autoit]

    #include-once
    Opt("MustDeclareVars", 1)
    Opt("OnExitFunc", "CallBack_Exit")

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

    ;GUICtrlSetOnHover Initialize
    Global $HOVER_CONTROLS_ARRAY[1][1]
    Global $LAST_HOVERED_ELEMENT[2] = [-1, -1]
    Global $LAST_HOVERED_ELEMENT_MARK = -1
    Global $pTimerProc = DllCallbackRegister("CALLBACKPROC", "none", "hwnd;uint;uint;dword")
    Global $uiTimer = DllCall("user32.dll", "uint", "SetTimer", "hwnd", 0, "uint", 0, "int", 10, "ptr", DllCallbackGetPtr($pTimerProc))
    $uiTimer = $uiTimer[0]

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

    Opt("MustDeclareVars", 0)

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

    ;===============================================================================
    ;
    ; Function Name: GUICtrlSetOnHover()
    ; Description: Set function(s) to call when hovering/leave hovering GUI elements.
    ; Parameter(s): $CtrlID - The Ctrl ID to set hovering for (can be a -1 as indication to the last item created).
    ; $HoverFuncName - Function to call when the mouse is hovering the control.
    ; $LeaveHoverFuncName - [Optional] Function to call when the mouse is leaving hovering the control
    ; (-1 no function used).
    ;
    ; Return Value(s): Always returns 1 regardless of success.
    ; Requirement(s): AutoIt 3.2.10.0
    ; Note(s): 1) TreeView/ListView Items can not be set :(.
    ; 2) When the window is not active, the hover/leave hover functions will still called,
    ; but not when the window is disabled.
    ; 3) The hover/leave hover functions will be called even if the script is paused by such functions as MsgBox().
    ; Author(s): G.Sandler (a.k.a CreatoR).
    ;
    ;===============================================================================
    Func _GUICtrlSetOnHover($CtrlID, $HoverFuncName, $LeaveHoverFuncName=-1)
    Local $Ubound = UBound($HOVER_CONTROLS_ARRAY)
    ReDim $HOVER_CONTROLS_ARRAY[$Ubound+1][3]
    $HOVER_CONTROLS_ARRAY[$Ubound][0] = GUICtrlGetHandle($CtrlID)
    $HOVER_CONTROLS_ARRAY[$Ubound][1] = $HoverFuncName
    $HOVER_CONTROLS_ARRAY[$Ubound][2] = $LeaveHoverFuncName
    $HOVER_CONTROLS_ARRAY[0][0] = $Ubound
    EndFunc

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

    ;CallBack function to handle the hovering process
    Func CALLBACKPROC($hWnd, $uiMsg, $idEvent, $dwTime)
    If UBound($HOVER_CONTROLS_ARRAY)-1 < 1 Then Return
    Local $ControlGetHovered = _ControlGetHoveredHwnd()
    Local $sCheck_LHE = $LAST_HOVERED_ELEMENT[1]

    If $ControlGetHovered = 0 Or ($sCheck_LHE <> -1 And $ControlGetHovered <> $sCheck_LHE) Then
    If $LAST_HOVERED_ELEMENT_MARK = -1 Then Return
    If $LAST_HOVERED_ELEMENT[0] <> -1 Then Call($LAST_HOVERED_ELEMENT[0], _ControlGetID($LAST_HOVERED_ELEMENT[1]))
    $LAST_HOVERED_ELEMENT[0] = -1
    $LAST_HOVERED_ELEMENT[1] = -1
    $LAST_HOVERED_ELEMENT_MARK = -1
    Else
    For $i = 1 To $HOVER_CONTROLS_ARRAY[0][0]
    If $HOVER_CONTROLS_ARRAY[$i][0] = $ControlGetHovered Then
    If $LAST_HOVERED_ELEMENT_MARK = $HOVER_CONTROLS_ARRAY[$i][0] Then ExitLoop
    $LAST_HOVERED_ELEMENT_MARK = $HOVER_CONTROLS_ARRAY[$i][0]
    Call($HOVER_CONTROLS_ARRAY[$i][1], _ControlGetID($ControlGetHovered))
    If $HOVER_CONTROLS_ARRAY[$i][2] <> -1 Then
    $LAST_HOVERED_ELEMENT[0] = $HOVER_CONTROLS_ARRAY[$i][2]
    $LAST_HOVERED_ELEMENT[1] = $ControlGetHovered
    EndIf
    ExitLoop
    EndIf
    Next
    EndIf
    EndFunc
    #include <WinApi.au3>

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

    Func _ControlGetID($ControlGetHovered)
    Local $ControlGetHoveredID = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $ControlGetHovered)
    If @error Then Return
    Return $ControlGetHoveredID[0]
    EndFunc
    ;Thanks to amel27 for that one!!!
    Func _ControlGetHoveredHwnd()
    Local $mouse = _WinAPI_GetCursorInfo()
    Local $iRet = DllCall("user32.dll", "hwnd", "WindowFromPoint", _
    "long", $mouse[3], _
    "long", $mouse[4])
    Return $iRet[0]
    EndFunc

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

    ;Release the CallBack resources
    Func CallBack_Exit()
    DllCallbackFree($pTimerProc)
    DllCall("user32.dll", "int", "KillTimer", "hwnd", 0, "uint", $uiTimer)
    EndFunc

    [/autoit]