1

我为游戏中的 3D 效果制作了这段代码,这段代码有助于改变位置和放大 + 缩小屏幕!

但是,如果我在 win 7 64 位上运行它,当向前和向后滚动鼠标滚轮时,它只会放大,但在 Windows 7 32 位上运行时它可以正常工作!

我该如何解决它以获得任何胜利?
谢谢你的帮助!!!!

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);
}
4

3 回答 3

3

该修复程序解决了问题:http:
//support.microsoft.com/kb/2752274/en-us

于 2012-11-22T16:20:45.613 回答
1

从文档中您可以阅读:

mouseData 类型:DWORD 如果消息是 WM_MOUSEWHEEL,则此成员的 HIWORD 是车轮增量。LOWORD 未定义且保留。正值表示滚轮向前旋转,远离用户;负值表示轮子向后旋转,朝向用户。一轮点击定义为 WHEEL_DELTA,即 120。

所以我想如果你使用 HIWORD(mhs->mouseData) 可能会更好。另请注意,结果是无符号的。

于 2012-11-22T08:45:12.950 回答
0

我通过在 WM_MOUSEWHEEL 事件中测试非零来解决这个问题......然后测试是否为“120”......

WM_MOUSEWHEEL:
if(HIWORD(wParam) == 120)
{
//Do Code for forward
}
else
{ 
//Do Code for reverse
}
于 2021-02-18T20:07:42.073 回答