soo*_*ise 18 c# topmost winforms
我有一个弹出用户屏幕的表单TopMost=true,但是它会窃取焦点.如何才能让它在第一次出现时没有窃取焦点?
Ren*_*Pet 14
这对我有用.它提供TopMost但没有焦点窃取.
protected override bool ShowWithoutActivation
{
get { return true; }
}
private const int WS_EX_TOPMOST = 0x00000008;
protected override CreateParams CreateParams
{
get
{
CreateParams createParams = base.CreateParams;
createParams.ExStyle |= WS_EX_TOPMOST;
return createParams;
}
}
Run Code Online (Sandbox Code Playgroud)
请记住在Visual Studio设计器或其他地方省略设置TopMost.
这是从这里偷来的,错误的,借来的(点击解决方法):
将此代码粘贴到您的表单中:
protected override bool ShowWithoutActivation
{
get { return true; }
}
Run Code Online (Sandbox Code Playgroud)