Outlook add-in open dialogs

Status
Not open for further replies.
J

J E Jensen

Hello NG

On a property page that i have added to the outlook options form, i have a

button. And when the user clicks that button i want the FolderBrowserDialog

to open.

My code:

using (FolderBrowserDialog fbd = new FolderBrowserDialog())

{

fbd.Description = "Select folder";

fbd.SelectedPath = DefaultFolder;

if (fbd.ShowDialog() == DialogResult.OK)

strReturn = fbd.SelectedPath;

}

It do not shows on the screen, if i pause the code it stops at the

If(fbd.ShowDialog() == DialogResult.OK) line. I think that Outlook can't

open a modal dialog from the property pages.

Is there another way to do that.

Kind regards

Johnny Jensen
 
Sure you can open a modal dialog on top of a property page, I do it all the

time.

You just need to pass along the window handle of the window you want the

dialog to be on top of as the owner of your dialog. Get the hWnd of your

property page and pass that as the hWnd of the owner of the dialog.

You can also set the TopMost property of your dialog.

"J E Jensen" <jej@winnercrm.dk> wrote in message

news:%23w7N2ScwKHA.2436@TK2MSFTNGP04.phx.gbl...
> Hello NG

> On a property page that i have added to the outlook options form, i have a
> button. And when the user clicks that button i want the
> FolderBrowserDialog to open.

> My code:
> using (FolderBrowserDialog fbd = new FolderBrowserDialog())

> {

> fbd.Description = "Select folder";

> fbd.SelectedPath = DefaultFolder;

> if (fbd.ShowDialog() == DialogResult.OK)

> strReturn = fbd.SelectedPath;

> }

> It do not shows on the screen, if i pause the code it stops at the
> If(fbd.ShowDialog() == DialogResult.OK) line. I think that Outlook can't
> open a modal dialog from the property pages.

> Is there another way to do that.

> Kind regards
> Johnny Jensen

>
 
Hello Ken

Thanks for helping.

The dialog i want to display i the System.Windows.Forms.FolderBrowserDialog

this dialog allow me to pass a IWin32Window as the owner, so I stubbled over

a snipet to help me.

The wrapper:

public class WindowWrapper : System.Windows.Forms.IWin32Window

{

public WindowWrapper(IntPtr handle)

{

_Handle = handle;

}

private IntPtr _Handle;

public IntPtr Handle

{

get { return _Handle; }

}

}

I'll get the Outlook's handle by:

System.Diagnostics.Process[] proc =

System.Diagnostics.Process.GetProcessesByName("OUTLOOK");

if (proc.Length > 0)

{

IntPtr hwnd = proc[0].MainWindowHandle;

}

The create a new instance of the WindowWrapper with the hwnd in the

construstor.

Then i use the FolderBrowserDialog.ShowDialog(new WindowWrapper(hwnd))

but the dialog never shows.

Kind regards

Johnny Jensen
<kenslovak@mvps.org> wrote in message

news:OWycoLfwKHA.3564@TK2MSFTNGP05.phx.gbl...
> Sure you can open a modal dialog on top of a property page, I do it all
> the time.

> You just need to pass along the window handle of the window you want the
> dialog to be on top of as the owner of your dialog. Get the hWnd of your
> property page and pass that as the hWnd of the owner of the dialog.

> You can also set the TopMost property of your dialog.

> >

>

> "J E Jensen" <jej@winnercrm.dk> wrote in message
> news:%23w7N2ScwKHA.2436@TK2MSFTNGP04.phx.gbl...
> > Hello NG
>

>> On a property page that i have added to the outlook options form, i have
> > a button. And when the user clicks that button i want the
> > FolderBrowserDialog to open.
>

>> My code:
> > using (FolderBrowserDialog fbd = new FolderBrowserDialog())
>

>> {
>

>> fbd.Description = "Select folder";
>

>> fbd.SelectedPath = DefaultFolder;
>

>> if (fbd.ShowDialog() == DialogResult.OK)
>

>> strReturn = fbd.SelectedPath;
>

>> }
>

>> It do not shows on the screen, if i pause the code it stops at the
> > If(fbd.ShowDialog() == DialogResult.OK) line. I think that Outlook can't
> > open a modal dialog from the property pages.
>

>> Is there another way to do that.
>

>> Kind regards
> > Johnny Jensen
>

>
>>

>
 
My guess is that will place your dialog behind the property page but in

front of the main Outlook window, in other words invisible. I'd use the hWnd

for the property page form or usercontrol you are using rather than the hWnd

of the main Outlook window.

"J E Jensen" <jej@winnercrm.dk> wrote in message

news:eIR$nJ6wKHA.5036@TK2MSFTNGP02.phx.gbl...
> Hello Ken

> Thanks for helping.
> The dialog i want to display i the
> System.Windows.Forms.FolderBrowserDialog this dialog allow me to pass a
> IWin32Window as the owner, so I stubbled over a snipet to help me.

> The wrapper:
> public class WindowWrapper : System.Windows.Forms.IWin32Window

