Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / Extensibility / March 2005

Tip: Looking for answers? Try searching our database.

How to Handle Menu event?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ahmad Jalil Qarshi - 17 Mar 2005 15:54 GMT
hi!

I have Added a new CommandBarControl of type msoControlButton in the Menu
"Inline Picture" (which is displayed when you right click on some picture or
some OleObject in MS Word Document). I have also run some VBA macros on
click event at this new inserted menu Item by specifying them into
PutOnAction function. But now i want to call some functions of my ActiveX
control's class on click event at this new inserted menu. Is it possible if
so then please help me. i am using ATL in VC6

Thanks

Ahmad Jalil Qarshi
Fuzzier - 27 Mar 2005 04:20 GMT
Your class must implement IDTCommandTarget interface (typelib: Program
File\Common Files\Microsoft Shared\MSEnv\dte.olb).
Exec() and QueryStatus() will pass in 'cmdName', which is the full qualified
command name of a command -- "Addins.%progid%.%name%" (e.g.
progid:"MyAddin", name:"MyCmd", full name: "Addins.MyAddin.MyCmd").
You should check this name by comparing it with supported commands, then do
anything you like.

"Ahmad Jalil Qarshi" <ahmaddearNO@SPAMhotmail.com> дÈëÏûÏ¢ÐÂÎÅ:uNfSuEwKFHA.732@TK2MSFTNGP12.phx.gbl...

> hi!
>
[quoted text clipped - 11 lines]
>
> Ahmad Jalil Qarshi
Fuzzier - 28 Mar 2005 10:07 GMT
1. If you want to handle event from a Word button, you must implement
_CommandBarButtonEvents as ICommandBarButtonEvents.
------------------------------------------------
// sample code VC++:
class ATL_NO_VTABLE CEventSink :
public CComObjectRootEx<CComSingleThreadModel>,
public IDispatchImpl<ICommandBarButtonEvents,
&__uuidof(ICommandBarButtonEvents), &LIBID_Office, /*wMajor =*/ 2, /*wMinor
=*/ 3> // 2.3 = office 11.0
{
...
BEGIN_COM_MAP(CEventSink)
COM_INTERFACE_ENTRY_IID(__uuidof(_CommandBarButtonEvents),
ICommandBarButtonEvents)
END_COM_MAP()
...
STDMETHOD_(void, Click)(_CommandBarButton *Ctrl, VARIANT_BOOL
*CancelDefault);
};

------------------------------------------------
Then advise the event sink for the button (e.g. inside
_IDTExtensibility2::OnConnection()).

2. I think the problem is a custom button in a popup menu doesn't raise
events when it's clicked (bug?). The function _CommandBarButton::Execute()
will raise the event, however.
I created a word document and added a button to the "Inline Picture" popup
menu, and I created a VBA class to handle the 'click' event of the button
which simply shows a msgbox. The instance of the class is created during
document loading. But sadly, the event was not raised when I clicked the
button. Instead, I had a macro to invoke the 'Execute' method of the button,
the event is raised. I also tried to handle events from the build-in
"Cut(&T)" buttons, and the event was raised when it was clicked.

"Ahmad Jalil Qarshi" <ahmaddearNO@SPAMhotmail.com> дÈëÏûÏ¢ÐÂÎÅ:uNfSuEwKFHA.732@TK2MSFTNGP12.phx.gbl...

> hi!
>
[quoted text clipped - 11 lines]
>
> Ahmad Jalil Qarshi

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.