Bild hover unsichtbar

  • Hallo,

    ich möchte mit einer Hover Funktion ein Bild
    unsichtbar, bzw. sichbar machen! Das klappt leider nicht!

    [autoit]


    AdlibRegister("_Hover_Label")
    Func _Hover_Label()
    $pos = GUIGetCursorInfo()

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

    If $pos[4] = $Pic2 Then
    $Pic2.visible = false
    else
    $Pic2.visible = true
    EndIf
    EndFunc

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

    Viele Grüße
    Ilse

  • ...hat funktioniert!

    Leider gibt es noch ein Problem
    (ähnlich wie bei meinem Labels Thread)

    Wenn ich die Maus auf das Bild halte blinkt es!
    Ich habe das ganze wie von h2112 empfohlen angepasst
    bei dem Bild klappt es leider nicht!

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

    AdlibRegister("_Hover_Label",0) ; hiert kann man die Zeit einstellen
    Global $hoverbild = False

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

    Func _Hover_Label()
    $pos = GUIGetCursorInfo()

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

    If $pos[4] = $Pic2 And $Hoverbild = false Then
    ;Msgbox(4,"teset","Test")
    GUICtrlSetState($Pic2, $GUI_HIDE) ; Der Fokus ist auf diesem Button
    $Hoverbild = true

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

    ElseIf $pos[4] <> $Pic2 And $Hoverbild = True then
    GUICtrlSetState($Pic2, $GUI_Show)
    $Hoverbild = False
    EndIf

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

    EndFunc

    [/autoit]

    wenn ich den Cursor auf dem Bild lasse, dann wird es aus und an geschaltet!
    Es sollte aber, solange ich den Cursor auf dem Bild halte unsichtbar sein!

    Einmal editiert, zuletzt von Ilse (10. November 2010 um 16:58)

  • AdlibRegister in einer Funktion? Das kann nich gut gehen... und dann auch noch dauerhaft ausführen? Da wird nebenbei kaum noch was anderes klappen...
    Und in einer Funktion eine Variable andauernd Global zu deklarieren ist auch nicht gerade sinnvoll...

  • So,
    hier nochmal der kpl. Code

    [autoit]


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

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

    Global $Hoverbild

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

    $Form1 = GUICreate("Form1", 615, 440, 192, 124, BitOR($GUI_SS_DEFAULT_GUI,$WS_MAXIMIZEBOX,$WS_SIZEBOX,$WS_THICKFRAME,$WS_TABSTOP))
    $Pic1 = GUICtrlCreatePic("C:\Bild1.jpg", 24, 14, 567, 403) ; das ist das Hintergrundbild!
    GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
    $Pic2 = GUICtrlCreatePic("C:\bt1.jpg", 188, 110, 209, 133) ; das ist das Bild auf das der Cursor reagiert!
    GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
    GUISetState(@SW_SHOW)

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

    AdlibRegister("_Hover_Label")

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

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

    EndSwitch
    WEnd

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

    Global $Hoverbild = False

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

    Func _Hover_Label()

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

    $pos = GUIGetCursorInfo()
    If $pos[4] = $Pic2 And $Hoverbild = false Then
    GUICtrlSetState($Pic2, $GUI_HIDE)
    $Hoverbild = true

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

    ElseIf $pos[4] <> $Pic2 And $Hoverbild = True then
    GUICtrlSetState($Pic2, $GUI_show)
    $Hoverbild = False
    endif

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

    EndFunc

    [/autoit]

    Also, wenn ich den Cursor auf das "pic2" halte, dann soll es verschwinden
    Bewege ich den Cursor außerhalb, dann soll es wieder erscheinen!
    Wenn ich den Cursor ruhig halte blinkt es.

    Komm da einfach nicht weiter...

    Viele Grüße
    Ilse ;)

    Einmal editiert, zuletzt von Ilse (10. November 2010 um 18:14)

  • Spoiler anzeigen
    [autoit][/autoit] [autoit][/autoit] [autoit]

    Global $Hover=0

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

    ;Dein Code

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

    Func Hover()
    $Cursor=GUIGetCursorInfo()
    If $Cursor[4]=$DeinCTRL Then
    Guictrlsetstate($DeinCTRL,32)
    $Hover=1
    Elseif $Hover=1 Then
    Guictrlsetstate($DeinCTRL,16)
    $Hover=0
    Endif
    Endfunc

    [/autoit]

    probier das mal

  • Ich versuche schon die ganze Zeit das zu lösen, denke jetzt aber nach gut einer halben Stunde das man sowas lieber mit GDI+ machen sollte und einen Backbuffer verwenden sollte. Wenn man mit GUICtrlCreatePic() Ein Bild erstellt dann flackert das weil es kurz vorher immer weiß ist.
    Ich versuch mich mal an der GDI+ Variante wenn ich fertig bin kann ichs dir geben.

    So hab mal was improvisiert :D Denke ist sehr umstädnlich aber es funzt.:

    Spoiler anzeigen
    [autoit]

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

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

    Global $Hoverbild

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

    $hGUI = GUICreate("Form1", 615, 440, 192, 124, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_TABSTOP))
    Guisetbkcolor (0xffFfff)
    ;~ $Pic1 = GUICtrlCreatePic(@desktopdir & "\Bilder\blau.jpg", 24, 14, 567, 403) ; das ist das Hintergrundbild!
    GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
    ;~ $Pic2 = GUICtrlCreatePic(@DesktopDir & "\Bilder\Baum.jpg", 100, 100, 100, 100) ; das ist das Bild auf das der Cursor reagiert!
    GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ; Benutzt die GUI als "Unterlage" für unsere Bilder
    $hBitmap = _GDIPlus_BitmapCreateFromGraphics(615, 440, $hGraphic)
    $hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    ;~ $HintergrundImage = _GDIPlus_ImageLoadFromFile () =============FALS DU DEN HINTERGRUND EINBAZUEN WILLST, MACHE ICH JETZT NICHT==================
    $pic2 = _GDIPlus_ImageLoadFromFile (@desktopdir & "\Bilder\Baum.jpg")
    $deckung= _GDIPlus_ImageLoadFromFile (@desktopdir & "\Bilder\weiss.png")
    $pic2malen= _GDIPlus_GraphicsDrawImageRect ($hBackbuffer, $pic2, 100, 100, 100, 100)

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

    GUISetState(@SW_SHOW)
    _GDIPlus_GraphicsDrawImageRect ($hGraphic, $hBitmap, 0, 0, 615, 440)

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

    ;~ AdlibRegister("_Hover_Label")

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

    While 1
    $pos = GUIGetCursorInfo()
    _GDIPlus_GraphicsDrawImageRect ($hGraphic, $hBitmap, 0, 0, 615, 440)
    If Isarray ($pos) Then
    If $pos[0] >= 100 and $pos[0] <= 200 and $pos[1] >= 100 and $pos[1] <= 200 Then
    _GDIPlus_GraphicsDrawImageRect ( $hBackbuffer,$deckung, 100, 100, 100, 100)
    Else
    $pic2malen= _GDIPlus_GraphicsDrawImageRect ($hBackbuffer, $pic2, 100, 100, 100, 100)
    EndIf
    endif

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

    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

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

    EndSwitch
    ;~ If IsArray($pos) Then
    ;~ If $pos[4] = $Pic2 Then _Hover_Label()
    ;~ else
    ;~ GUICtrlSetState($Pic2, $GUI_show)
    ;~ ElseIf $pos[4] <> $Pic2 Then GUICtrlSetState($Pic2, $GUI_show)
    ;~ EndIf
    ;~ If IsArray ($pos) Then
    ;~ If $pos[4] <> $Pic2 Then GUICtrlSetState($Pic2, $GUI_show)
    ;~ EndIf
    WEnd

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

    Func _Hover_Label()

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

    ;~ $pos = GUIGetCursorInfo()
    ;~ If $pos[4] = $Pic2 Then
    GUICtrlSetState($Pic2, $GUI_HIDE)
    ;~ $Hoverbild = true

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

    ;~ Else
    ;~ GUICtrlSetState($Pic2, $GUI_show)

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

    ;~ endif

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

    EndFunc ;==>_Hover_Label

    [/autoit]

    mfg BB

    "IF YOU'RE GOING TO KILL IT
    OPEN SOURCE IT!"

    by Phillip Torrone

    Zitat von Shoutbox

    [Heute, 11:16] Andy: ....böseböseböseböse....da erinnere ich mich daran, dass man den Puschelschwanz eines KaRnickels auch "Blume" nennt....ob da eins zum anderen passt? :rofl: :rofl: :rofl: :rofl:

    https://autoit.de/index.php?page…leIt#post251138

    Neon Snake

    3 Mal editiert, zuletzt von BadBunny (10. November 2010 um 21:12)

  • Naja, wenn das Bild versteckt ist, ist die Maus auch nicht mehr über dem Bild ;) Deshalb kann man das ganz einfach mit der Position der Maus machen:

    Spoiler anzeigen
    [autoit]

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

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

    Global $Hoverbild
    $hoverjn = 0
    $act = 0
    $Form1 = GUICreate("Form1", 615, 440, 192, 124, BitOR($GUI_SS_DEFAULT_GUI,$WS_MAXIMIZEBOX,$WS_SIZEBOX,$WS_THICKFRAME,$WS_TABSTOP))
    $Pic1 = GUICtrlCreatePic("C:\Bild1.jpg", 24, 14, 567, 403) ; das ist das Hintergrundbild!
    GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
    $Pic2 = GUICtrlCreatePic("C:\bt1.jpg", 188, 110, 209, 133) ; das ist das Bild auf das der Cursor reagiert!
    GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
    GUISetState(@SW_SHOW)

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
    $pos = GUIGetCursorInfo()
    if 188 < $pos[0] and $pos[0] < 397 and 110 < $pos[1] and $pos[1] < 243 Then
    $hoverjn = 1
    Else
    $hoverjn = 0
    EndIf
    if $hoverjn <> $act Then
    if $hoverjn = 1 Then
    $act = 1
    guictrlsetstate($pic2, $GUI_HIDE)
    Else
    $act = 0
    guictrlsetstate($pic2, $GUI_SHOW)
    EndIf
    EndIf
    WEnd

    [/autoit]
  • Guten Morgen alle zusammen,

    erstmal danke für eure Beiträge.
    Aber es funktioniert immer noch nicht!
    Ich fang mal langsam an:

    @ AlexanderSchill
    flackert nach wie vor....

    Spoiler anzeigen


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

    Global $Hover=0

    $Form1 = GUICreate("Form1", 615, 440, 192, 124, BitOR($GUI_SS_DEFAULT_GUI,$WS_MAXIMIZEBOX,$WS_SIZEBOX,$WS_THICKFRAME,$WS_TABSTOP))
    $Pic1 = GUICtrlCreatePic("C:\Bild1.jpg", 24, 14, 567, 403)
    GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
    $Pic2 = GUICtrlCreatePic("C:\bt1.jpg", 188, 110, 209, 133)
    GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
    GUISetState(@SW_SHOW)


    AdlibRegister("Hover")

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

    EndSwitch
    WEnd


    Global $Hoverbild = False


    Func Hover()
    $Cursor=GUIGetCursorInfo()
    If $Cursor[4]=$Pic2 Then
    Guictrlsetstate($Pic2,32)
    $Hover=1
    Elseif $Hover=1 Then
    Guictrlsetstate($Pic2,16)
    $Hover=0
    Endif
    Endfunc

    BadBunny
    huh..., es funktioniert bis auf die Größenanpassung.
    Wenn das Fenster vergrößert wird,
    dann sollten die Bilder mitvergrößert werden.

    Spoiler anzeigen


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


    Global $Hoverbild

    $hGUI = GUICreate("Form1", 615, 440, 192, 124, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_TABSTOP))
    Guisetbkcolor (0xffFfff)
    ;~ $Pic1 = GUICtrlCreatePic(@desktopdir & "\Bilder\blau.jpg", 24, 14, 567, 403) ; das ist das Hintergrundbild!
    GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
    ;~ $Pic2 = GUICtrlCreatePic(@DesktopDir & "\Bilder\Baum.jpg", 100, 100, 100, 100) ; das ist das Bild auf das der Cursor reagiert!
    GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ; Benutzt die GUI als "Unterlage" für unsere Bilder
    $hBitmap = _GDIPlus_BitmapCreateFromGraphics(615, 440, $hGraphic)
    $hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    ;~ $HintergrundImage = _GDIPlus_ImageLoadFromFile () =============FALS DU DEN HINTERGRUND EINBAZUEN WILLST, MACHE ICH JETZT NICHT==================
    $pic2 = _GDIPlus_ImageLoadFromFile (@desktopdir & "\Bilder\Baum.jpg")
    $deckung= _GDIPlus_ImageLoadFromFile (@desktopdir & "\Bilder\weiss.png")
    $pic2malen= _GDIPlus_GraphicsDrawImageRect ($hBackbuffer, $pic2, 100, 100, 100, 100)

    GUISetState(@SW_SHOW)
    _GDIPlus_GraphicsDrawImageRect ($hGraphic, $hBitmap, 0, 0, 615, 440)

    ;~ AdlibRegister("_Hover_Label")

    While 1
    $pos = GUIGetCursorInfo()
    _GDIPlus_GraphicsDrawImageRect ($hGraphic, $hBitmap, 0, 0, 615, 440)
    If Isarray ($pos) Then
    If $pos[0] >= 100 and $pos[0] <= 200 and $pos[1] >= 100 and $pos[1] <= 200 Then
    _GDIPlus_GraphicsDrawImageRect ( $hBackbuffer,$deckung, 100, 100, 100, 100)
    Else
    $pic2malen= _GDIPlus_GraphicsDrawImageRect ($hBackbuffer, $pic2, 100, 100, 100, 100)
    EndIf
    endif


    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

    EndSwitch
    ;~ If IsArray($pos) Then
    ;~ If $pos[4] = $Pic2 Then _Hover_Label()
    ;~ else
    ;~ GUICtrlSetState($Pic2, $GUI_show)
    ;~ ElseIf $pos[4] <> $Pic2 Then GUICtrlSetState($Pic2, $GUI_show)
    ;~ EndIf
    ;~ If IsArray ($pos) Then
    ;~ If $pos[4] <> $Pic2 Then GUICtrlSetState($Pic2, $GUI_show)
    ;~ EndIf
    WEnd


    Func _Hover_Label()

    ;~ $pos = GUIGetCursorInfo()
    ;~ If $pos[4] = $Pic2 Then
    GUICtrlSetState($Pic2, $GUI_HIDE)
    ;~ $Hoverbild = true


    ;~ Else
    ;~ GUICtrlSetState($Pic2, $GUI_show)

    ;~ endif

    EndFunc ;==>_Hover_Label

    Fresapore

    wenn das Fenster vergrößert wird,
    dann geht leider nichts mehr!

    Spoiler anzeigen


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

    Global $Hoverbild
    $hoverjn = 0
    $act = 0
    $Form1 = GUICreate("Form1", 615, 440, 192, 124, BitOR($GUI_SS_DEFAULT_GUI,$WS_MAXIMIZEBOX,$WS_SIZEBOX,$WS_THICKFRAME,$WS_TABSTOP))
    $Pic1 = GUICtrlCreatePic("C:\Bild1.jpg", 24, 14, 567, 403)
    GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
    $Pic2 = GUICtrlCreatePic("C:\bt1.jpg", 188, 110, 209, 133)
    GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
    GUISetState(@SW_SHOW)


    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
    $pos = GUIGetCursorInfo()
    if 188 < $pos[0] and $pos[0] < 397 and 110 < $pos[1] and $pos[1] < 243 Then
    $hoverjn = 1
    Else
    $hoverjn = 0
    EndIf
    if $hoverjn <> $act Then
    if $hoverjn = 1 Then
    $act = 1
    guictrlsetstate($pic2, $GUI_HIDE)
    Else
    $act = 0
    guictrlsetstate($pic2, $GUI_SHOW)
    EndIf
    EndIf
    WEnd


    ...das wird bestimmt wieder
    ein toller Tag!

    Liebe Grüße
    Ilse ;)

  • Oh stimmt, das hatte ich nicht beachtet:

    Spoiler anzeigen
    [autoit]

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

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

    Global $Hoverbild
    $hoverjn = 0
    $act = 0
    $Form1 = GUICreate("Form1", 615, 440, 192, 124, BitOR($GUI_SS_DEFAULT_GUI,$WS_MAXIMIZEBOX,$WS_SIZEBOX,$WS_THICKFRAME,$WS_TABSTOP))
    $Pic1 = GUICtrlCreatePic("C:\Bild1.jpg", 24, 14, 567, 403)
    GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
    $Pic2 = GUICtrlCreatePic("C:\bt1.jpg", 188, 110, 209, 133)
    GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
    GUISetState(@SW_SHOW)

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
    $pos = GUIGetCursorInfo()
    $size = wingetpos("Form1")
    if $size[2]/(615/188) < $pos[0] and $pos[0] < $size[2]/(615/397) and $size[3]/(440/110) < $pos[1] and $pos[1] < $size[3]/(440/243) Then
    $hoverjn = 1
    Else
    $hoverjn = 0
    EndIf
    if $hoverjn <> $act Then
    if $hoverjn = 1 Then
    $act = 1
    guictrlsetstate($pic2, $GUI_HIDE)
    Else
    $act = 0
    guictrlsetstate($pic2, $GUI_SHOW)
    EndIf
    EndIf
    WEnd

    [/autoit]