Fenster: Maus-Transparenz-Effekt

    • VB.NET

    Es gibt 5 Antworten in diesem Thema. Der letzte Beitrag () ist von doci.

      Fenster: Maus-Transparenz-Effekt

      Hi,
      ich möchte hier mal nen kleinen Code posten, welcher bewerkstelligt, dass das Fenster durchsichtig wird, wenn sich die Maus nicht mehr in diesem befindet.

      VB.NET-Quellcode

      1. If MousePosition.X > Me.Location.X And MousePosition.Y > Me.Location.Y And MousePosition.X < Me.Location.X + Me.Size.Width And MousePosition.Y < Me.Location.Y + Me.Size.Height Then
      2. If (Me.Opacity < 1) Then
      3. Me.Opacity += 0.025
      4. End If
      5. Else
      6. If (Me.Opacity > 0.7) Then
      7. Me.Opacity -= 0.025
      8. End If
      9. End If
      hallo noname,

      gute idee.
      noch eine kleine abfragekorrektur und schon sieht ein vollständiger code so aus

      VB.NET-Quellcode

      1. Public Class Form1
      2. Private WithEvents t As New Timer
      3. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      4. t.Start()
      5. End Sub
      6. Private Sub t_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles t.Tick
      7. If Me.Bounds.Contains(MousePosition) = True Then
      8. If (Me.Opacity < 1) Then
      9. Me.Opacity += 0.025
      10. End If
      11. Else
      12. If (Me.Opacity > 0.7) Then
      13. Me.Opacity -= 0.025
      14. End If
      15. End If
      16. End Sub
      17. End Class

      @noname,
      hat sie - das springt aber auch an, wenn man in ein control fährt. ;(

      gruss

      mikeb69