Click here to Skip to main content
12,998,892 members (53,050 online)
Click here to Skip to main content
Add your own
alternative version

Stats

115.3K views
1.4K downloads
26 bookmarked
Posted 5 Jul 2004

Creating An ActiveX Control using VC++.NET

, 5 Jul 2004
Rate this:
Please Sign up or sign in to vote.
An understanding of ActiveX controls.

Sample Image - picture1.jpg

A view of ActiveX Control Test Container.

Sample screenshot

A view of an ActiveX control used in a Visual Basic .NET application.

Introduction

An ActiveX control is a software component that can be plugged into many different programs and used as if it were a native part of the program. It's similar to the concept of a separate head phone. If you have a computer, just plug into it, it works with your computer. ActiveX controls bring the same type of interoperability to software applications.

Required things

  • Visual Studio .NET
  • Windows 2000/XP

Working

Create MFC ActiveX control wizards application, named as MyActiveXIcon, In the class named CMyActiveXIconCtrl, use the OnDraw function. This function is called by the framework to draw the control in the specified bounding rectangle using the specified device context.

void CMyActiveXIconCtrl::OnDraw(CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)

This function is to draw the ActiveX control icon.

CBitmap::LoadBitmap()

This function loads the MyActiveXIcon bitmap file using the resource ID, IDB_MyActiveXIcon. Then bitmap file is used by the memDC, which is the compatible device context (DC) with the current DC.

CDC::StretchBlt()

This function resizes the MyActiveXIcon by stretching the AcitveXControl icon to fit the current size of the Device Context. Now, run the program. In Visual C++ .NET, it automatically registers the control.

Then go to the Tools menu and click on ActiveX Control Test container. It displays the window, in which, go to the Edit menu and click on Insert Control option. A window will appear, check the MyActiveX Icon Control, you see this like in the above picture which shows the ActiveX Control Test Container.

How to use in an application

For this moment, I tell you how to use it in VB.NET. Create a Windows application. Go to the toolbox window, right click on it, and click on the Customize toolbox. A dialog appears with two tab controls. Use the COM tab and check the My ActieXControl icon. Now, it will appear on the toolbox. Click it and add it on your form.

If you have any suggestions, send me an email, I will be thankful to you.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Abdul Hye
Web Developer
Pakistan Pakistan
I did Msc Computer Scicences specialization in software engineering from University of Management and Technology Lahore,and having the experience of IT for more than 5 years.
I have worked in different programming languages, such as: C, C++, Visual C++,Java, Visual Basic and C#, also in PHP, HTML, ASP, ASP.NET and also CCNA & RedHat Linux. Love Mathematics. I have always been fascinated by .NET, so now I am programming in .NET.

You can email me: only_boby@hotmail.com
Visit my web site: http://www28.brinkster.com/abdulhye

You may also be interested in...

Pro
Pro

Comments and Discussions

 
GeneralKnoweldge about ActiveX Pin
g1d111-Dec-07 0:32
memberg1d111-Dec-07 0:32 
Generalthat is not c++.NET! Pin
zanadar10-Dec-07 18:04
memberzanadar10-Dec-07 18:04 
GeneralVC++.net 2003 Pin
minad_78610-Sep-07 3:25
memberminad_78610-Sep-07 3:25 
GeneralVS2005 crashes after the active-x control was added Pin
Andy Jey7-Nov-06 16:32
memberAndy Jey7-Nov-06 16:32 
GeneralSomething to watch out for... Pin
Paul S. Vickery6-Nov-06 6:31
memberPaul S. Vickery6-Nov-06 6:31 
GeneralVery Big Problem Pin
charfeddine_ahmed10-Jul-06 2:20
membercharfeddine_ahmed10-Jul-06 2:20 
Generalgood article Pin
ttt_say8-Feb-06 18:26
memberttt_say8-Feb-06 18:26 
QuestionCan I make ActiveX by C#? Pin
thainam6-Oct-05 20:04
memberthainam6-Oct-05 20:04 
Generalgood job Pin
TuPacMansur12-Sep-05 17:42
memberTuPacMansur12-Sep-05 17:42 
QuestionCan you put your ActiveX to device control? Pin
hwang82222-Aug-05 10:41
memberhwang82222-Aug-05 10:41 
AnswerRe: Can you put your ActiveX to device control? Pin
Abdul Hye23-Aug-05 19:59
memberAbdul Hye23-Aug-05 19:59 
GeneralRe: Can you put your ActiveX to device control? Pin
Hongbo Wang24-Aug-05 3:03
memberHongbo Wang24-Aug-05 3:03 
QuestionActiveX on .Net ? Pin
Anonymous29-Apr-05 3:22
sussAnonymous29-Apr-05 3:22 
AnswerRe: ActiveX on .Net ? Pin
Abdul Hye30-Apr-05 21:08
memberAbdul Hye30-Apr-05 21:08 
QuestionAnd where is the wizard to delete methods. properties and events? Pin
Roger Bamforth26-Apr-05 5:58
memberRoger Bamforth26-Apr-05 5:58 
QuestionWhere is the wizard to add properties and methods? Pin
SohailB26-Mar-05 20:51
memberSohailB26-Mar-05 20:51 
AnswerRe: Where is the wizard to add properties and methods? Pin
MMansonFan2529-Mar-05 17:08
memberMMansonFan2529-Mar-05 17:08 
GeneralRe: Where is the wizard to add properties and methods? Pin
Abdul Hye30-Mar-05 6:19
memberAbdul Hye30-Mar-05 6:19 
GeneralCreating ActiveX from C# Pin
drubio15-Nov-04 21:36
memberdrubio15-Nov-04 21:36 
GeneralRe: Creating ActiveX from C# Pin
Abdul Hye28-Nov-04 6:20
memberAbdul Hye28-Nov-04 6:20 
GeneralRe: Creating ActiveX from C# Pin
JavierJJJ20-Nov-05 21:47
memberJavierJJJ20-Nov-05 21:47 
GeneralNice article Pin
Pakaa6-Jul-04 4:10
memberPakaa6-Jul-04 4:10 
GeneralRe: Nice article Pin
Abdul Hye6-Jul-04 18:57
memberAbdul Hye6-Jul-04 18:57 
QuestionCan i used it in VC.Net? Pin
coco_556-Jul-04 2:18
membercoco_556-Jul-04 2:18 
AnswerRe: Can i used it in VC.Net? Pin
Abdul Hye6-Jul-04 18:59
memberAbdul Hye6-Jul-04 18:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170622.1 | Last Updated 6 Jul 2004
Article Copyright 2004 by Abdul Hye
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid