# AmbientProperties class

The **AmbientProperties** object exposes information about the environment in which a control is hosted. The container --- a form, a property page, the IDE designer surface --- populates this object with hints about its appearance, locale, and operating mode so that an embedded control can adapt itself to fit in. Every property is read-only: the container, not the control, decides what these values should be.

## Detecting design-time versus run-time

A control often needs to behave differently while it is being placed on a designer surface than when it is actually running inside an application. [**UserMode**](/tB/Packages/VBRUN/AmbientProperties/UserMode.md) returns **False** in the IDE designer and **True** at run time, and [**UIDead**](/tB/Packages/VBRUN/AmbientProperties/UIDead.md) becomes **True** while execution is paused under the debugger so that a control knows not to repaint or respond to input. [**ShowGrabHandles**](/tB/Packages/VBRUN/AmbientProperties/ShowGrabHandles.md) and [**ShowHatching**](/tB/Packages/VBRUN/AmbientProperties/ShowHatching.md) tell a control whether the container would like it to draw the usual selection adornments while it is being edited.

```tb check_build
Sub AdaptToHost(ByVal Host As AmbientProperties)
    If Host.UserMode Then
        ' Running in the host application — render normally.
    Else
        ' Embedded in a designer — show edit-time decorations instead.
    End If
End Sub
```

## Visual defaults from the container

The container suggests a default colour scheme and typeface so that embedded controls fit in with their surroundings. [**BackColor**](/tB/Packages/VBRUN/AmbientProperties/BackColor.md) and [**ForeColor**](/tB/Packages/VBRUN/AmbientProperties/ForeColor.md) supply the suggested background and foreground colours as **OLE_COLOR** values, [**Font**](/tB/Packages/VBRUN/AmbientProperties/Font.md) returns the suggested **stdole.IFontDisp**, and [**Palette**](/tB/Packages/VBRUN/AmbientProperties/Palette.md) returns a hint palette as an **stdole.IPictureDisp**. [**TextAlign**](/tB/Packages/VBRUN/AmbientProperties/TextAlign.md) reports the container's preferred text alignment, and [**RightToLeft**](/tB/Packages/VBRUN/AmbientProperties/RightToLeft.md) is **True** when the container is laid out for a right-to-left language.

## Layout and other UI hints

[**ScaleUnits**](/tB/Packages/VBRUN/AmbientProperties/ScaleUnits.md) names the unit of measure the container uses to size itself --- for example `"Twip"` or `"Pixel"`. [**SupportsMnemonics**](/tB/Packages/VBRUN/AmbientProperties/SupportsMnemonics.md) is **True** when the container will dispatch keyboard mnemonics --- the underlined letters following an `&` --- to its controls. [**DisplayAsDefault**](/tB/Packages/VBRUN/AmbientProperties/DisplayAsDefault.md) is **True** if the container is treating this control as its default control, so the control can paint itself with a heavier border. [**MessageReflect**](/tB/Packages/VBRUN/AmbientProperties/MessageReflect.md) indicates whether the container reflects window messages addressed to the control back to the control's own message handler.

## Locale and identity

[**LocaleID**](/tB/Packages/VBRUN/AmbientProperties/LocaleID.md) returns the Locale ID of the container, so a control can format text and numbers consistently with its host. [**DisplayName**](/tB/Packages/VBRUN/AmbientProperties/DisplayName.md) returns the name the container has assigned to the control --- a useful string for error messages or property browsers.

## Members

- [BackColor](/tB/Packages/VBRUN/AmbientProperties/BackColor.md) -- returns the container's suggested background colour
- [DisplayAsDefault](/tB/Packages/VBRUN/AmbientProperties/DisplayAsDefault.md) -- returns whether the container is treating this control as its default
- [DisplayName](/tB/Packages/VBRUN/AmbientProperties/DisplayName.md) -- returns the name the container has assigned to the control
- [Font](/tB/Packages/VBRUN/AmbientProperties/Font.md) -- returns the container's suggested font
- [ForeColor](/tB/Packages/VBRUN/AmbientProperties/ForeColor.md) -- returns the container's suggested foreground colour
- [LocaleID](/tB/Packages/VBRUN/AmbientProperties/LocaleID.md) -- returns the container's Locale ID
- [MessageReflect](/tB/Packages/VBRUN/AmbientProperties/MessageReflect.md) -- returns whether the container reflects window messages back to the control
- [Palette](/tB/Packages/VBRUN/AmbientProperties/Palette.md) -- returns the container's suggested colour palette
- [RightToLeft](/tB/Packages/VBRUN/AmbientProperties/RightToLeft.md) -- returns whether the container is laid out right-to-left
- [ScaleUnits](/tB/Packages/VBRUN/AmbientProperties/ScaleUnits.md) -- returns the unit of measure used by the container
- [ShowGrabHandles](/tB/Packages/VBRUN/AmbientProperties/ShowGrabHandles.md) -- returns whether the container wants the control to draw selection grab handles
- [ShowHatching](/tB/Packages/VBRUN/AmbientProperties/ShowHatching.md) -- returns whether the container wants the control to draw a selection hatching pattern
- [SupportsMnemonics](/tB/Packages/VBRUN/AmbientProperties/SupportsMnemonics.md) -- returns whether the container will dispatch keyboard mnemonics to controls
- [TextAlign](/tB/Packages/VBRUN/AmbientProperties/TextAlign.md) -- returns the container's preferred text alignment
- [UIDead](/tB/Packages/VBRUN/AmbientProperties/UIDead.md) -- returns whether the user interface is non-responsive (for example, paused in the debugger)
- [UserMode](/tB/Packages/VBRUN/AmbientProperties/UserMode.md) -- returns **True** at run time and **False** when hosted in a designer
