【问题标题】:Semitransparent form that skips (or sends to background) mouse input?跳过(或发送到后台)鼠标输入的半透明表单?
【发布时间】:2010-12-03 23:51:43
【问题描述】:

我如何制作一个表单,无论我用鼠标在上面做什么,它都会像表单不存在,而后面的任何东西(这将成为我的应用程序的一部分)都将接收所有鼠标输入。我想做的基本上是一个突出显示用户需要单击的控件的教程。我知道如何产生点击,但我想将功能扩展到每一个可能的鼠标输入。我尝试在我的表单中处理WndProc 并将消息发送到后面的任何东西,但那是一团糟。有没有更好的方法来做到这一点?

另一种可能性是保持我的表单透明并在任何应该接收鼠标输入的控件周围进行绘制,但我只想知道是否可以突出显示(使用半透明画笔在控件上绘制)。

【问题讨论】:

    标签: c# .net winforms .net-4.0


    【解决方案1】:

    使用带有父窗口参数的构造函数创建一个教程窗口(半透明)。 在窗口的 MouseDown / MouseUp 事件中调用父级的 mouse down / mouse up 事件处理程序。

    公共部分类 ParentWindow :窗口 { 公共父窗口() { 初始化组件(); }

    private void testButton_Click(object sender, RoutedEventArgs e)
    {
        TutorialWindow tutorialWindow = new TutorialWindow(this);
        tutorialWindow.Show();
    }
    
    public void Window_MouseDown(object sender, MouseButtonEventArgs e)
    {
        // Do something
    }
    

    }

    还有 TutorialWindow 类

    公共部分类 TutorialWindow : Window { 私有 ParentWindow 父级;

    public TutorialWindow(ParentWindow parent)
    {
        InitializeComponent();
        this.parent = parent;
    }
    
    private void Window_MouseDown(object sender, MouseButtonEventArgs e)
    {
        this.parent.Window_MouseDown(sender, e);
    }
    

    }

    可以修改教程窗口的属性,使其半透明,甚至在用户单击窗口时“消失”。

    【讨论】:

      猜你喜欢
      • 2012-01-22
      • 1970-01-01
      • 2011-11-09
      • 2017-03-27
      • 2011-04-16
      • 1970-01-01
      • 2019-06-13
      • 1970-01-01
      • 2012-07-15
      相关资源
      最近更新 更多