Beginning ActiveX - Part 2
We have been using the Usercontrol object all the way through, but we are yet to see some of the cool things that we can do with it. Most of the changes to the Usercontrol will be made at the control's design-time. I will now take you on a whirlwind tour of what some of the more obscure properties do.
The Alignable property, when set to true, automatically creates a new property for the control, the align property. This allows the container to position the control in a similar way to toolbars and it also means that you control can be placed on MDI parent forms.
The CanGetFocus property allows the designer to prevent the control from getting focus at run-time, making it an entirely graphical control. When this is set to false, the only standard controls that you can use are the label, shape, image, line and timer controls.
The ControlContainer property defines whether the control can act as a container of other controls in a similar fashion to frames and picture boxes.
The DefaultCancel property adds the Default and Cancel properties to the control. In the same way that a command button with cancel set will have the click event raised when it detects the escape key being pressed. This allows you to create a quick way out for the user.
You can detect whether you must show that the control is the default control by checking the DisplayAsDefault property of the AmbientProperties object.
The InvisibleAtRuntime property enables you to create controls like the timer control that are not visible on the form at run-time.
Lastly, the ToolboxBitmap property lets you set an icon that appears in the toolbox. Although Microsoft recommends 32x32, I find that 23x23 or 24x24 works better, as 32x32 must be shrunk to fit it in.
Page 5 of 7