A view of ActiveX Control Test Container.
A view of an ActiveX control used in a Visual Basic .NET application.
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.
- Visual Studio .NET
- Windows 2000/XP
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.
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.
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.