积极答复者
c#附加窗体

问题
答案
-
也许你要说的是把b窗体放到a窗体中,然后再把c窗体放到b窗体中,形成类似于父子孙窗体a->b->c, 对吗?
那么SetParent函数可以满足你的需求。
你可以读一下我的这两篇相关case:
http://social.msdn.microsoft.com/Forums/en/winforms/thread/5ea93903-e9ac-4f5e-8383-be167a74120f
http://social.msdn.microsoft.com/Forums/en/csharpgeneral/thread/159b9898-4610-41bc-8d03-f3f2130176ad
核心代码如下:
[DllImport("user32.dll", SetLastError = true)] static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent); public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Process p = new Process(); p.StartInfo.FileName = "Notepad.exe"; p.Start(); Thread.Sleep(50); SetParent(p.MainWindowHandle, this.Handle); }
Mike [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- 已标记为答案 Mike Dos ZhangModerator 2011年9月8日 4:56
全部回复
-
窗体A,b,c
将b附加到a,然后将c附加到b,可行么?
请具体说明——什么是“附加”?如果你的“附加”是“把窗体设为父窗体”,然后把另外一个窗体作为其子窗体的话,那么是不可行的。因为同时只能有一个父窗体存在。
如果你有其它意见或私下交流,请直接发送maledong_work@foxmail.com;或者
If you do not have QQ, please open the page and download it and click the image to talk or leave message for me.
下载MSDN桌面工具(Vista,Win7)
下载Technet桌面小工具(Vista,Win7)
慈善点击,点击此处 -
也许你要说的是把b窗体放到a窗体中,然后再把c窗体放到b窗体中,形成类似于父子孙窗体a->b->c, 对吗?
那么SetParent函数可以满足你的需求。
你可以读一下我的这两篇相关case:
http://social.msdn.microsoft.com/Forums/en/winforms/thread/5ea93903-e9ac-4f5e-8383-be167a74120f
http://social.msdn.microsoft.com/Forums/en/csharpgeneral/thread/159b9898-4610-41bc-8d03-f3f2130176ad
核心代码如下:
[DllImport("user32.dll", SetLastError = true)] static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent); public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Process p = new Process(); p.StartInfo.FileName = "Notepad.exe"; p.Start(); Thread.Sleep(50); SetParent(p.MainWindowHandle, this.Handle); }
Mike [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- 已标记为答案 Mike Dos ZhangModerator 2011年9月8日 4:56