0

I’m tring to add OLE support to my program. I started by compiling one of the Qt examples: http://doc.qt.digia.com/stable/activeqt-comapp.html

This example, export 1 class and 2 types:

QAXCLASS(Application)
QAXTYPE(Document)
QAXTYPE(DocumentList)

In order to test it, I import it in Microsft Visual C++ (add class, MFC class from Typelib) The problem is that, after import, my classes are renamed:

CApplication
CDocument
CDocumentList

So when I call CApplication::Getdocuments() it returns a DocumentList* and this class is unknown! What am I doing wrong?

EDIT: tested in a VB project, and it works fine! So there must be something wrong when importing the tlb in VC++

Julien M
  • 657
  • 3
  • 10
  • 40
  • The "MFC class from Typelib" option is rather awful. It does generate class names that have a C prefix. They are *wrappers*, using late binding to your COM classes. What you get back from Getdocuments() should be an IDispatch*, not a DocumentList*. This is all rather a bad idea, use the #import directive instead. – Hans Passant Nov 28 '12 at 00:43
  • Could you please detail your answer, or point me on a webpage? The option "MFC class from Typelib" generate a class. In the header, the first line is a #import of my tlb. What should I do instead? – Julien M Nov 29 '12 at 15:27
  • Just start at the MSDN page for #import and continue reading at the "Compiler COM support" link to understand how to use the smart pointers. http://msdn.microsoft.com/en-us/library/8etzzkb6%28v=VS.100%29.aspx – Hans Passant Nov 29 '12 at 15:31

0 Answers0