Solved

ActiveX control of a C++ class

Posted on 2004-04-04
2
258 Views
Last Modified: 2013-11-20
Hi All,
      I wanted to make a ActiveX control which has all the methods similar to the methods defined in the class shown below including the operator== overloading and copy contructor. Actually, later on I need all these methods in a VBA.

Please guide me how I should proceed to do the same?
Please reply as quick as possible, if you can.
 
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:pawankumariitd
2 Comments
 
LVL 15

Accepted Solution

by:
lakshman_ce earned 125 total points
ID: 10753840
Use MFC ActiveX control Wizard for creating the project .
If you don't want any windows,select windowless activation option (refer Advanced tab in the MFC ActiveX control wizard while creating the project)

Once you create the project you can find the Interfaces.

Note : MFCActiveX = Project Name

Right click on the interface "DMFCActiveX" and Add a method or property.
1.Inside your method you can write the code and call this method where you will be using the activex control
  - In the Add Method window select custom for creating your own methods and you can type the name of the function
2. You can add properites and call the setters and getters in the contained where this activex control wil be used.
In your case, you can properties for 'total' attribute of your class
Plz refer to this for more on set and get property
http://www.experts-exchange.com/Programming/Programming_Languages/Cplusplus/Q_20892274.html

Right click on the interface "DMFCActiveXEvents" and add events, if required

Also you can refer to for more details

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/_core_activex_controls.3a_.adding_custom_methods_to_an_activex_control.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/_core_activex_controls.3a_.events.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/_core_activex_control_topics.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/_core_Overview.3a_.Creating_an_MFC_ActiveX_Control_Program.asp

-Lakshman
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Turn a spreadsheet into a vba executable. 2 98
maven archtype selection in eclipse 1 58
abstract class with all non abstract mentods 6 84
Detect file exist or not 3 202
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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…
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.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

733 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