Results 1 to 10 of 10

Thread: [VB6] - Mouse whell horizontal not working:(

  1. #1

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,961

    [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
    VB6 2D Sprite control

    To live is difficult, but we do it.

  2. #2
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    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

  3. #3

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,961

    Re: [VB6] - Mouse whell horizontal not working:(

    Quote Originally Posted by koolsid View Post
    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.
    VB6 2D Sprite control

    To live is difficult, but we do it.

  4. #4
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  5. #5

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,961

    Re: [VB6] - Mouse whell horizontal not working:(

    Quote Originally Posted by LaVolpe View Post
    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.
    VB6 2D Sprite control

    To live is difficult, but we do it.

  6. #6
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: [VB6] - Mouse whell horizontal not working:(

    Quote Originally Posted by joaquim View Post
    .ParentControls(0) is the form.
    Well, the form doesn't have a horizontal scrollbar, so how can you get WM_HSCROLL messages?
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  7. #7

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,961

    Re: [VB6] - Mouse whell horizontal not working:(

    Quote Originally Posted by LaVolpe View Post
    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?
    VB6 2D Sprite control

    To live is difficult, but we do it.

  8. #8
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  9. #9

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,961

    Re: [VB6] - Mouse whell horizontal not working:(

    Quote Originally Posted by LaVolpe View Post
    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?
    VB6 2D Sprite control

    To live is difficult, but we do it.

  10. #10
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width