Question

The question seems to be stupid since there are many explanations in internet, that describe how to add a new method that can be called by users of the resulting OCX later. Unfortunately it does not work for me.

I have a MFC-based ActiveX-control project that was created with Visual Studio 6 and was imported to VS2010. There I have NO class view where I could use the Wizard with to add a method (the class view tab pane is there but it is empty). The existing code also does not provide any callable methods until now so that I simply could copy them.

So: how can I enable/invoke the class view generation in VS2010 to use the Wizard?

And as soon as it works: What type should such a method be to be externally visible? From what I learned the Wizard asks for some type...

Was it helpful?

Solution

To add a method to your ActiveX control you have to follow the folliwng 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. :)

OTHER TIPS

Maybe the SDF file is corrupt?

If you right-click the Class View dialog bar, you should see a context menu option for Class Wizard. From there, you should be able to work with your project's classes.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top