How to add a method to an ActiveX (ocx)

In the programming world, there are many ways to perform a task.

Prerequisites: Language: C++ and I have used VisualStudio2008.

First, create a Project (MFC ActiveX control). Then to add a method to your ActiveX control you have to follow the following steps:

  1.  Declare the function in the header file.

e.g.

public:
int Connect(int timeout);

2. Add the definition in the CPP file.

int CSLWebLinkCtrl::Connect(int timeout)

// Your logic here.

return 0;
3. Expose your methods in the .idl file

[id(4), helpstring(“method Connect”)] int Connect(int timeout);
Hope it will help you. 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s