Visual Basic Reference
HasDC Property
See Also Example Applies To
Returns or sets a value that determines whether a unique display context (or hDC) is allocated to a control.
Syntax
object.HasDC [ = boolean]
The HasDC property syntax has these parts:
Part | Description |
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. |
Settings
The settings for boolean are:
Setting | Description |
True | (Default) An hDC is allocated to the control. |
False | No hDC is allocated to the control. |
Remarks
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.