> {

> public WindowWrapper(IntPtr handle)

> {

> _Handle = handle;

> }

> private IntPtr _Handle;

> public IntPtr Handle

> {

> get { return _Handle; }

> }

> }

> I'll get the Outlook's handle by:
> System.Diagnostics.Process[] proc =
> System.Diagnostics.Process.GetProcessesByName("OUTLOOK");

> if (proc.Length > 0)

> {

> IntPtr hwnd = proc[0].MainWindowHandle;

> }

> The create a new instance of the WindowWrapper with the hwnd in the
> construstor.

> Then i use the FolderBrowserDialog.ShowDialog(new WindowWrapper(hwnd))
> but the dialog never shows.

> Kind regards
> Johnny Jensen
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
B Add-in "always enabled" but Outlook 13 won't open Using Outlook 7
G Add Map It button to Custom Contacts Form in Outlook Outlook VBA and Custom Forms 1
P Can't add custom field to custom Outlook form, it always adds to the Folder instead Outlook VBA and Custom Forms 2
P VBA to add email address to Outlook 365 rule Outlook VBA and Custom Forms 0
S Outlook 2019 Custom outlook Add-in using Visual Studio Outlook VBA and Custom Forms 0
F Want to add second email to Outlook for business use Using Outlook 4
M "Attachment Detacher for Outlook" add in, does it update the server copy of the email? Using Outlook 1
J GoDaddy migrated to Office365 - Outlook Wont Add Account Exchange Server Administration 21
F Outlook 2019 Outlook 2019 Add and Sync to New computer Comcast server Using Outlook 2
A iCloud Outlook Add In is causing Outlook 2021 to crash and got disabled Using Outlook 10
L did MS ever add way to text via Outlook Using Outlook 5
P How to add a column named categories when searching in Outlook Using Outlook 0
N Can't create NEW GROUP and add/remove a member from existing Group in Outlook Using Outlook 1
Witzker Outlook 2019 Pls. add a Prefix for OUTLOOK 2019 here Using Outlook 1
A "Get Add-Ins" - Which Version of Outlook to use Using Outlook 1
C Looking for feedback on new Outlook Add-in Using Outlook 0
G How to add a folder shortcut to outlook quick access toolbar? Using Outlook 6
G Add to Outlook Contacts - Point to non-default contacts folder Using Outlook 0
O Outlook tasks - Add text column with multiple lines Using Outlook 3
D Add date next to day name in Outlook Today calendar view Using Outlook 1
D iCloud Add-in not working in Outlook 2013 and Outlook 2016 After Windows Upgrade & iCloud Upgrade Using Outlook 2
L Tired of Outlook disabling Adobe PDF Creator add-in Using Outlook 1
Mark Foley Cannot enable add-in in outlook 2010 Using Outlook 0
iwshim outlook 2013 - I cannot see the "Manage Add-ins" Using Outlook 2
A Add to Outlook Contacts from email - default view Outlook VBA and Custom Forms 1
P Add a contact to the New Task in Outlook 2016 Using Outlook 2
O Outlook on Android - add BCC Using Outlook 2
J Execute Add-In Button from VBA Outlook 2016 Outlook VBA and Custom Forms 1
J vb to c# for Outlook add-in. Using Outlook 0
R Outlook add-in to create new contact from an email. Using Outlook 0
A add birthday to outlook contacts Using Outlook 1
Tanja Östrand Outlook 2016 - Create Macro button to add text in Subject Outlook VBA and Custom Forms 1
C Need VBA code to automatically save message outside outlook and add date Outlook VBA and Custom Forms 1
R Add Exchange Account to existing POP3 Outlook 2007 Profile Using Outlook 0
O Outlook 2016 follow-up flags--how can I add dates? Using Outlook 1
J VB6 Add-in fails to load in Outlook 16 - message useless Outlook VBA and Custom Forms 4
Diane Poremsky Disable Outlook Add-ins (Apps) Using Outlook 0
Diane Poremsky The Best Outlook Store Add-ins Contest Using Outlook 0
Diane Poremsky Add to Outlook Contacts Bug (Fixed) Using Outlook 1
Diane Poremsky Add a Charm to Outlook Meetings Using Outlook 0
N Get the seconds with userproperties.add method VBA Outlook Outlook VBA and Custom Forms 4
D Outlook Add-on for Exchange Spam Management? Exchange Server Administration 2
O Add private notes or comments to Outlook meeting invite Using Outlook 4
J Outlook calendar...How to add an event or appointment without a border around it? Using Outlook 9
iwshim Can I add an Unsubscribe link to Outlook outgoing email? Something like this? Using Outlook 1
Mark Klaassen HOw to keep Outlook iCloud add-in enabled Using Outlook 4
Tech Checkers Make Outlook add Contact Card Address in Location Field based on Appointment Subject Name. Using Outlook 2
B No email accounts in outlook. Cannot add email Using Outlook 5
A iCloud add-on for Outlook: Reminder for new appointment is set to 'None' by default. How to change? Using Outlook 6
T Cannot successfully add gmail IMAP account to Outlook 2013. Using Outlook 1

Similar threads

Back
Top