Please see the following code fragment:
case WM_SETTINGCHANGE:
SystemParametersInfo(SPI_GETWHEELSCROLLLINES,0,&ulScrollLines,0);
if(ulScrollLines)
iDeltaPerLine = WHEEL_DELTA / ulScrollLines;
else
iDeltaPerLine = 0;
return 0;
The program contains many other lines, however, this is where the following
errors come from :
c:\_DTS_PROGRAMMING\vc++\CURRENT\CPZ_Pxxx\CPZ_P318_SYSMETS\SYSMETS3.cpp(78)
: error C2065: 'SPI_GETWHEELSCROLLLINES' : undeclared identifier
c:\_DTS_PROGRAMMING\vc++\CURRENT\CPZ_Pxxx\CPZ_P318_SYSMETS\SYSMETS3.cpp(81)
: error C2065: 'WHEEL_DELTA' : undeclared identifier
If I right click on these identifiers, they are already defined in C
libraries. So why is VC++ saying that they are not defined? I am not sure if
Windows.h includes them.
'SPI_GETWHEELSCROLLLINES' >>> Defined in viewscrl.cpp and in winuser.h
'WHEEL_DELTA' >>> Defined in winuser.h and in zmouse.h
Also, the following case message in win proc
WM_MOUSEWHEEL:
produces the following errors:
c:\_DTS_PROGRAMMING\vc++\CURRENT\CPZ_Pxxx\CPZ_P318_SYSMETS\SYSMETS3.cpp(230)
: error C2065: 'WM_MOUSEWHEEL' : undeclared identifier
c:\_DTS_PROGRAMMING\vc++\CURRENT\CPZ_Pxxx\CPZ_P318_SYSMETS\SYSMETS3.cpp(230)
: error C2051: case expression not constant
I don't know where these errors are comming from... Can anyone help me !
--
Best regards
Robert
>Hello,
>
>Please see the following code fragment:
>
>case WM_SETTINGCHANGE:
> SystemParametersInfo(SPI_GETWHEELSCROLLLINES,0,&ulScrollLines,0);
>
> if(ulScrollLines)
> iDeltaPerLine = WHEEL_DELTA / ulScrollLines;
> else
> iDeltaPerLine = 0;
>
>return 0;
>
>The program contains many other lines, however, this is where the following
>errors come from :
>
>c:\_DTS_PROGRAMMING\vc++\CURRENT\CPZ_Pxxx\CPZ_P318_SYSMETS\SYSMETS3.cpp(78)
>: error C2065: 'SPI_GETWHEELSCROLLLINES' : undeclared identifier
>
>c:\_DTS_PROGRAMMING\vc++\CURRENT\CPZ_Pxxx\CPZ_P318_SYSMETS\SYSMETS3.cpp(81)
>: error C2065: 'WHEEL_DELTA' : undeclared identifier
>
>
>If I right click on these identifiers, they are already defined in C
>libraries. So why is VC++ saying that they are not defined? I am not sure if
>Windows.h includes them.
It does. More than likely, you're using an outdated SDK, or you haven't
#defined _WIN32_WINNT properly. It has to be >= 0x0400, as can be
discovered by grepping the SDK header <winuser.h>:
#if(_WIN32_WINNT >= 0x0400)
/* Value for rolling one detent */
#define WHEEL_DELTA 120
...
--
Doug Harrison
Visual C++ MVP
> I don't know where these errors are comming from... Can anyone help me !
Have you #defined your target platform correctly? These macros are probably
only defined by <windows.h> if you've set your windows version to NT 4.0 or
later.
See
for information on which macros to define, and what values to give them to
specify the minimum version of windows that your application targets.
-cd
I have gone to your link and I see that there is a table of the prefered
macros in use by header files. I currently have Windows XP S2 installed in my
machine which coresponds to the following define statement in this table:
NTDDI_VERSION >=NTDDI_WINXPSP2
and the following table coresponds to the following:
_WIN32_WINNT>=0x0501
WINVER>=0x0501
Now, when I right click on WHEEL_DELTA in my program it takes me to the
following definition:
#if(_WIN32_WINNT >= 0x0400)
/* Value for rolling one detent */
#define WHEEL_DELTA 120
#define GET_WHEEL_DELTA_WPARAM(wParam) ((short)HIWORD(wParam))
I don't know what to do.. do I have to change the 400 to 501? or is there a
setting in the project properties I must change?
Please get back!
I am now currently stuck. I most appreciate any help that can get me out of
this problem!
--
Best regards
Robert
This issue has nothing to do with the operating system on your machine.
It is about the minimum operating system your program will require
when it executes. For example, if you use SDK definitions that did not
exist for Windows 95 your program cannot run on Windows 95.
You should #define _WIN32_WINNT and the other macros to have values
appropriate for your operating system requirements. This is usually
done in your project's stdafx.h file, prior to the #include's. Defining
the values there has the effect of making newer portions of the SDK
headers "invisible" to your program so you will not use something that
is not available in your target OS versions.
--
Scott McPhillips [VC++ MVP]
I don't know if you got a post prior to this one, I think I wrote it and
then I lost it...
Anyhow I did a search for all files called stdafx.h and I got approximately
35 files. Which would be the file I would have to do the #defines .
--
Best regards
Robert
One and only one of those stdafx.h files is in the same directory as
your other source code files and is listed in the file view of your
project in Visual Studio. That's the one: Edit your project's stdafx.h
file.
There is no editing of Windows header files being suggested - that is a
no no.
>Thankyou for your post CARL:
>
>I have gone to your link and I see that there is a table of the prefered
>macros in use by header files. I currently have Windows XP S2 installed in my
>machine which coresponds to the following define statement in this table:
>
>NTDDI_VERSION >=NTDDI_WINXPSP2
>
>and the following table coresponds to the following:
>
>_WIN32_WINNT>=0x0501
>WINVER>=0x0501
>
>Now, when I right click on WHEEL_DELTA in my program it takes me to the
>following definition:
>
>#if(_WIN32_WINNT >= 0x0400)
>/* Value for rolling one detent */
>#define WHEEL_DELTA 120
>#define GET_WHEEL_DELTA_WPARAM(wParam) ((short)HIWORD(wParam))
>
>I don't know what to do.. do I have to change the 400 to 501? or is there a
>setting in the project properties I must change?
The SDK and compiler include files allow you to build programs for any
version of Windows. When you are building a program that you KNOW will be
run on Windows NT 3.51, for example, you want to make sure that you don't
call any APIs that were introduced after that. The include files help you
do that, using the _WIN32_WINNT symbol.
_WIN32_WINNT is a symbol defined by YOU in YOUR project settings (or YOUR
stdafx.h). When you set _WIN32_WINNT to 0x400, for example, you are saying
"I need this program to run on Windows NT 4.0, so please don't allow me to
call any XP-only APIs". If you do not define _WIN32_WINNT, the default
setting hides all of the APIs introduced after NT 3.51.
In your case, you are asking for an API that was introduced in NT 4.0.
Thus, you need to tell the compiler that you need those APIs. To do that,
you have to get _WIN32_WINNT defined to at least 0x0400. One way to do is
to add:
#define _WIN32_WINNT 0x0400
early in your stdafx.h. Another way is to add:
-D_WIN32_WINNT=0x0400
to your project settings.
The NTDDI_VERSION symbol is part of the DDK, not the SDK.
--
- Tim Roberts, ti...@probo.com
Providenza & Boekelheide, Inc.