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.