Visual Basic Reference
Returns or sets a value that determines whether a unique display context (or hDC) is allocated to a control.
object.HasDC [ = boolean]
The HasDC property syntax has these parts:
|object||An object expression that evaluates to an object in the Applies To list.|
|boolean||A Boolean expression that specifies whether an hDC is allocated to a control.|
The settings for boolean are:
|True||(Default) An hDC is allocated to the control.|
|False||No hDC is allocated to the control.|
If you set the HasDC property to False, you should copy the hDC of the control only into a local variable. Calling APIs with an hDC obtained outside of the scope of an event can cause crashes or other unpredictable results.
For windowless UserControls, the HasDC property will only take effect if the UserControl is created with a window (i.e., it's in a container that doesn't support windowless activation, such as Visual Basic version 4.0 or Internet Explorer version 3.0). Windowless UserControls that are activated windowless never have their own hDC, and therefore ignore the value of their HasDC property.