Reputation:
I am creating some always-on-top toasts as forms and when I open them I'd like them not to take away focus from other forms as they open. How can I do this?
Thanks
Upvotes: 12
Views: 7933
Reputation: 161
It took me a few minutes using Adam's & Aaron's info above, but I finally got it to work for me. The one thing I had to do was make sure the form's Top Most property is set to false. Here is the code I used...
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;
}
}
Upvotes: 16
Reputation: 185583
protected override bool ShowWithoutActivation
{
get
{
return true;
}
}
Override this property in your form code and it should do the trick for you.
Upvotes: 17