Solved

Please help in making an ActiveX control of a class (no GUI needed)

Posted on 2004-04-06
7
162 Views
Last Modified: 2013-11-20
Hi All,

      I wanted to make a ActiveX control (no GUI support) which has all the methods defined in the class shown below including the operator== overloading and copy contructor.  Later on I have to use these methods in a VBA.

I got 3-4 replies but either the hint provided didn't worked out or I got syntax errors after compiling in MS VS C++ 6.
I have allready spent 3 days on this problem but could not able to solve it. Please help me in solving it.

Please reply as quick as possible in details. I will be very thankful,  if you could build the ActiveX control by taking my Test.cpp as an input and send the tar file of the complete project at the following address: pawan_kumar00@yahoo.com
 
Thanks in advance,

With Regards,
Pawan

//Test class
#include <iostream>
#include <string>
using namespace std;

class Test
{
private:
    unsigned int total;
public:
    Test();
    ~Test();
    Test(const Test& testObj);
    void addValue(unsigned int value);
    unsigned int getValue();
    bool operator== (const Test& testObj);
};

Test::Test()
{
     total = 0;
}

Test::~Test()
{
}

Test::Test(const Test& testObj)
{
    this->total = testObj.total;
}

void Test::addValue(unsigned int value)
{
    total = total + value;
}

unsigned int Test::getValue()
{
    return total;
}

bool Test::operator==(const Test& testObj)
{
    if (this->total == testObj.total)
        return true;
    else
        return false;
}
0
Comment
Question by:uniquepawan
  • 2
  • 2
7 Comments
 
LVL 15

Expert Comment

by:lakshman_ce
ID: 10774823
Hi Pawan,
Please try to make an ActiveX control with the inputs that I gave you. You will learn when you do it else you will never learn.
It is very simple to write a control for this class. Create an MFC ActiveX control project and add the required methods and properties as I suggested..
The class members which you intend to send or receive to VBA or any other application can be made as properties. And you can achieve this easily by using the set property and get property.
Also the methods like AddValue can be added to the ActiveX interface methods.
Plz let me know if you have any difficulties in making the activex control.
Good luck,
Lakshman
0
 
LVL 15

Expert Comment

by:lakshman_ce
ID: 10774840
Plz post the errors that you are getting. So that we can help you.

-Lakshman

0
 
LVL 9

Expert Comment

by:_ys_
ID: 10776535
COM [ActiveX] is supposed to be language independant. As such the ability to expose C++ esque methods is not available.

How many languages have operator== ? Specifically, does VBA ?!

As nonubik suggested (http://www.experts-exchange.com/Programming/Programming_Languages/MFC/Q_20943508.html) using isEqual( ) and clone( ) is a common implementaton for scenarios such as these.

Also, as lakshman_ce suggested, specific error codes/messages would aid your cause greatly.
0
 
LVL 9

Expert Comment

by:_ys_
ID: 10776557
Nobody has mentioned this yet, but if you want to use your object from VBA, you're going to have to implement an automation aware component. i.e. one that implements a dispinterface (IDispatch in COM parlance).
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 12049841
PAQed - no points refunded (of 125)

Computer101
E-E Admin
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Add content to output file 4 62
modThree challenge 4 77
twoTwo  challenge 35 93
firstChar challenge 13 107
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

919 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now