Share via


Visual Basic Concepts

Making Your Control Invisible at Run Time

To author a control that's invisible at run time, like the Timer control, set the InvisibleAtRuntime property of the UserControl object to True.

Important   Don't use the Visible property of the Extender object to make your control invisible at run time. If you do, your control will still have all the overhead of a visible control at run time. Furthermore, the extender properties are available to the user, who may make your control visible.

Invisible Controls vs. Ordinary Objects

Before you create a control that's invisible at run time, consider creating an ordinary object provided by an in-process code component (ActiveX DLL) instead.

Objects provided by in-process code components require fewer resources than controls, even invisible controls. The only reason to implement an invisible control is to take advantage of a feature that's only available to ActiveX controls.

Setting a Fixed Size for Your Control

Controls that are invisible at run time typically maintain a fixed size. You can duplicate this behavior using the Size method of the UserControl object, as shown here:

Private Sub UserControl_Resize()
   Size 420, 420
End Sub

The Width and Height properties of a UserControl object are always given in Twips, regardless of ScaleMode.