Solved

ActiveX control of a C++ class

Posted on 2004-04-04
2
262 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

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 …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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 is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

695 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