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

  • Thread starter Thread starter Yuan Nan via OfficeKB.com
  • Start date 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.
 
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!
 
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
 
Back
Top