ReleaseDC Function

Declare Function ReleaseDC Lib "user32.dll" (ByVal hWnd As Long, ByVal hdc As Long) As Long

Platforms: Win 32s, Win 95/98, Win NT

ReleaseDC frees up the resources used when you use GetDC to get an object's device context. This function should not be used to destroy a device context obtained from CreateDC -- for those, use DeleteDC instead. This should be done after your program finishes using the device context. The function returns 0 if an error occured or a 1 if successful.

hWnd
The handle of the object to free the resources of.
hdc
The device context of the object to free the resources of.

Example:

' Get the device context of the desktop window.  This example doesn't
' use the DC for anything, but it could be used to copy the desktop image to another window.
Dim deskhwnd As Long  ' receives handle to the desktop window
Dim deskhdc As Long  ' receives device context of the desktop window
Dim retval As Long  ' return value

' Figure out the desktop's device context
deskhwnd = GetDesktopWindow()  ' get the desktop's handle
deskhdc = GetDC(deskhwnd)  ' get its device context

' deskhdc could be used here to do any number of things....

' Release the device context to free up resources
retval = ReleaseDC(deskhwnd, deskhdc)

See Also: DeleteDC, GetDC
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/r/releasedc.html