|
-
Feb 4th, 2010, 04:19 PM
#1
Thread Starter
PowerPoster
[VB6] - Mouse whell horizontal not working:(
i have a module for work with mouse whell, but the horizontal mouse whell isn't detected
Code:
Option Explicit
Private PrevWin2 As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Const GWL_WNDPROC = (-4)
Private Const WM_MOUSEWHEEL = &H20A
Private Const WM_KEYDOWN = &H100
Public MouseOverControl As Long ' Handle for User Control (mouse move)
Private Const WM_HSCROLL = &H114
'with these public variable i can, only, use these event when the mouse is in control
'because out off it, isn't need it;)
Private Function Proc2(ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If Msg = WM_HSCROLL Then MsgBox "oi"
Proc2 = CallWindowProc(PrevWin2, hWnd, Msg, wParam, lParam)
End Function
Public Sub Hook2(handle As Long)
If PrevWin2 = 0 Then
PrevWin2 = SetWindowLong(handle, GWL_WNDPROC, AddressOf Proc2)
End If
End Sub
Public Sub Unhook2(handle As Long)
If PrevWin2 Then
Call SetWindowLong(handle, GWL_WNDPROC, PrevWin2)
PrevWin2 = 0
End If
End Sub
i do the horizontal scroll, but these message isn't showed
can anyone explain to me what isn't right(i use the toutchpad)?
thanks
-
Feb 6th, 2010, 08:05 AM
#2
Re: [VB6] - Mouse whell horizontal not working:(
i do the horizontal scroll, but these message isn't showed
Where are you doing this? listbox, Form, RTB... where?
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Feb 6th, 2010, 08:39 AM
#3
Thread Starter
PowerPoster
Re: [VB6] - Mouse whell horizontal not working:(
 Originally Posted by koolsid
Where are you doing this? listbox, Form, RTB... where?
Code:
If blnCreate = False Then
blnMove = False
lngOldPosX = Extender.Left
lngOldPosY = Extender.Top
Hook2 UserControl.ParentControls(0).hWnd
Call ContainerScaleMode
RaiseEvent Created(lngOldPosX, lngOldPosY)
blnCreate = True
End If
these code is activated when the usercontrol is created.
-
Feb 7th, 2010, 12:58 PM
#4
Re: [VB6] - Mouse whell horizontal not working:(
Two things.
1. Never put a msgbox in your subclass procedure. You will crash. Use Debug.Print instead.
2. If .ParentControls(0) does not have a horizontal scrollbar, then you won't get the message.
-
Feb 7th, 2010, 01:03 PM
#5
Thread Starter
PowerPoster
Re: [VB6] - Mouse whell horizontal not working:(
 Originally Posted by LaVolpe
Two things.
1. Never put a msgbox in your subclass procedure. You will crash. Use Debug.Print instead.
2. If .ParentControls(0) does not have a horizontal scrollbar, then you won't get the message.
.ParentControls(0) is the form. but that's true, the form doesn't have the scrollbar. but why doesn't work in same way of WM_MOUSEWHEEL?
Last edited by joaquim; Feb 7th, 2010 at 01:07 PM.
-
Feb 7th, 2010, 01:07 PM
#6
Re: [VB6] - Mouse whell horizontal not working:(
 Originally Posted by joaquim
.ParentControls(0) is the form.
Well, the form doesn't have a horizontal scrollbar, so how can you get WM_HSCROLL messages?
-
Feb 7th, 2010, 01:09 PM
#7
Thread Starter
PowerPoster
Re: [VB6] - Mouse whell horizontal not working:(
 Originally Posted by LaVolpe
Well, the form doesn't have a horizontal scrollbar, so how can you get WM_HSCROLL messages?
then how doesn't work in same way of WM_MOUSEWHEEL?
-
Feb 7th, 2010, 01:35 PM
#8
Re: [VB6] - Mouse whell horizontal not working:(
It just doesn't. If the form does not have WS_VScroll & WS_HScroll window styles, then you won't get WM_VScroll & WM_HScroll messages. You can still get WM_MouseWheel messages even if no scrollbars are present.
Edited: Though you can add those window styles and then later hide the scrollbar with the ShowScrollbar API, hidden scrollbars are just the same as not having them -- no messages.
-
Feb 7th, 2010, 01:38 PM
#9
Thread Starter
PowerPoster
Re: [VB6] - Mouse whell horizontal not working:(
 Originally Posted by LaVolpe
It just doesn't. If the form does not have WS_VScroll & WS_HScroll window styles, then you won't get WM_VScroll & WM_HScroll messages. You can still get WM_MouseWheel messages even if no scrollbars are present.
if so. how can i get the horizontal wheel? is there another api const message?
-
Feb 7th, 2010, 01:44 PM
#10
Re: [VB6] - Mouse whell horizontal not working:(
How? Through the window procedure? Without having those styles, I don't think you can because the messages won't be sent to the window.
I don't know if it is the answer, but you may want to experiment with a MouseHook. Look at SetWindowsHookEx and WH_MOUSE. Here is an example of the Hook procedure, notice the wParam value. If it contains WM_HScroll and/or WM_VScroll, then you have your answer.
Recommendation: Experiment in a new project.
Edited: After second thougths; that probably won't work either. WM_HSCroll/VScroll are not mouse messages, they are scrollbar messages.
Last edited by LaVolpe; Feb 7th, 2010 at 01:51 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|