Menggunakan Mouse Scroll
Kode ini akan menunjukkan bagaimana menggunakan mouse scroll atau roda di mouse.
Buat sebuah Form baru dan ketikkan kode berikut di bagian '(Declarations)'-nya.
Option Explicit
Private Declare Function PeekMessage Lib "user32" Alias "PeekMessageA" (lpMsg As msg, ByVal hwnd As Long, ByVal wMsgFilterMin As Long, ByVal wMsgFilterMax As Long, ByVal wRemoveMsg As Long) As Long
Private Declare Function WaitMessage Lib "user32" () As Long
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Type msg
hwnd As Long
Message As Long
wParam As Long
lParam As Long
time As Long
pt As POINTAPI
End Type
Private Const PM_REMOVE = &H1
Private Const WM_MOUSEWHEEL = 522
Public Sub ProcessScroll()
Dim Message As msg
WaitMessage
If PeekMessage(Message, Form1.hwnd, WM_MOUSEWHEEL, WM_MOUSEWHEEL, PM_REMOVE) Then
If Message.wParam > 0 Then
'kode untuk scroll up
Form1.Top = Form1.Top - 250
Else
'kode untuk scroll down
Form1.Top = Form1.Top + 250
End If
End If
DoEvents
End Sub
Private Declare Function PeekMessage Lib "user32" Alias "PeekMessageA" (lpMsg As msg, ByVal hwnd As Long, ByVal wMsgFilterMin As Long, ByVal wMsgFilterMax As Long, ByVal wRemoveMsg As Long) As Long
Private Declare Function WaitMessage Lib "user32" () As Long
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Type msg
hwnd As Long
Message As Long
wParam As Long
lParam As Long
time As Long
pt As POINTAPI
End Type
Private Const PM_REMOVE = &H1
Private Const WM_MOUSEWHEEL = 522
Public Sub ProcessScroll()
Dim Message As msg
WaitMessage
If PeekMessage(Message, Form1.hwnd, WM_MOUSEWHEEL, WM_MOUSEWHEEL, PM_REMOVE) Then
If Message.wParam > 0 Then
'kode untuk scroll up
Form1.Top = Form1.Top - 250
Else
'kode untuk scroll down
Form1.Top = Form1.Top + 250
End If
End If
DoEvents
End Sub
Lalu tambahkan sebuah kontrol Timer (Interval=1), dan ketikkan kode berikut di bagian 'Timer1_Timer'.
Call ProcessScroll
Label: (Menengah), Hardware, VB 6.0
0 Komentar:
Posting Komentar
Pengunjung yang baik selalu meninggalkan jejak berupa komentar. :)
Berlangganan Posting Komentar [Atom]
<< Beranda