Wednesday, 10 August 2011

Make Your First ActiveX Control 1

0 comments
 
First of all, what is ActiveX Control?ActiveX control is control like all visual basic common controls: Command Button, Label, etc.
You can make your own ActiveX control, for example  hover button control, and use it in every VB program you make without addition of code. Instead of writing the same code every time you want to use the hover button, make once hover button  ActiveX control, and drag it to your form every time you want to use it, like it was the usual Command Button.

How can you make your own ActiveX control?In this tutorial we will make a button control, that will pop a message box when the user will click on it.
I know that it's not very useful, and for this purpose you don't have to make an ActiveX control, but this example  will teach you how to make an ActiveX control.

Getting startedChoose from the menu (in VB 6.0) File->New Project
Select ActiveX Control and press OK.
A new form without a title bar has been opened
Choose from the menu Project->Project1 Properties.
 in the 'Project Name' Text Box is written by default 'Project1'
 Change the 'Project Name' to myFirstOCX.

This is what you will see, after you complete the control,
In the Project->Components menu - where the user choose
which OCX controls to add to his project

Right click on the form, and choose properties from the menu.
The form's name property by default is UserControl1. Change it to MyControl.
 This will be default name of the control when the user will
insert it to his form: MyControl1, MyControl2, and so on.

Leave a Reply