本文介绍了显示不偷焦点表格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用的形式展现通知(它出现在屏幕的右下角),但当我拿出这种形式,它抢断从主窗体的焦点。有没有一种方法,以显示此通知的形式,而不偷焦点?
I'm using a Form to show notifications (it appears at the bottom right of the screen), but when I show this form it steals the focus from the main Form. Is there a way to show this "notification" form without stealing focus?
推荐答案
嗯,不是简单地覆盖Form.ShowWithoutActivation就够了吗?
Hmmm, isn't simply overriding Form.ShowWithoutActivation enough?
protected override bool ShowWithoutActivation
{
get { return true; }
}
如果你不想让用户单击该通知窗口或者,您可以覆盖的CreateParams:
And if you don't want the user to click this notification window either, you can override CreateParams:
protected override CreateParams CreateParams
{
get
{
CreateParams baseParams = base.CreateParams;
baseParams.ExStyle |= ( int )(
Win32.ExtendedWindowStyles.WS_EX_NOACTIVATE |
Win32.ExtendedWindowStyles.WS_EX_TOOLWINDOW );
return baseParams;
}
}
这篇关于显示不偷焦点表格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!