重新设置父级非模态形式存在的应用程序 [英] Reparent non-modal form to existing application

查看:105
本文介绍了重新设置父级非模态形式存在的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想能够显示一个非模态形式已经存在的应用程序。目前,我可以这样做:

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);



但将创建父应用程序模式窗体和我真正寻找的东西不是模态的,所以当窗体失去焦点也不会断裂控制的流量和对纠缠不关闭该用户。

but that will create a modal form parented to the application and what I'm really looking for something that isn't modal so when the form loses focus it won't break the flow of control and pester the user about not being closed.

有谁知道如果我可以做什么,我找?

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

推荐答案

我发现我一直在寻找,你必​​须做出一个类看起来像这样的:

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));

这篇关于重新设置父级非模态形式存在的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