Programming Components with Microsoft Visual Basic 6.0
Creating
ActiveX Controls
The standard ambient properties are as follows: BackColor, DisplayAsDefault, DisplayName, Font, ForeColor, LocaleID, MessageReflect, Palette, RightToLeft, ScaleUnits, ShowGrabHandles, ShowHatching, SupportsMnemonics, TextAlign, UIDead, and UserMode. In Visual Basic, you can safely ignore many of these ambient properties since default functionality in response to these properties is built in. The following are the ambient properties that you should be aware of:
- DisplayAsDefault
tells you whether your control is the default button for the container. If your control is the default, pressing the Enter key is equivalent to clicking on the control. Controls that are the default (DisplayAsDefault = True) should draw an extra-heavy border that identifies the default button to the end user.
- DisplayName
is the name of the particular instance of the control. It should be used when raising errors at design time so that the developer who receives the error can identify the control instance causing the error.
- ForeColor
, BackColor, and Font are hints your control can use to make its appearance match that of the container. For example, in the InitProperties event, which is fired whenever an instance of your control is first placed in a container, it is highly recommended to set your control’s ForeColor, BackColor, and Font properties to the values supplied by the ambient properties.
- TextAlign
tells the control how the client site would like the control to arrange the text it displays. If the value of the property is 0, the control should obey "general" alignment principles: text aligned to the left, numbers to the right. A value of 1 means left alignment, 2 means centered alignment, 3 means right alignment, and 4 means justified alignment.
- LocaleID
tells the control in which locale (language and country) the control should consider itself to be running.
- Palette
provides the current palette of the container.
- UserMode
allows an instance of your control to determine whether it is executing at design time (UserMode = False) or at run time (UserMode = True).
next page....
|