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)

Related Call: DeleteDC, GetDC
Category: Devices
Back to the index.


Go to Paul Kuliniewicz's Home Page.
E-mail: rogue953@hotmail.com
This page is at http://skyscraper.fortunecity.com/transmission/45/api/r/releasedc.html