Outlook 2003 Add-in - WPF Window - ShortCut keys referring to Outl

R

R. Amirdha Gopal.

The Outlook 2003 addin (using VSTO) launches a WPF window. The window has a
toolbar with menus, for which shortcut keys are assigned.

The problem is that the shortcut keys are intercepted by the outlook and not
by the WPF Window.

Example: Alt+f invokes file menu on outlook, instead of file menu in WPF
window.

There are some links pointing to Addin Express. Is there a way to get the
work done in VSTO AddIn itself.

Thanks for your kind help in advance.
 
K

Ken Slovak - [MVP - Outlook]

Are you actually using AddIn Express?

Keyboard input should be directed to whatever window has the focus. Do other
keystrokes go to your WPF window or to another window?
 
R

R. Amirdha Gopal.

//Code Snippet for Outlook Shortcut Key Issue.
using System;
using System.Reflection;
using System.Windows.Interop;
using Microsoft.Office.Core;
using Microsoft.Office.Interop.Outlook;
using WpfApplication1;


namespace OutlookShortcutKeySpike
{
public partial class ThisAddIn
{
private Explorer explorer;
private CommandBar commandBar;
private CommandBarButton wpfButton;
private WpfWindow1 wpfWindow1;


private void ThisAddIn_Startup(object sender, EventArgs e)
{
AddCommandBar();
}

private void AddCommandBar()
{
explorer = Application.ActiveExplorer();
commandBar = explorer.CommandBars.Add("KeyBoardSpike",
MsoBarPosition.msoBarTop, false, true);
commandBar.Visible = true;
wpfButton =
commandBar.Controls.Add(MsoControlType.msoControlButton, Missing.Value,
Missing.Value, Missing.Value, true) as CommandBarButton;
wpfButton.Caption = "Wpf";
wpfButton.Visible = true;
wpfButton.Click += WpfButtonOnClick;

}

private void WpfButtonOnClick(CommandBarButton button, ref bool
@default)
{
wpfWindow1 = new WpfWindow1();
wpfWindow1.Show();
wpfWindow1.Activate();
}
}
}

The Window1 has Menubar with MenuItems having shortcut, which is not getting
focus when used.

The above code snippet is written using Outlook 2003 Add-in Project in VS2008.

Please suggest, whether the above approach is valid or anything else needs
to b e done. Any help on this is highly appreciated. Thanks.
 
R

R. Amirdha Gopal.

Thanks for your reply Ken.
Are you actually using AddIn Express?
No, We are not using AddIn Express.
Keyboard input should be directed to whatever window has the focus. Do other
keystrokes go to your WPF window or to another window?
I kept a textbox in the WPF Window, which is working fine. (getting the
keystrokes and showing the text in the text box.) However, the shortcuts are
always going to the Outlook window.

I have also posted the code snippet in other post.

Thanks again for your kind interest.
 
K

Ken Slovak - [MVP - Outlook]

I don't know. If the shortcuts are being handled by the window and it has
focus I see no reason why Outlook would intercept those keystrokes. I use
menu shortcuts in some windows in addins and haven't seen that problem.
 
R

R. Amirdha Gopal.

It works fine with normal winforms. However, the issue is with the WPF
window. Have u used WPF Window as a add-in form in Outlook?

Thanks for your reply.
 
K

Ken Slovak - [MVP - Outlook]

No, I've never used a WPF form like that, only WinForms. Perhaps it's some
incompatibility in WPF forms.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top