有没有办法检查鼠标何时位于标准窗口控制按钮上方(关闭、最小化等)? [英] Is there a way to check when mouse is above standard window control buttons (close, minimize etc)?

查看:26
本文介绍了有没有办法检查鼠标何时位于标准窗口控制按钮上方(关闭、最小化等)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当鼠标位于标准窗口控件之一(关闭、最小化、最大化)上方时,我想运行一个方法.我该怎么做?

I'd like to run a method when mouse is above one of the standard window controls (close, minimize, maximize). How do I do that?

推荐答案

你可以使用这个:

internal const int WM_NCMOUSEMOVE = 0x00A0;

protected override void WndProc(ref Message m)
{
    if (m.Msg == WM_NCMOUSEMOVE)
    {
        if ((int)m.WParam == 0x8)
            Console.WriteLine("Mouse over on Minimize button");

        if ((int)m.WParam == 0x9)
            Console.WriteLine("Mouse over on Maximize button");

        if ((int)m.WParam == 0x14)
            Console.WriteLine("Mouse over on Close button");
    }

    base.WndProc(ref m);
}

只需将其放入表单代码中即可.

just put it in your form's code.

这篇关于有没有办法检查鼠标何时位于标准窗口控制按钮上方(关闭、最小化等)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