Advertisement
NAK

MouseEnterLeave using GetCursorPos API

NAK
Jun 22nd, 2013
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.92 KB | None | 0 0
  1. Public Class Form1
  2.  
  3.     Public Declare Auto Function GetCursorPos Lib "User32.dll" (ByRef lpPoint As Point) As Integer
  4.     Dim WithEvents TrackerRefresh As System.Timers.Timer = New System.Timers.Timer(10)
  5.     Dim rect As Point
  6.  
  7.     Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  8.         AddHandler TrackerRefresh.Elapsed, AddressOf TrackerRefresh_Elapse
  9.         TrackerRefresh.Start()
  10.     End Sub
  11.  
  12.     Private Sub Form1_Paint(sender As Object, e As PaintEventArgs) Handles MyBase.Paint
  13.         GetCursorPos(rect)
  14.         If (rect.X <= Me.Left Or rect.X >= (Me.Left + Me.Width)) Or (rect.Y <= Me.Top Or rect.Y >= (Me.Top + Me.Height)) Then
  15.             Me.Opacity = 1
  16.         Else
  17.             Me.Opacity = 0.5
  18.         End If
  19.     End Sub
  20.  
  21.     Protected Sub TrackerRefresh_Elapse(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs)
  22.         Me.Invalidate()
  23.     End Sub
  24.  
  25. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement