Solved

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

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

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

809 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