Declare Function GetDC Lib "user32.dll" (ByVal hWnd As Long) As Long
GetDC returns the device context (DC) of a window or similar object, given its handle. When you are finished using the device context, you should use ReleaseDC to free up system resources. This function has the same effect as using a VB object's .hDC property. If you try to get the device context of something that is not a device (i.e., pass the function a handle to a file) or another error occurs, the function will instead return 0.
Example:
' The two Print commands will return the same value
Debug.Print Form1.hDC
x = GetDC(Form1.hWnd)
Debug.Print x
Related Call: ReleaseDC
Category: Devices
Back to the index.