Context Menu in Outlook 2007 Preview Pane

P

Paul

We are developing a Telephony Toolbar component as a Microsoft Outlook Addin.
Briefly it has dialing capabilities that then sends via a proprietary API to
a VoIP softswitch in the network.
A feature of this addin consists of getting the selected text from the
Preview Pane and dialling it using the context menu. We have successfully
implemented this feature in Outlook 2002 and 2003 but not in Outlook 2007
that uses Word(“_WwG†class) instead of Internet Explorer(“Internet
Explorer_Server†class) to display an email. So far, we have succeeded to get
the selected text from the Preview Pane using Microsoft Active Accessibility
but we do not know how to attach a menu item to the Preview Pane’s context
menu.
Outlook 2007 provides several context menu events but no one is suitable for
the Preview Pane. So we tried several approaches:
• Calling get_CommandBars method of the Word (embedded in Outlook)
Application object
CComPtr<MSWORD::_Application> spApplication;
//getting the application.
//...
// trying to get the command bars.
CComPtr<Office::_CommandBars> spCmdBars;
HRESULT hr = spApplication->get_CommandBars(&spCmdBars);
Returns the undocumented value 0x800a180e.
• Creating a Word addin.
The addin works fine when Word is not embedded but not when it is. It seems
that in the first case Word uses Normal.dotm template and NormalEmail.dotm in
the second.
• Using Microsoft UI Spy we found out the following hierarchy (Name, Class,
ControlType):
“â€,“NeT UI Tool Windowâ€,â€ControlType.Paneâ€
“â€,“NetUIHWND†â€,â€ControlType.Paneâ€
“â€,“â€â€,â€ControlType.Customâ€
“â€,Ҡâ€,â€ControlType.Menuâ€
“â€,“â€â€,â€ControlType.Customâ€
“Copyâ€,Ҡâ€,â€ControlType.MenuItemâ€

We can get the NetUIHWND window’s handle but we do not know how to inset a
new “menu itemâ€.
• Using Microsoft Spy++ we found out that a “Microsoft Word†OpusApp window
is created when Outlook is launched. We can get the handle of this window or
of any child window but do not know how to make use of it from this point.
The first time a context menu in Preview Pane is instantiated a “Textâ€
“MsoCommandBarPopup†window is created. We can get its handle too but do not
know about MsoCommandBarPopup class.

Thank You
 
K

Ken Slovak - [MVP - Outlook]

I believe that Application.ItemContextMenuDisplay is the event you're
looking for in Outlook 2007.

WordMail in Outlook 2007 is very different than WordMail in earlier
versions. Instead of subclassing an instance of msword.exe Outlook 2007 uses
a separate DLL for WordMail that's now owned by the Outlook team. In
general, other than getting text from WordEditor using Accessibility as
you're doing all other operations and hWnds related to the WordMail window
should use the Inspector hWnd and Inspector properties.
 
S

Sue Mosher [MVP-Outlook]

