I have a sort of a pop-up windows form. It pops up to show gathered data. Problem is it gains focus when it loads and interrupts work. I need it not to get focus when loaded. How to do that?
Asked
Active
Viewed 1,502 times
0
-
@JeroenvanLangen from the looks of it, that should help me, but I cant figure it out. – Jonas Kazlauskas Jul 14 '16 at 09:21
2 Answers
0
the Simplest thing you can do is, first load all the data which you gathered and when u feel its ready and you want to load the popup window, call the window.show() this will help you to use the data once its loaded. Also it would be better if you can share more details on the same.

Hatim Nagarwala
- 110
- 8
-
I have a timer, on every tick I get data from an url, parse it, and if there is anything useful to show I use `this.Show();` but the form still get focus. Although I have set topmost on true, so this pop up would always get noticed. – Jonas Kazlauskas Jul 14 '16 at 08:08
-
Can you ad your code here for me to see how the events are triggering up? – Hatim Nagarwala Jul 14 '16 at 08:15
0
In Your form class, override OnLostFocus(EventArgs e) and place a focusing call inside it. So it looks like this:
protected override void OnLostFocus(EventArgs e)
{
base.OnLostFocus(e);
this.Focus();
}
Sometimes if that doesn't work try:
protected override void OnDeactivate(EventArgs e)
{
base.OnDeactivate(e);
this.Focus();
}

DV8DUG
- 247
- 2
- 9