如何确定是否按下了鼠标左键?

时间:2012-12-06 06:15:11

标签: c# dll

在winform中,当鼠标停止时,表单将跟随鼠标,但有时当机器特别慢时,表格是跟着鼠标,即使鼠标出来,所以我用win32 dll来判断状态鼠标

 [DllImport("user32.dll")]
    static extern short GetAsyncKeyState(int nVirtKey);
    public static bool GetCurrentLeftMouseIsDowning()
    {
        if (GetAsyncKeyState(0x01) == 0)
            return false;
        else
            return true;
    }

但是当表单被拖动时内存会增加,还有什么方法可以确定鼠标的状态?或者在拖动表单时如何控制内存?

1 个答案:

答案 0 :(得分:0)

考虑到您使用的是winform,可以使用form1_mousedown事件进行此

参考this

相关问题