ItemContextMenuDisplay works for items right-clicked in the item list. A context menu event for right-clicking in the preview pane is one that is sorely lacking, along with the Word item body context menu . :(

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


Ken Slovak - said:
I believe that Application.ItemContextMenuDisplay is the event you're
looking for in Outlook 2007.

WordMail in Outlook 2007 is very different than WordMail in earlier
versions. Instead of subclassing an instance of msword.exe Outlook 2007 uses
a separate DLL for WordMail that's now owned by the Outlook team. In
general, other than getting text from WordEditor using Accessibility as
you're doing all other operations and hWnds related to the WordMail window
should use the Inspector hWnd and Inspector properties.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


Paul said:
We are developing a Telephony Toolbar component as a Microsoft Outlook
Addin.
Briefly it has dialing capabilities that then sends via a proprietary API
to
a VoIP softswitch in the network.
A feature of this addin consists of getting the selected text from the
Preview Pane and dialling it using the context menu. We have successfully
implemented this feature in Outlook 2002 and 2003 but not in Outlook 2007
that uses Word(“_WwG†class) instead of Internet Explorer(“Internet
Explorer_Server†class) to display an email. So far, we have succeeded to
get
the selected text from the Preview Pane using Microsoft Active
Accessibility
but we do not know how to attach a menu item to the Preview Pane’s context
menu.
Outlook 2007 provides several context menu events but no one is suitable
for
the Preview Pane. So we tried several approaches:
• Calling get_CommandBars method of the Word (embedded in Outlook)
Application object
CComPtr<MSWORD::_Application> spApplication;
//getting the application.
//...
// trying to get the command bars.
CComPtr<Office::_CommandBars> spCmdBars;
HRESULT hr = spApplication->get_CommandBars(&spCmdBars);
Returns the undocumented value 0x800a180e.
• Creating a Word addin.
The addin works fine when Word is not embedded but not when it is. It
seems
that in the first case Word uses Normal.dotm template and NormalEmail.dotm
in
the second.
• Using Microsoft UI Spy we found out the following hierarchy (Name,
Class,
ControlType):
“â€,“NeT UI Tool Windowâ€,â€ControlType.Paneâ€
“â€,“NetUIHWND†â€,â€ControlType.Paneâ€
“â€,“â€â€,â€ControlType.Customâ€
“â€,Ҡâ€,â€ControlType.Menuâ€
“â€,“â€â€,â€ControlType.Customâ€
“Copyâ€,Ҡâ€,â€ControlType.MenuItemâ€

We can get the NetUIHWND window’s handle but we do not know how to inset a
new “menu itemâ€.
• Using Microsoft Spy++ we found out that a “Microsoft Word†OpusApp
window
is created when Outlook is launched. We can get the handle of this window
or
of any child window but do not know how to make use of it from this point.
The first time a context menu in Preview Pane is instantiated a “Textâ€
“MsoCommandBarPopup†window is created. We can get its handle too but do
not
know about MsoCommandBarPopup class.

Thank You
 
P

Paul

I am looking for an event for right-clicking in the preview pane.
In Outlook 2002 & 2003 I used CommandBars.OnUpdate to insert a
CommandBarButton into the context menu which is a CommandBar object.

All context menus for Outlook 2007 events are still CommandBar objects, but
it appears that the context menu Preview Pane is no longer a CommandBar
object and its owner is the embedded Word window (_WwG class).

This is why I tried to retrieve the embedded Word CommandBars collection but
got an undocumented 0x800a180e HRESULT value.

If Outlook 2007 has no suitable event, and if my assumption that the context
menu’s owner is the embedded Word window is true, could you suggest any
feasible solution?

Is the dll for WordMail wwlib.dll? If so, should I try getting the Word
application using wdGetApplicationObject function again? I think I used an
incorrect function signature that did not succeed.

Thank You
 
K

Ken Slovak - [MVP - Outlook]

Just use ItemContextMenuDisplay. When you get the item it's not loaded in
WordMail since it's being read in the preview pane. I've had no problems
adding items to the context menu in that event handler. Just use the
CommandBar object passed to you and use the Selection collection passed to
you in that event handler. There's even sample code in the Help for that
event that shows how to use it.
 
S

Sue Mosher [MVP-Outlook]

I think what Paul is looking for is the context menu that appears when the user right-clicks on the preview pane itself, i.e. the one with the View Source command. That is not exposed in the Outlook 2007 object model. And since the context menu isn't exposed in Inspector.WordEditor editor either (for reasons that have yet to be explained -- arggh), I think the only avenue is to explore low-level Windows API techniques (which are way over my head).

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
 
H

himani

Paul wrote on 06/14/2007 01:15 ET
We are developing a Telephony Toolbar component as a Microsoft Outlook Addin
Briefly it has dialing capabilities that then sends via a proprietary API t
a VoIP softswitch in the network
A feature of this addin consists of getting the selected text from th
Preview Pane and dialling it using the context menu. We have successfull
implemented this feature in Outlook 2002 and 2003 but not in Outlook 200
that uses Word(&ldquo;_WwG&rdquo; class) instead of Interne
Explorer(&ldquo;Interne
Explorer_Server&rdquo; class) to display an email. So far, we have succeede t
ge
the selected text from the Preview Pane using Microsoft Active Accessibilit
but we do not know how to attach a menu item to the Preview Pane&rsquo;
contex
menu
Outlook 2007 provides several context menu events but no one is suitable fo
the Preview Pane. So we tried several approaches
&bull; Calling get_CommandBars method of the Word (embedded in Outlook
Application objec
CComPtr&lt;MSWORD::_Application&gt; spApplication
//getting the application
//..
// trying to get the command bars
CComPtr&lt;Office::_CommandBars&gt; spCmdBars
HRESULT hr = spApplication-&gt;get_CommandBars(&amp;spCmdBars)
Returns the undocumented value 0x800a180e
&bull; Creating a Word addin
The addin works fine when Word is not embedded but not when it is. It seem
that in the first case Word uses Normal.dotm template and NormalEmail.dotm i
the second
&bull; Using Microsoft UI Spy we found out the following hierarchy (Name
Class
ControlType)
&ldquo;&rdquo;,&ldquo;NeT UI Too Window&rdquo;,&rdquo;ControlType.Pane&rdquo
&ldquo;&rdquo;,&ldquo;NetUIHWND&rdquo; &rdquo;,&rdquo;ControlType.Pane&rdquo
&ldquo;&rdquo;,&ldquo;&rdquo;&rdquo;,&rdquo;ControlType.Custom&rdquo
&ldquo;&rdquo;,&ldquo;&rdquo; &rdquo;,&rdquo;ControlType.Menu&rdquo
&ldquo;&rdquo;,&ldquo;&rdquo;&rdquo;,&rdquo;ControlType.Custom&rdquo
&ldquo;Copy&rdquo;,&ldquo;&rdquo; &rdquo;,&rdquo;ControlType.MenuItem&rdquo

We can get the NetUIHWND window&rsquo;s handle but we do not know how t inse

new &ldquo;menu item&rdquo;
&bull; Using Microsoft Spy++ we found out that a &ldquo;Microsoft Word&rdquo
OpusApp windo
is created when Outlook is launched. We can get the handle of this window o
of any child window but do not know how to make use of it from this point
The first time a context menu in Preview Pane is instantiated
&ldquo;Text&rdquo
&ldquo;MsoCommandBarPopup&rdquo; window is created. We can get its handle to
but do no
know about MsoCommandBarPopup class

Thank Yo
Pau
Hi
I have a similar requirement to add menu item to context menu on right
clicking on Reading Pane of an email in Outlook 2010. I can do that fo
&quot;New Mail&quot; or on &quot;Reply&quot;, &quot;Reply All&quot; &amp
&quot;Forward&quot; of existing mail by adding context men
&quot;ContextMenuText&quot; to ribbon.xml

But not for existing mail (without clicking &quot;Reply&quot;, &quot;Repl
All&quot; &amp; &quot;Forward&quot; ). Is there any solution?
 

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