LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Use WM_MOUSEWHEEL??

I want to use the Mouse Wheel for zoom a picture in and out!!

I want to get the WM whit this:


int postHandle;

//Win M
Ret = InstallWinMsgCallback (moinPanel, WM_MOUSEWHEEL, cbMouseWheel,
VAL_MODE_IN_QUEUE, NULL, &postHandle);

strcpy(ErrorM, GetGeneralErrorString (Ret));


//THE CALLBACK
int CVICALLBACK cbMouseWheel (int panelHandle, int message,
unsigned int* wParam,
unsigned int* lParam,
void* callbackData)
{
zDelta = GET_WHEEL_DELTA_WPARAM(wParam);

if(zDelta==+120)
{
ZoomIn();
}

if(zDelta==-120)
{
ZoomOot();

return 0;
}

I have included the winuser.h!

And now when I run the programm theres an error message:

Undeclared identifier 'WM_MOUSEWHEEL'.


I think it becaus this here in the winuser.h:

#if (_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)
#define WM_MOUSEWHEEL 0x020A
#endif

I use win XP!

I try the same thing with the WM_MBUTTONDOWN and It works!!


Can someone help me with this problem!
0 Kudos
Message 1 of 4
(5,068 Views)
Go to the Build options and add this line to the compiler defines

/D_WIN32_WINNT=0x0501

This will allow you to include all the functionality that is present in the Windows SDK for XP

If you prefer to add this to your code, just define _WIN32_WINNT as the given value before any of the includes.

Microsoft organizes the Windows SDK header files in this manner to avoid using newer features in older OS's. For more information, check out this article here

Hope this helps
Bilal Durrani
NI
0 Kudos
Message 2 of 4
(5,042 Views)
Thanks for your answer!

Now it works with the WM_MOUSEWHEEL!

But theres an other preoblem with evaluate which way the scrollwheel is moved!

short zDelta;

zDelta = GET_WHEEL_DELTA_WPARAM(wParam);

When I move the Scroll forward and Backward the zDelta have the same Value!

But the zDelta must have one way a -Value and the other way a +Value!

Whats wrong?
0 Kudos
Message 3 of 4
(5,032 Views)
I did some searching and it appears as though the macro (GET_WHEEL_DELTA_PARAM) actually takes in a HIWORD of wParam, and so the HIWORD will always be a positive number. You may actually have to put in a Mouse Hook (WH_MOUSE) using the MouseHookStructEx structure and the MouseData parameter. I don't have much more detail on this, but you should take a look in the msdn for information on this structure and mouse hooks. Hope this helps!
Jeremy L.
National Instruments
0 Kudos
Message 4 of 4
(5,014 Views)