1

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...

Elmi
  • 5,899
  • 15
  • 72
  • 143

2 Answers2

1

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. :)

Community
  • 1
  • 1
Imran Khan Hunzai
  • 304
  • 1
  • 3
  • 17
0

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.

  • Hm, there is no .sdf file - how can I enable creation of it? – Elmi Apr 12 '13 at 05:20
  • @Tom Archer - In VS2010 it was still .ncb wasn't it? .sdf came with VS2012. – Roger Rowland Apr 12 '13 at 06:29
  • @Roger - I believe that we changed over to SDF in VS2k10. Prior to that, it was NCB. –  Apr 12 '13 at 13:50
  • @Tom - you're right! I stand corrected - http://stackoverflow.com/a/6296120/2065121 – Roger Rowland Apr 12 '13 at 13:52
  • @Elmi - The NCB (or SDF) file should be in the same folder as your SLN file. One thing to try is to close the VS solution, delete the NCB File, and then open the VS solution again. That should re-create the NCB file. –  Apr 12 '13 at 14:01
  • Hm, no success, there is nor NCP and no SDF file. I tried it with deleting the SUO file but that did not help, obviously this file is something different... – Elmi Apr 15 '13 at 05:57