WM_MOUSEWHEEL problems

This is a discussion on WM_MOUSEWHEEL problems within the Windows Programming forums, part of the Platform Specific Boards category; Hi all, I am using the WM_MOUSEWHEEL message in my program, but I am having trouble detecting two things: the ...

  1. #1
    Registered User
    Join Date
    Jul 2005
    Posts
    64

    WM_MOUSEWHEEL problems

    Hi all,

    I am using the WM_MOUSEWHEEL message in my program, but I am having trouble detecting two things: the direction of scrolling and checking whether or not the mouse wheel itself was pressed/clicked.

    I read that the high-order word of the WPARAM parameter returns positive if the user rotated the mouse wheel forward and negative if he/she rotated it backwards. So this is what I did:

    Code:
    case WM_MOUSEWHEEL:
    if(HIWORD(wParam) > 0)  //if user rotated the wheel forward
    {//handle it accordingly}
    if(HIWORD(wParam) < 0)  //if user rotated the wheel backward
    {//handle it accordingly}
    I also read that pressing the mouse wheel is equivalent to the WM_MBUTTONDOWN message, but that is not working in my program.

    Thanks to you all.

    Bill

  2. #2
    Registered User
    Join Date
    Jul 2005
    Posts
    64
    Ok I solved the first problem. I had to do an explicit type cast of short:

    Code:
    if ((short)HIWORD(wParam) > 0)
       {// handle it accordingly}
    if ((short)HIWORD(wParam) < 0)
       {//handle it accordingly}
    All I have left is the last problem: how do I detect whether or not the mouse wheel itself was clicked?

    Thanks again.

    Bill

  3. #3
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    I also read that pressing the mouse wheel is equivalent to the WM_MBUTTONDOWN message, but that is not working in my program.
    WM_MBUTTONDOWN/WM_MBUTTONUP should work. Do you get correct behaviour when you click the mouse wheel in other applications? For example, in Firefox and IE, you should get a up/down scroller symbol.

  4. #4
    Registered User
    Join Date
    Jul 2005
    Posts
    64
    Thanks for your reply. I actually do get the scroller symbol in IE, but I do not know why it is not responding to WM_MBUTTONDOWN in my program.

  5. #5
    Registered User
    Join Date
    Jul 2005
    Posts
    64
    I'm sorry you're right. Looks like I have to debug my program, because it works with other programs.

    Thanks again.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. No clue how to make a code to solve problems!
    By ctnzn in forum C Programming
    Replies: 8
    Last Post: 10-16-2008, 03:59 AM
  2. C Pointers Problems
    By mhelal in forum C Programming
    Replies: 8
    Last Post: 01-10-2007, 06:35 AM
  3. String Manipulation problems -_-
    By Astra in forum C Programming
    Replies: 5
    Last Post: 12-13-2006, 05:48 PM
  4. contest problems on my site
    By DavidP in forum Contests Board
    Replies: 4
    Last Post: 01-10-2004, 09:19 PM
  5. DJGPP problems
    By stormswift in forum C Programming
    Replies: 2
    Last Post: 02-26-2002, 04:35 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21