[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
Re: [VB6] - Mouse whell horizontal not working:(
Quote:
i do the horizontal scroll, but these message isn't showed
Where are you doing this? listbox, Form, RTB... where?
Re: [VB6] - Mouse whell horizontal not working:(
Quote:
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.
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.
Re: [VB6] - Mouse whell horizontal not working:(
Quote:
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?
Re: [VB6] - Mouse whell horizontal not working:(
Quote:
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?
Re: [VB6] - Mouse whell horizontal not working:(
Quote:
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?
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.
Re: [VB6] - Mouse whell horizontal not working:(
Quote:
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?
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.