Solved

ActiveX control of a C++ class

Posted on 2004-04-04
2
253 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
WinWaitActive parameters 12 31
bigDiff challenge 17 75
ShiftLeft challenge 21 66
Use of condition with 'serial' in ansible 2 36
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

758 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