Export (0) Print
Expand All
Expand Minimize
7 out of 20 rated this helpful - Rate this topic

Visual Basic Reference

Visual Studio 6.0

hDC Property

See Also    Example    Applies To

Returns a handle provided by the Microsoft Windows operating environment to the device context of an object.



The object placeholder represents an object expression that evaluates to an object in the Applies To list.


This property is a Windows operating environment device context handle. The Windows operating environment manages the system display by assigning a device context for the Printer object and for each form and PictureBox control in your application. You can use the hDC property to refer to the handle for an object's device context. This provides a value to pass to Windows API calls.

With a CommonDialog control, this property returns a device context for the printer selected in the Print dialog box when the cdlReturnDC flag is set or an information context when the cdlReturnIC flag is set.

Note   The value of the hDC property can change while a program is running, so don't store the value in a variable; instead, use the hDC property each time you need it.

The AutoRedraw property can cause the hDC property setting to change. If AutoRedraw is set to True for a form or PictureBox container, hDC acts as a handle to the device context of the persistent graphic (equivalent to the Image property). When AutoRedraw is False, hDC is the actual hDC value of the Form window or the PictureBox container. The hDC property setting may change while the program is running regardless of the AutoRedraw setting.

If the HasDC property is set to False, a new device context will be created by the system and the value of the hDC property will change each time it is called.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
© 2014 Microsoft. All rights reserved.