IE Extension:IOleCommandTarget Implementation in C#

S

Sujoan

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
 

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