Click here to Skip to main content
Licence 
First Posted 5 Jul 2004
Views 98,261
Bookmarked 25 times

Creating An ActiveX Control using VC++.NET

By | 5 Jul 2004 | Article
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

About the Author

Abdul Hye

Web Developer

Pakistan Pakistan

Member

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

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralKnoweldge about ActiveX Pinmemberg1d10:32 11 Dec '07  
Generalthat is not c++.NET! Pinmemberzanadar18:04 10 Dec '07  
GeneralVC++.net 2003 Pinmemberminad_7863:25 10 Sep '07  
GeneralVS2005 crashes after the active-x control was added PinmemberAndy Jey16:32 7 Nov '06  
GeneralSomething to watch out for... PinmemberPaul S. Vickery6:31 6 Nov '06  
GeneralVery Big Problem Pinmembercharfeddine_ahmed2:20 10 Jul '06  
Generalgood article Pinmemberttt_say18:26 8 Feb '06  
QuestionCan I make ActiveX by C#? Pinmemberthainam20:04 6 Oct '05  
Generalgood job PinmemberTuPacMansur17:42 12 Sep '05  
QuestionCan you put your ActiveX to device control? Pinmemberhwang82210:41 22 Aug '05  
AnswerRe: Can you put your ActiveX to device control? PinmemberAbdul Hye19:59 23 Aug '05  
GeneralRe: Can you put your ActiveX to device control? PinmemberHongbo Wang3:03 24 Aug '05  
QuestionActiveX on .Net ? PinsussAnonymous3:22 29 Apr '05  
AnswerRe: ActiveX on .Net ? PinmemberAbdul Hye21:08 30 Apr '05  
QuestionAnd where is the wizard to delete methods. properties and events? PinmemberRoger Bamforth5:58 26 Apr '05  
QuestionWhere is the wizard to add properties and methods? PinmemberSohailB20:51 26 Mar '05  
AnswerRe: Where is the wizard to add properties and methods? PinmemberMMansonFan2517:08 29 Mar '05  
GeneralRe: Where is the wizard to add properties and methods? PinmemberAbdul Hye6:19 30 Mar '05  
GeneralCreating ActiveX from C# Pinmemberdrubio21:36 15 Nov '04  
GeneralRe: Creating ActiveX from C# PinmemberAbdul Hye6:20 28 Nov '04  
GeneralRe: Creating ActiveX from C# PinmemberJavierJJJ21:47 20 Nov '05  
GeneralNice article PinmemberPakaa4:10 6 Jul '04  
GeneralRe: Nice article PinmemberAbdul Hye18:57 6 Jul '04  
QuestionCan i used it in VC.Net? Pinmembercoco_552:18 6 Jul '04  
AnswerRe: Can i used it in VC.Net? PinmemberAbdul Hye18:59 6 Jul '04  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    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 | Mobile
Web02 | 2.5.120517.1 | Last Updated 6 Jul 2004
Article Copyright 2004 by Abdul Hye
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid