大家好。
[DllImport("user32.dll")]
public static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
public void DockAllNote(System.Windows.Forms.Panel panel)
{
Process[] MultiClients = Process.GetProcessesByName("notepad");
foreach (Process Client in MultiClients)
{
hWndOriginalParent = Client.MainWindowHandle;
SetParent(Client.MainWindowHandle, panel.Handle);
panel.Refresh();
}
}`enter code here`
在代码之上工作。我想打开记事本窗口。
public void UndockNoteAll(System.Windows.Forms.Panel panel)
{
Process[] MultiClients = Process.GetProcessesByName("notepad");
foreach (Process Client in MultiClients)
{
SetParent(Client.MainWindowHandle, IntPtr.Zero);
panel.Refresh();
}
}
我尝试了这个undock代码,但undock不起作用。记事本仍留在面板上。如何打开窗口?一年前尝试使用IntPtr.Zero解除对接。我不记得代码是什么了。
抱歉英语不好感谢
已解决。
IntPtr DockedHandle = IntPtr.Zero;
IntPtr OrjinalHandle = IntPtr.Zero;
//Dock
OrjinalHandle = process.MainWindowHandle
DockedHandle = SetParent(process.MainWindowHandle, panel.Handle);
//Undock
SetParent(OrjinalHandle, DockedHandle);