Make Your First ActiveX Control

Lesson 1
Tutorials - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13

So now the Control look like a button.
But it's not a button, it's a form with button on it.
But what if the user will resize the control at design time
(like you do to Command Button, after you enter it to your form)?

Suppose you have a regular form with a button on it,
and the form is resized to the button size (like in your current control).
When the user will resize the form, he will see the form
that was before 'under' the button.
The same thing will happen in our case.

To solve this problem, when the user resize the form (i.e the control),
we need to resize the button to fit the form and the form will be
again at the size of the button.
When the user resize the control, he actually try to resize the button.
Enter the following code to let the user resize the button
instead of resizing the form:

Private Sub UserControl_Resize()
   Command1.Width = UserControl.Width
   Command1.Height = UserControl.Height
End Sub

UserControl is the name of the Form/Control.
thus, UserControl.Width is the Form/Control width,
UserControl.Height is the Form/Control Height and UserControl_Resize()
is the event that occur when the user resize the control.


Back  Forward