Fallback modeless form of an existing application

I would like to be able to show a non-modal form in an existing application. At the moment, I can do something like:

myform.ShowDialog(handleToApp); 

but this will create a modal form that was born for the application, and that I'm really looking for something that is not modal, so when the form loses focus, it will not disrupt the control flow and does not pester the user that it is not closed.

Does anyone know how or can I do what I'm looking for?

+4
source share
2 answers

I found what I was looking for, you need to create a class that looks like this:

 public class MapinfoWindowHandle : System.Windows.Forms.IWin32Window { private IntPtr handle; public MapinfoWindowHandle(IntPtr hWnd) { handle = hWnd; } #region IWin32Window Members IntPtr System.Windows.Forms.IWin32Window.Handle { get { return handle; } } #endregion } 

and then you can do this:

 IntPtr windowhandle = new IntPtr(hWnd); MyForm.Show(new MapinfoWindowHandle(windowhandle)); 
+2
source

How about a simple myForm.Show() ?

-1
source

All Articles