将FolderBrowserDialog 设置为前台
我正在创建一个基本的 MSI installshield 安装程序。为了选择安装路径,我调用了FolderBrowserDialog。除了在后台显示FolderBrowserDialog 之外,一切正常。我想将其设置为前景窗口。如果没有其他窗口打开,此代码始终返回 true 并且工作正常。
如何检查dialogHandle是否是我的对话框句柄?
这是我的方法:
/// <param name="fPath">INSTALLPATH</param>
/// <param name="handle">installshield handle</param>
/// <returns></returns>
public string NetworkFolderDialog(string sFilePath, IntPtr handle)
{
FolderBrowserDialog dialog = new FolderBrowserDialog();
IntPtr handle2 = GetDesktopWindow();
IntPtr dialogHandle = GetWindow(handle2, 5);
bool set = SetForegroundWindow(dialogHandle);
DialogResult result = dialog.ShowDialog();
MessageBox.Show(set.ToString());
if (result == DialogResult.OK)
return dialog.SelectedPath;
else
return sFilePath;
}
谢谢您的帮助。
I'm creating an Basic MSI installshield installer. And for choosing instllation path i'm calling FolderBrowserDialog. Everything works OK except FolderBrowserDialog appers in background. I would like to set it to be a foreground window. This code always returns true and works fine if there is no other window open.
How can I check if dialogHandle is my dialog handle?
Here is my method:
/// <param name="fPath">INSTALLPATH</param>
/// <param name="handle">installshield handle</param>
/// <returns></returns>
public string NetworkFolderDialog(string sFilePath, IntPtr handle)
{
FolderBrowserDialog dialog = new FolderBrowserDialog();
IntPtr handle2 = GetDesktopWindow();
IntPtr dialogHandle = GetWindow(handle2, 5);
bool set = SetForegroundWindow(dialogHandle);
DialogResult result = dialog.ShowDialog();
MessageBox.Show(set.ToString());
if (result == DialogResult.OK)
return dialog.SelectedPath;
else
return sFilePath;
}
Thank you for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为您应该从代码中删除以下行:
I think you should remove the following lines from your code:
这里有一个关于此的讨论: .Net 中的自定义安装程序显示后面的表单安装程序
There is a discussion about this here: Custom Installer in .Net showing Form behind installer