Runder Button

    • Offizieller Beitrag

    Einen runden Button gibt es nicht, aber Du kannst ein Icon auch als Klick-Event abfragen:

    [autoit]


    #include<GUIConstantsEx.au3>

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

    GUICreate(" My GUI Icons", 250, 250)
    $icon = GUICtrlCreateIcon("shell32.dll", -24, 20, 75, 32, 32)
    GUISetState()

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

    While 1
    $msg = GUIGetMsg()
    If $msg = $icon Then MsgBox(0,0,'angeklickt')
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd

    [/autoit]
  • Mach es doch als Icon und benutzt es wie ein button

    Spoiler anzeigen
    [autoit]

    $fenster = GUICreate("", 231, 172, 414, 226)
    $Beispiel = GUICtrlCreateIcon(@ScriptDir&"\Beispielordner\Icon.ico", 0, 0, 0, 0, 0)
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $Beispiel
    Das was dann getan werden soll
    Wend

    [/autoit]

    MfG
    Conan (Nur Mitlesend)
    Schon lange dabei

    • Offizieller Beitrag

    Man kann sowas simulieren:

    Spoiler anzeigen
    [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]
    • Offizieller Beitrag

    Ich habe mal noch eine andere Version erstellt, bei der man beliebig viele Buttons mit der Hover-Funktion belegen kann:

    Spoiler anzeigen
    [autoit]


    #include<GUIConstantsEx.au3>
    Opt('GUIOnEventMode', 1)

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

    $hGui = GUICreate(" My GUI Icons", 280, 100)
    GUISetOnEvent($GUI_EVENT_CLOSE, '_End')
    GUISetOnEvent($GUI_EVENT_MOUSEMOVE, '_MoveOrDown')
    GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, '_MoveOrDown')
    GUISetOnEvent($GUI_EVENT_PRIMARYUP, '_Up')

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

    Global $aButton[3][7]
    $aButton[0][0] = GUICtrlCreateIcon("shell32.dll", -24, 20, 20, 32, 32)
    $aButton[0][1] = -24 ; Iconposition in der dll für nicht gedrückt
    $aButton[0][2] = -44 ; Iconposition in der dll für gedrückt
    $aButton[0][3] = False ; Check für Position bei gedrückt (verhindert flackern)
    $aButton[0][4] = False ; Check für Icon-Image bei gedrückt (verhindert flackern)
    $aButton[0][5] = 20 ; X-Position des Icons
    $aButton[0][6] = 20 ; Y-Position des Icons

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

    $aButton[1][0] = GUICtrlCreateIcon("shell32.dll", -14, 120, 20, 32, 32)
    $aButton[1][1] = -14
    $aButton[1][2] = -15
    $aButton[1][3] = False
    $aButton[1][4] = False
    $aButton[1][5] = 120
    $aButton[1][6] = 20

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

    $aButton[2][0] = GUICtrlCreateIcon("shell32.dll", -10, 220, 20, 32, 32)
    $aButton[2][1] = -10
    $aButton[2][2] = -11
    $aButton[2][3] = False
    $aButton[2][4] = False
    $aButton[2][5] = 220
    $aButton[2][6] = 20

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

    GUISetState()

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

    While 1
    Sleep(50)
    WEnd

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

    Func _End()
    Exit
    EndFunc

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

    Func _Up() ; wird aufgerufen, wenn die linke Maustaste losgelassen wird
    Local $aInfo = GUIGetCursorInfo($hGui), $j = -1
    For $i = 0 To UBound($aButton)-1
    If $aInfo[4] = $aButton[$i][0] Then $j = $i
    Next
    If $j = -1 Then Return
    MsgBox(0, 0, 'Button ' & $j+1 & ' wurde angeklickt')
    GUICtrlSetImage($aButton[$j][0], "shell32.dll", $aButton[$j][1]) ; ursprüngliches Icon wiederherstellen
    EndFunc

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

    Func _MoveOrDown() ; wird aufgerufen, wenn entweder die Maus bewegt oder die linke Maustaste runtergedrückt wird
    Local $aInfo = GUIGetCursorInfo($hGui), $j = -1
    For $i = 0 To UBound($aButton)-1
    If $aInfo[4] = $aButton[$i][0] Then $j = $i
    Next
    If $j = -1 Then
    For $i = 0 To UBound($aButton)-1
    if $aButton[$i][3] Then GUICtrlSetPos($aButton[$i][0], $aButton[$i][5], $aButton[$i][6])
    if $aButton[$i][4] Then GUICtrlSetImage($aButton[$i][0], "shell32.dll", $aButton[$i][1])
    $aButton[$i][3] = False
    $aButton[$i][4] = False
    Next
    Return
    EndIf
    If Not $aButton[$j][3] Then
    GUICtrlSetPos($aButton[$j][0], $aButton[$j][5]+1, $aButton[$j][6]+1)
    $aButton[$j][3] = True
    EndIf
    If $aInfo[2] And Not $aButton[$j][4] Then
    GUICtrlSetImage($aButton[$j][0], "shell32.dll", $aButton[$j][2])
    $aButton[$j][4] = True
    EndIf
    EndFunc

    [/autoit]

    Hier wird auch noch der linke Mausklick abgefangen und es wird, während man die Maustaste gedrückt hält, ein anderes Icon angezeigt. Der eigentliche Klick-Event erfolgt erst beim loslassen der Maustaste.