By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,963 Members | 1,260 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,963 IT Pros & Developers. It's quick & easy.

IE Extension:IOleCommandTarget Implementation in C#

P: n/a
Hi,
I want to create a IE Extension in C#. I have added a button to IE
standard toolbar and then made IE call the DLL when button is clicked.
In this DLL, I want to capture the button click. To identify this,
I have started with the following code:
*--------------------------------------------------------------------------**

[StructLayout(LayoutKind.Sequential)]
public struct OLECMDTEXT
{
public UInt32 cmdtextf;
public UInt32 cwActual;
public UInt32 cwBuf;
public char rgwz;
}

[StructLayout(LayoutKind.Sequential)]
public struct OLECMD
{
public UInt32 cmdID;
public UInt64 cmdf;
}
[ComImport(), Guid("B722BCCB-4E68-101B-A2BC-00AA00404770"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown )]
public interface IOleCommandTarget
{
[PreserveSig()]
int QueryStatus( [In, MarshalAs(UnmanagedType.Struct)]
ref Guid
pguidCmdGroup, [MarshalAs(UnmanagedType.U4)]
int cCmds,
[In, Out] IntPtr prgCmds, [In, Out] IntPtr
pCmdText);
[PreserveSig()]
int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint
nCmdExecOpt,
object[] pvaIn, [In, Out,
MarshalAs(UnmanagedType.LPArray)]
object[] pvaOut);
}
*--------------------------------------------------------------------------*----------------------------*

Now, I need to implement the QueryStatus& Exec methods for the button
click. What all the parameters to be handled inside this QueryStatus
method to give information about the button?
I found that nCmdID for my button has to be given to invoke Exec
method. Already IDs exist only for the standard buttons. In the
tutorial for "adding toolbar button", i found that 1 is to be given.
But 1 already exist for a standard button. Please give a clear idea on
this.
Can anybody point me to a sample implementation for these methods on
similar scenario or help me directly in this?
Thanks and Regards,
Sujoan

Mar 18 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.