I am doing the same thing that this => Show a Form without stealing focus?
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 my software and computer. Is there a way to show this "notification" form without stealing focus?
I have tried all solution but when my form is open i loose the focus in all my computer :
My Notification Class :
/// <summary>
/// Class to sent Notification like Skype/Outlook
/// </summary>
public partial class Notification : Form
{
private static readonly List<Notification> OpenNotifications = new List<Notification>();
private readonly FormAnimator _animator;
public Notification(...)
{
InitializeComponent();
//Other...
}
public void Notification_Shown(object sender, EventArgs e)
{
// Close the form by sliding down.
_animator.Duration = 0;
_animator.Direction = FormAnimator.AnimationDirection.Down;
}
protected override bool ShowWithoutActivation
{
get { return true; }
}
protected override CreateParams CreateParams
{
get
{
CreateParams baseParams = base.CreateParams;
const int WS_EX_NOACTIVATE = 0x08000000;
const int WS_EX_TOOLWINDOW = 0x00000080;
baseParams.ExStyle |= ( int )( WS_EX_NOACTIVATE | WS_EX_TOOLWINDOW );
return baseParams;
}
}
//Other Functions
}
}
My InitializeComponent() of Notification From (TopMost is false) :
private void InitializeComponent()
{
//OTHER
this.lifeTimer.Tick += new System.EventHandler(this.lifeTimer_Tick);
this.Controls.Add(this.labelTitle);
this.Controls.Add(this.labelBody);
this.TopMost = false;
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.Notification_FormClosed);
this.Load += new System.EventHandler(this.Notification_Load);
this.Shown += new System.EventHandler(this.Notification_Shown);
this.Click += new System.EventHandler(this.Notification_Click);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);
}
My Notification form is open using Show :
Notification toastNotification = new Notification(...);
toastNotification.Show();
I know it's a duplicate but i really need your help , thank you :)
User contributions licensed under CC BY-SA 3.0