我有一个 CustomInstaller 类 (System.Configuration.Install.Installer),基本上我在 Install 方法中打开一个对话框表单。 我想知道是否有可能以某种方式说该表单的“父”属性将是设置过程窗口?
我该怎么做?
最佳答案
您需要获取安装程序窗口的句柄。不太确定如何获得它,但 Process.GetCurrentProcess().MainWindowHandle 应该会给你很大的机会。然后创建一个 NativeWindow 来包装句柄,以便您可以将其用作所有者。像这样:
IntPtr hdl = Process.GetCurrentProcess().MainWindowHandle;
var window = new NativeWindow();
window.AssignHandle(hdl);
try {
using (var dlg = new YourForm()) {
var result = dlg.ShowDialog(window);
//...
}
}
finally {
window.ReleaseHandle();
}
关于c# - 在 CustomActions 类中设置项目窗口处理程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3246866/