?
Solved

ActiveX control of a C++ class

Posted on 2004-04-04
2
Medium Priority
?
266 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 375 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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 this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month14 days, 1 hour left to enroll

801 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