I made this code for 3D Effect in a Game, this code help change Possition and Zoom In + Out the screen!
But if I run it on win 7 64 bits, when scroll the mouse wheel, both forward and backward, it Zoom In only but it works correctly when run on Windows 7 32 bits!
How can I fix it for any win?
Thanks for any help!!!!
LRESULT CALLBACK MouseProc(int code, WPARAM wParam, LPARAM lParam)
{
MOUSEHOOKSTRUCTEX* mhs = (MOUSEHOOKSTRUCTEX*)lParam;
HWND MuWnd = FindWindow(TEXT("MU"), NULL);
if(UseCamera)
{
if(GetForegroundWindow() == MuWnd)
{
if(InitCamera)
{
Camera.ClipX = *Camera_ClipX;
Camera.ClipY = *Camera_ClipY;
Camera.GlClip = *Camera_GlClip;
Camera.PosZ = *Camera_PosZ;
Camera.RotY = *Camera_RotY;
Camera.RotZ = -45;
Camera.Zoom = *Camera_Zoom;
InitCamera = false;
}
else if(wParam == WM_MBUTTONDOWN)
{
MouseX = mhs->pt.x;
MouseY = mhs->pt.y;
MoveCamera = true;
}
else if(wParam == WM_MBUTTONUP)
{
MoveCamera = false;
}
else if(wParam == WM_MOUSEWHEEL)
{
int direction = mhs->mouseData;
if(direction < 0)
{
if(*Camera_Zoom < 60)
{
*Camera_Zoom += 2;
}
*Camera_ClipX = 1190 + (abs(*Camera_PosZ - 150) * 3) + 4000;
*Camera_ClipY = 2400 + (abs(*Camera_PosZ - 150) * 3) + 4000;
*Camera_GlClip = 2300 + (abs(*Camera_PosZ - 150) * 3) + 4000;
}
else if(direction > 0)
{
if(*Camera_Zoom > 12)
{
*Camera_Zoom -= 2;
}
*Camera_ClipX = 1190 + (abs(*Camera_PosZ - 150) * 3) + 4000;
*Camera_ClipY = 2400 + (abs(*Camera_PosZ - 150) * 3) + 4000;
*Camera_GlClip = 2300 + (abs(*Camera_PosZ - 150) * 3) + 4000;
}
}
else if(wParam == WM_MOUSEMOVE)
{
if(MoveCamera)
{
if(MouseX < mhs->pt.x)
{
*Camera_RotZ += 8;
if (*Camera_RotZ > 315) *Camera_RotZ = -45;
}
else if(MouseX > mhs->pt.x)
{
*Camera_RotZ -= 8;
if (*Camera_RotZ < -405) *Camera_RotZ = -45;
}
if(MouseY < mhs->pt.y)
{
if(*Camera_RotY < -45)
{
*Camera_PosZ -= 44;
*Camera_RotY += (double)2.42;
}
}
else if(MouseY > mhs->pt.y)
{
if(*Camera_RotY > -90)
{
*Camera_PosZ += 44;
*Camera_RotY -= (double)2.42;
}
}
MouseX = mhs->pt.x;
MouseY = mhs->pt.y;
*Camera_ClipX = 1190 + (abs(*Camera_PosZ - 150) * 3) + 4000;
*Camera_ClipY = 2400 + (abs(*Camera_PosZ - 150) * 3) + 4000;
*Camera_GlClip = 2300 + (abs(*Camera_PosZ - 150) * 3) + 4000;
}
}
}
}
return CallNextHookEx(MouseHook, code, wParam, lParam);
}
Problem is solved with that fix:
http://support.microsoft.com/kb/2752274/en-us