Show WinForms window out of focus

I create and show a new WinForms window on top of the main window. How can I achieve that the original (main window) retains focus? Setting the focus back after showing a new window does not solve my problem because I need to prevent the title bar of the main window from flickering. The new window should remain on top of the main window, so I need to set topMost = true. However, this does not make any difference to the problem I am thinking about.

Thanks!

+4
source share
2 answers

If you are trying to achieve something similar to the β€œsuper” tooltips in Office 2007, you might be better off with a third-party library that already does this. Another option would probably be to create a window in the form of a NativeWindow and use interacting calls to interact with it.

0
source

Setting focus after showing a new form works great. My taskbar does not flicker.

private void button1_Click(object sender, EventArgs e) { Form2 f2 = new Form2(); f2.TopMost = true; f2.Show(); this.Focus(); } 

May I ask why you want to set the focus to the main shape, because by default the new shape will be drawn on top of the main window and you will need to close or move the new shape to view the main shape of the window.

+3
source

All Articles