Berikut Langkah-Langkahnya :
[ VB 6.0 ]
Buat Form baru (BorderStyle=None) dengan sebuah Timer (Enabled=True; Interval=10).
Di bagian '(Declarations)' dari Form ketikkan :
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Declare Function GetCursorPos Lib "user32.dll" (ByRef lpPoint As POINTAPI) As Long
Private Type POINTAPI
X As Long
Y As Long
End Type
Di bagian 'Form_Load' ketikkan :
SetWindowPos Me.hwnd, -1, 0, 0, 0, 0, &H1 Or &H2 'selalu di depan
Di bagian 'Timer1_Timer' ketikkan :
Dim p As POINTAPI
GetCursorPos p
Me.Left = (p.X * Screen.TwipsPerPixelX) + 100
Me.Top = (p.Y * Screen.TwipsPerPixelY) + 100
[ VB .NET ]
Buat Form baru (FormBorderStyle=None; TopMost=True) dengan sebuah Timer (Enabled=True; Interval=10).
Di bagian '(Declarations)' dari Form ketikkan :
Private Declare Function GetCursorPos Lib "user32.dll" (ByRef lpPoint As POINTAPI) As Integer
Private Structure POINTAPI
Dim X As Integer
Dim Y As Integer
End Structure
Di bagian 'Timer1_Tick' ketikkan :
Dim p As POINTAPI
GetCursorPos(p)
Me.Left = p.X + 5
Me.Top = p.Y + 5
0 komentar: