How to insert menu items to pop-up context menu in inspectors?

  • Thread starter Yuan Nan via OfficeKB.com
  • Start date
Y

Yuan Nan via OfficeKB.com

Hi,
I followed several aticles's instruction and complete this function in
main form in Outlook 2003.
But I met problem when I want to do the same work in mail item
inspector, since the context menu seems dynamically created and destructed,
not belongs to CommandBars object, just like its name: "Temporary Context
Menu"(get from spy++).
When the mouse hover/click on the mail address of sender/recipients in
mail inspector, A MSN-style icon appears and click it, the context menu
poped up is just the menu I want to insert items to.
I'm very thankful to your kind help.
 
Y

Yuan Nan via OfficeKB.com

I use WINAPI FindWindow to get the Menu's HWND successfully. And also use
WINAPI InsertMenuItem to insert the item in it. Like this:

Dim hwnd As Long
Dim ItemInfo As MENUITEMINFO
Dim ID As Long
On Error Resume Next
hwnd = FindWindow("MsoCommandBarPopup", "Temporary context menu")
If hwnd = 0 Then Exit Sub
ID = 1
With ItemInfo
.cbSize = LenB(ItemInfo)
.fMask = .....
.fType = &H0
.fState = &H0
.wID = ID
.dwItemData = True
.cch = Len("test")
.dwTypeData = "test"
End With
i = InsertMenuItem(hwnd, ID, False, ItemInfo)

But the code does not function. Is the hwnd returned by FindWindow
equal to the hMenu (1st Param. of InsertMenuItem)?
Variable i always return FAIL but GetLastError return NO-ERROR!
 
D

Dmitry Streblechenko

Outlook and Office menus are *not* the regular Windows menus, they are
custom controls.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 

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