|
Patrick Jox
Guest
|
Hello,
I need to popup the FolderBrowseDialog to sel ect an directory fr om my property page. This is done using the following code:
private void SelectApplicationDirectory()
{
FolderBrowserDialog fbd = new FolderBrowserDialog();
OpenFileDialog ofd = new OpenFileDialog();
try
{
// this is only for testing.
ofd.ShowDialog();
fbd.SelectedPath = this.ApplicationDirectoryTextBox.Text;
fbd.ShowNewFolderButton = true;
if (fbd.ShowDialog() == DialogResult.Cancel)
return;
this.ApplicationDirectoryTextBox.Text = fbd.SelectedPath;
}
catch (System.Exception ex)
{
throw ex;
}
}
The line fbd.ShowDialog() causes the application to hang. I tried the OpenFileDialog a few lines above. This works fine. Maybe the Dialog is poped up but not visible?
Since I am using Windows 7 I thought this might be an debug isssue of running Visual Studio as admin while Outlook runs in my normal user context. But starting the outlook the normal way i see the same effect.
Any ideas?
Kind regards
Patrick |
|
Posted 17 Jan, 2010 08:31:47
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 18816
Joined: 2006-05-11
|
Hi Patrick,
You need to use the ShowDialog(IWin32Window) overload. Use the GetOutlookWindowHandle of the add-in module to get the hwnd required for implementing IWin32Window.
Andrei Smolin
Add-in Express Team Leader |
|
Posted 18 Jan, 2010 08:03:52
|
|
Top
|
|
Patrick Jox
Guest
|
Hey Andrei,
thanks a lot. One little question is remaining.
The GetOutlookWindowHandle expects a window. Which would be this window? I think the propertydialog but how can I reach this?
Kind regards
Patrick |
|
Posted 18 Jan, 2010 09:34:23
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 18816
Joined: 2006-05-11
|
Hi Patrick,
Pass the active Explorer to that method and release it after that call.
Andrei Smolin
Add-in Express Team Leader |
|
Posted 18 Jan, 2010 09:54:12
|
|
Top
|
|
Patrick Jox
Guest
|
OK got it.
public class WindowWrapper : System.Windows.Forms.IWin32Window
{
public WindowWrapper(IntPtr handle)
{
_hwnd = handle;
}
public IntPtr Handle
{
get { return _hwnd; }
}
private IntPtr _hwnd;
}
Outlook._Application olApp = ((AddinModule)AddinModule.CurrentInstance).OutlookApp as Outlook._Application;
System.IntPtr hWnd = AddinModule.CurrentInstance.GetOutlookWindowHandle(olApp.ActiveWindow());
WindowWrapper w = new WindowWrapper(hWnd);
if (fbd.ShowDialog(w) == DialogResult.Cancel)
return;
Still has the same effect. Do I need the PropertyDialogs handle and how can I get it?
Kind regards.
Patrick |
|
Posted 18 Jan, 2010 09:56:05
|
|
Top
|
|
Patrick Jox
Guest
|
hmmm,
Tried out the following
Outlook._Application olApp = ((AddinModule)AddinModule.CurrentInstance).OutlookApp as Outlook._Application;
System.IntPtr hWnd = AddinModule.CurrentInstance.GetOutlookWindowHandle(olApp.ActiveExplorer());
WindowWrapper w = new WindowWrapper(hWnd);
if (fbd.ShowDialog(w) == DialogResult.Cancel)
return;
Still the same effect.
Kind regards
Patrick |
|
Posted 18 Jan, 2010 09:59:16
|
|
Top
|
|
Patrick Jox
Guest
|
So I tried to create a new System.Windows.Forms.Form, create it and show it.
This has just the same effect with the one difference, that I can see the new form.
The new form pops up.
The forms workspace, respectivly the controls inside the form are not drawn.
The form remains visible and after a while the property dialogs caption changes to "not responding".
After clicking in the ne forms area this forms caption too changes to "not responding".
Any ideas?
Kind regards
Patrick |
|
Posted 18 Jan, 2010 11:48:22
|
|
Top
|
|
Patrick Jox
Guest
|
OK I got it to work. The problem was, that the buttons through which I opened the forms have been on TabControl / TabPage.
After placing the button directly in the property page everything works.
Kind regards
Patrick |
|
Posted 18 Jan, 2010 12:51:53
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 18816
Joined: 2006-05-11
|
Hi Patrick,
Thank you for letting me know.
Andrei Smolin
Add-in Express Team Leader |
|
Posted 18 Jan, 2010 12:55:38
|
|
Top
|
|