View Full Version : Little OT but important ! WM_MOUSEWHEEL
03-24-2002, 02:59 AM
Hi, I've done mousesupport to my engine and all works except WM_MOUSEWHEEL.
WM_MOUSEWHEEL: undeclared identifier.
windows.h and winuser.h are included.
What am I doing wrong, or wich file have i forgotten to include ?
Thanks anyway, StryX
03-24-2002, 03:20 AM
Hmm, not my fault.
If you have the problem too, here is the solution:
Open up winuser.h in your VC98\Include Folder.
Search for "WM_MBUTTONDBLCLK"
Under this #define statement ther is an if statement:
#if (_WIN32_WINNT >= 0x0400) (_WIN32_WINDOWS > 0x0400)
Ok, now copy the line with WM_MOUSEWHEEL out of it and insert it above the if statement.
A few lines below there you'll find something like that:
#if(_WIN32_WINNT >= 0x0400)
cut the #define WHEEL_DELTA 120 line and paste it after you WM_MOUSEWHEEL above.
As you'll notice, there is something called WHEEL_PAGESCROLL.
Well, I've never used this so I let it there.
Now to get you WM_MOUSEWHEEL use
case WM_MOUSEWHEEL in your MesageSelection.
In the Win32-Reference they said that WM_MOUSEWHEEL is not supported by W95 and W32s.
Whatever that means, in W98 it works.
Have fun using your wheel !
03-24-2002, 10:19 AM
There is an easier solution to that than modifying or copying the header. And the docs are right, WM_MOUSEWHEEL is not supported in Win95. And by default your compiler is set to build Win95 applications. If you want to build Win98 applications simply redefine _WIN32_WINDOWS in your code to be greater than 0x400. I use 0x410 for compiling a Win98 application. You should also set WINVER to 0x500 for Windows 98 applications.
[This message has been edited by DFrey (edited 03-24-2002).]
03-25-2002, 02:48 AM
What does "does not work under Win95" mean? Does it mean that if I try to use the mouse wheel (listen for WM_MOUSEWHEEL events), my program will crash (or similar), or does it mean that I simply will get no WM_MOUSEWHEEL messages???
In the latter case, I see no reason not to define the constant for Win95 apps.
Anyway, I generally think it's extremely bad coding to modify your include files. Do a #ifndef statement in your source instead and define it yourself if it's not already defined:
#define WM_MOUSEWHEEL 0x020A
#endif // WM_MOUSEWHEEL
#define WHEEL_DELTA 120
#endif // WHEEL_DELTA
...also remember: MSVC is not the only compiler out there - other compilers may have different headers (the win32/winnt flag trick might not work).
[This message has been edited by marcus256 (edited 03-25-2002).]
03-25-2002, 05:22 AM
Setting those constants will work as long as you are using the headers from the Windows SDK, and is a standard Windows programming practice.
If you simply define those message values, then try to run the program on Win95, you will get incorrect behavior (no mouse wheel). Again, Win95 uses its own seperate Intellimouse API for handling the mousewheel. That API defines only a subset of mouse wheel messages, and defines them as values that are different from the standard defines in the winuser.h. So, for Win95 winuser.h will not define the mouse wheel stuff, and none of it will be defined unless you specifically include the Intellimouse API in your Win95 app. On the otherhand, if you are properly building a Win98 or WinNT4 app, the mouse wheel stuff is defined by winuser.h as those operating systems natively support mouse wheels.
03-25-2002, 05:26 AM
since this is a very windows-specific question and has nothing to do with openGL, i suggest you better use the codeguru forum for such requests at www.codeguru.com (http://www.codeguru.com)
this is NOT a flame, but codeguru actually is the best forum for such questions, usually you get a satisfactory reply within 5 minutes or less there http://www.opengl.org/discussion_boards/ubb/smile.gif
03-25-2002, 07:18 AM
I'll not use this Forum Offtopic next time.
Sorry but it was very important that time.
I'll do it better next time !
03-25-2002, 10:28 PM
hoshi55, I see your point (and agree).
DFrey, since we have this thread running anyway, I would just like to post one more question:
What you are saying sounds as if I build my app for Win98/NT using mouse wheel support, it will not run properly under Win95? In other words:
I poll for WM_MOUSEWHEEL events, and calculate the wheel delta as:
WheelDelta = (((int)wParam) >> 16) / WHEEL_DELTA;
...in order to maintain a local mouse wheel position variable (add WheelDelta to the variable every time I receive a WM_MOUSEWHEEL event).
Would this crash on Win95, or simply have no effect??? If it means that it would crash (or have undefined behaviour), I would need to check if the program is running under Win95 at runtime, and skip WM_MOUSEWHEEL messages in that case.
03-25-2002, 10:42 PM
It would not work at all on Win95 and might cause it to crash (though I suspect that is unlikely). On Win95, you need to have MSWHEEL.EXE running, this app creates a hidden window and it is what creates the wheel messages for Win95. So on Win95 you have to first find that hidden window, and then query it to determine if the mouse wheel is supported. If it is, then you can use the mouse wheel constants the Intellimouse API defines (which is in the header zmouse.h), those mouse wheel constants are different from the one defined in Win98 so if you want to support mouse wheels in both Win95 and Win98 by way of windows messages, you have to take extra care to first determine what operating system is being used, then use that information to select the correct mouse wheel code to use. However, there is an exception, if you are using DirectInput to query the mouse, you can easily access the mouse wheel on both Win95 and Win98 in exactly the same way (as a relative axis).
[This message has been edited by DFrey (edited 03-25-2002).]
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.