11

我正在创建一些始终处于顶部的吐司作为表单,当我打开它们时,我希望它们在打开时不会从其他表单中转移注意力。我怎样才能做到这一点?

谢谢

4

2 回答 2

16
protected override bool ShowWithoutActivation
{
    get
    {
        return true;
    }
}

在您的表单代码中覆盖此属性,它应该为您解决问题。

于 2009-03-26T14:57:40.550 回答
14

我花了几分钟使用上面的亚当和亚伦的信息,但我终于让它为我工作了。我必须做的一件事是确保表单的 Top Most 属性设置为 false。这是我使用的代码...

    protected override bool ShowWithoutActivation { get { return true; } }

    protected override CreateParams CreateParams
    {
        get
        {
            //make sure Top Most property on form is set to false
            //otherwise this doesn't work
            int WS_EX_TOPMOST = 0x00000008;
            CreateParams cp = base.CreateParams;
            cp.ExStyle |= WS_EX_TOPMOST;
            return cp;
        }
    }
于 2012-05-23T20:28:04.787 回答