Returns a Windows handle to the form's device context.
[ hDc = ] Object.hDC
The hDC property syntax has the following parts:
Name |
Type |
Description |
Object |
AForm |
AForm object |
hDc |
Long |
An integer specifying a Windows handle to the object's device context. |
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. The hDC property can be used 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.
The following statement retrieves the AForm's device context handle:
frm1.hDC