Solved

Vc++ 6.0

Posted on 1998-12-22
2
240 Views
Last Modified: 2010-04-02
I have created a generic class in a ActiveX control project , which owns some properties and member fuctions that have itself special datatype(example: CPerson) and return type(example: CPerson), how can I use it in VB? Now, I can add the controller into VB, but I can't use the member fuctions and properties that I defined myself like those  member fuctions and properties which automatically inherit from MFC.
0
Comment
Question by:WangHong
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 200 total points
ID: 1180877
You have to make sure that CPerson is derived from CObject. Then in the constructor of the class call EnableAutomation(). Finally, you need to use IDispatch* instead of CPerson* in your methods and properties. To retrieve the IDispatch* from a CPerson* you need to use

  IDispatch* dispatch = person->GetIDispatch(FALSE);

You cannot safely convert from an IDispatch* to a CPerson* unless there is a specific interface (CLSID) that you can query IDispatch* for and get a valid interface pointer. My suggestion is to either make a specific interface and add it to CPerson's interface map. Another possible solution to this problem is to use the IDispatch interface directly. That is GetIDsofNames() and Invoke().
0
 

Author Comment

by:WangHong
ID: 1180878
Sir, I have try your propose in a project. However, I still can't use the class properties or methods I defined myself. For example, I defined two classes named CPoint and CPoints use MFC class wizard as follow:
  class CPoint : public CCmdTarget
  {
   public:
      ...
   public:
     X : double;
     Y : double;
     ...(methods and properties)
   };

  class CPoints : public CCmdTarget
  {
   public:
      ...
   public:
     CPoint Items(short Index);
     void Add(CPoint aPoint);
     ...(methods and properties)
   };
   
   class CMyActiveXCtl : public COleControl
   {
    ....
    };
   And I suppose that I will use these two ActiveX Automation objects in VB 6.0 as follow:
   dim pt as new Point
   dim pts as new Points
   pt.x = 100.1
   pt.y = 200.1
   pts.Add(pt)
   
   May you tell me how can I realize these? If possible, please give me the actual steps and detail source code of the example.Thanks a lot.

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question