Solved

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

Posted on 2004-04-06
7
161 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
withoutTen challenge 14 88
canBalance challenge 34 65
building a service to accessed via telnet client, want colors ? 4 78
Sed question 2 49
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

746 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

18 Experts available now in Live!

Get 1:1 Help Now