Declare Function GetDC Lib "user32.dll" (ByVal hWnd As Long) As Long
Platforms: Win 32s, Win 95/98, Win NT
GetDC returns the device context (DC) of a window or other device, given the object's handle. When you are finished using the device context, you should use ReleaseDC to free up system resources. 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. Do not use DeleteDC to destroy the device context when you are done.
Example:
' Find the device context of the desktop Dim deskhwnd As Long ' handle to the desktop Dim deskhdc As Long ' device context to the desktop Dim retval As Long ' return value deskhwnd = GetDesktopWindow() ' get the desktop's handle deskhdc = GetDC(deskhwnd) ' get the desktop's device context ' You could put any code that works with the desktop here retval = ReleaseDC(deskhwnd, deskhdc) ' free up resources associated with the device context
See Also: CreateDC, ReleaseDC
Category: Devices
Go back to the alphabetical Function listing.
Go back to the Reference section index.
This page is copyright © 2000 Paul Kuliniewicz. Copyright Information.
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/g/getdc.html