Reparent non-modal form to existing application

前端 未结 2 607
隐瞒了意图╮
隐瞒了意图╮ 2021-01-06 06:26

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

myform.ShowDialog(handleToApp);
         


        
相关标签:
2条回答
  • 2021-01-06 06:45

    I found what I was looking for, you have to make a class which 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));
    
    0 讨论(0)
  • 2021-01-06 07:03

    How about a simple myForm.Show()?

    0 讨论(0)
提交回复
热议问题