?
Solved

ActiveX control of a C++ class

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.

649 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