"Release" 来自我的面板的进程 (MainWindowHandle)
"Release" a process from my Panel (MainWindowHandle)
我运行此代码设置进程的父window:
SetParent(masterP.MainWindowHandle, panel1.Handle);
当我关闭我的应用程序时,我想将 masterP 进程的 MainWindowHandle 更改为操作系统。换句话说,我想 "release" 恢复正常 "state"。
所以基本上我的问题是,我需要使用什么代码才能做到这一点? :)
提前致谢
我想你正在使用 winforms 和 WinApi:
SetParent(masterP.MainWindowHandle, IntPtr.Zero);
Mainwindow句柄显示为“0”,因为在使用 SetParent 时 window 撕裂。在使用SetParent操作之前,需要使用如下代码:
private IntPtr backupMainWindowHandle = IntPtr.Zero;
private void Button1_Click(object sender, EventArgs e)
{
Process notepad = Process.GetProcessesByName("notepad")[0];
backupMainWindowHandle = notepad.MainWindowHandle;
SetParent(notepad.MainWindowHandle, SetToHandle); //Dock
}
发布代码如下:
private void Button2_Click(object sender, EventArgs e)
{
SetParent(backupMainWindowHandle, IntPtr.Zero); //Undock
}
我运行此代码设置进程的父window:
SetParent(masterP.MainWindowHandle, panel1.Handle);
当我关闭我的应用程序时,我想将 masterP 进程的 MainWindowHandle 更改为操作系统。换句话说,我想 "release" 恢复正常 "state"。
所以基本上我的问题是,我需要使用什么代码才能做到这一点? :)
提前致谢
我想你正在使用 winforms 和 WinApi:
SetParent(masterP.MainWindowHandle, IntPtr.Zero);
Mainwindow句柄显示为“0”,因为在使用 SetParent 时 window 撕裂。在使用SetParent操作之前,需要使用如下代码:
private IntPtr backupMainWindowHandle = IntPtr.Zero;
private void Button1_Click(object sender, EventArgs e)
{
Process notepad = Process.GetProcessesByName("notepad")[0];
backupMainWindowHandle = notepad.MainWindowHandle;
SetParent(notepad.MainWindowHandle, SetToHandle); //Dock
}
发布代码如下:
private void Button2_Click(object sender, EventArgs e)
{
SetParent(backupMainWindowHandle, IntPtr.Zero); //Undock
}