WM_MOUSEWHEEL compilation problem

This is a discussion on WM_MOUSEWHEEL compilation problem within the Windows Programming forums, part of the Platform Specific Boards category; I have MSVC++ 6.0, and am attempting to use the WM_MOUSEWHEEL message. I get this error when compiling: error C2065: ...

  1. #1
    jasondoucette.com JasonD's Avatar
    Join Date
    Mar 2003
    Posts
    278

    WM_MOUSEWHEEL compilation problem

    I have MSVC++ 6.0, and am attempting to use the WM_MOUSEWHEEL message. I get this error when compiling:

    error C2065: 'WM_MOUSEWHEEL' : undeclared identifier

    I know that WM_MOUSEWHEEL is defined in winuser.h, which is automatically included when you declare:

    #include <windows.h>

    I checked winuser.h to see if it was declared within it, and I see it declared only in this section:

    Code:
    #if (_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)
    #define WM_MOUSEWHEEL                   0x020A
    #define WM_MOUSELAST                    0x020A
    #else
    #define WM_MOUSELAST                    0x0209
    #endif /* if (_WIN32_WINNT < 0x0400) */
    Neither _WIN32_WINNT nor _WIN32_WINDOWS is defined. Where should these values be defined, and what should they equal for a WinXP system?

    (btw, if I changed the switch statement for the WM_MOUSEWHEEL message to this:

    Code:
         switch (message)
         {
               case 0x020A: // WM_MOUSEWHEEL = 0x020A
               // handle mouse wheel message
         }
    the program compiles fine, and the scrolling works.)

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    >>Where should these values be defined, and what should they equal for a WinXP system?<<

    Before you include <windows.h>, _WIN32_WINNT=0x0501 and WINVER=0x0501 (for winxp).

    See the post by Stoned_Coder in this thread:

    http://cboard.cprogramming.com/showt...533#post272533

    edit: correction,link added
    Last edited by Ken Fitlike; 06-03-2003 at 02:24 PM.

  3. #3
    jasondoucette.com JasonD's Avatar
    Join Date
    Mar 2003
    Posts
    278
    Ken Fitlike, thanks for the reply. Bascially, to use the WM_MOUSEWHEEL messages, I need to specifically define either WIN32_WINNT or _WIN32_WINDOWS to a value equal to or above 0x0400. Is this standard procedure for anyone writing a program that requires such newer functionalities in windows?

    As the link that you posted states, if I were to define WIN32_WINNT as 0x0501, I am classifying my program to be run only on a Windows XP system, which is not what I want. I want my program to be backwards compatible as far as possible.

    I am surprised that this isn't explained within MSDN for the WM_MOUSEWHEEL message (although, it does explain the old style of mouse wheel messages - MSH_MOUSEWHEEL for IntelliMouse mice).

    Edit: I found a page on MSDN that explains most of this:
    Using the SDK Headers

  4. #4
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    >> Bascially, to use the WM_MOUSEWHEEL messages, I need to specifically define either WIN32_WINNT or _WIN32_WINDOWS to a value equal to or above 0x0400. Is this standard procedure for anyone writing a program that requires such newer functionalities in windows?<<

    Yes. This is what I tend to do myself: #define minimum values; checks can be made at run-time to determine the exact version of windows etc and take appropriate action if a 'feature' is not supported.

    >>As the link that you posted states, if I were to define WIN32_WINNT as 0x0501, I am classifying my program to be run only on a Windows XP system, which is not what I want. I want my program to be backwards compatible as far as possible.<<

    What you asked originally was: "..what should they equal for a WinXP system?" But I reckoned you knew what you were doing.

    >>I am surprised that this isn't explained within MSDN<<

    haha! Sorry, I have to laugh: while MSDN is always the first stop for information, i've found that having a healthy cynicism regarding its actual content (or lack, thereof) is not a bad idea.

    The link to 'using the sdk headers' is likely to be useful for future reference, though.

  5. #5
    jasondoucette.com JasonD's Avatar
    Join Date
    Mar 2003
    Posts
    278
    Originally posted by Ken Fitlike
    Yes. This is what I tend to do myself: #define minimum values; checks can be made at run-time to determine the exact version of windows etc and take appropriate action if a 'feature' is not supported.
    Certainly. I know that there are commands to check to see if the system has a scroll wheel on the mouse, so I could use them.

    However, I would assume that I could place the WM_MOUSEWHEEL case statements in the program, and if the message is sent (for a system that has a mouse wheel, and a user who uses it), the case statement would handle it, and if it is not sent (on a system without a mouse wheel), well, then it's just like if you had one and refused to use it. What bothered me is that, for this type of 'check' (in quotes because it actually doesn't perform any type of checking to see if a mouse wheel exists) does not work, since WM_MOUSEWHEEL is not defined unless I define WIN32_WINNT or _WIN32_WINDOWS before including windows.h (unless, of course, I place in the value that WM_MOUSEWHEEL stands for myself).

    Originally posted by Ken Fitlike
    What you asked originally was: "..what should they equal for a WinXP system?" But I reckoned you knew what you were doing.
    Yes, sorry, I did not mean to imply that your answer was wrong in any way. This is what I asked, and you answered correctly. I honestly did not understand what they were for until you answered, and then I realized that they were meant for the minimal system (not the current system).

    Originally posted by Ken Fitlike
    haha! Sorry, I have to laugh: while MSDN is always the first stop for information, i've found that having a healthy cynicism regarding its actual content (or lack, thereof) is not a bad idea.

    The link to 'using the sdk headers' is likely to be useful for future reference, though.
    Usually, when something becomes outdated, MSDN makes sure to mention it. I would think when a new feature is added, it would also mention what is required for it to work.

    Thanks for the reply.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. searching problem
    By DaMenge in forum C Programming
    Replies: 9
    Last Post: 09-12-2005, 02:04 AM
  2. Compilation problem
    By OSDever in forum C++ Programming
    Replies: 10
    Last Post: 09-08-2005, 07:42 AM
  3. half ADT (nested struct) problem...
    By CyC|OpS in forum C Programming
    Replies: 1
    Last Post: 10-26-2002, 09:37 AM
  4. binary tree problem - help needed
    By sanju in forum C Programming
    Replies: 4
    Last Post: 10-16-2002, 06:18 AM

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