1

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

我在说这些

4

4 回答 4

3

你可以使用这个:

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

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

于 2012-09-08T11:44:02.567 回答
0

是的,当触发 MouseHover 事件时,您可以使用工具提示来控制按钮。

VB代码...

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.MouseHover
ToolTip1.SetToolTip(Button1, "sometext")
End Sub

这是更多信息。希望能帮助到你。 http://bytes.com/topic/visual-basic-net/answers/683286-hover-text-command-buttons

于 2012-09-08T09:04:16.663 回答
0

您也可以使用此自定义用户控件。检查这是否适合您。 http://www.codeproject.com/Articles/42223/Easy-Customize-Title-Bar

于 2012-09-08T09:16:30.010 回答
-2

如果您没有太多控件,请将事件处理程序添加到控件的鼠标悬停事件中。

于 2012-09-08T09:00:23.873 回答