Am I doing wrong?
-
Hi, In View I get DC as CDC *dc = GetDC(); I do whatever.. and function exits.. Is there need to release this dc or it will be done automatically as function exits.. If I release will there be harm to views DC. What is the right way. SHould I always use CClientDC in views rather than CDC regards ppatel
-
Hi, In View I get DC as CDC *dc = GetDC(); I do whatever.. and function exits.. Is there need to release this dc or it will be done automatically as function exits.. If I release will there be harm to views DC. What is the right way. SHould I always use CClientDC in views rather than CDC regards ppatel
From the docs:
Unless the device context belongs to a window class, the ReleaseDC member function must be called to release the context after painting.
--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
-
From the docs:
Unless the device context belongs to a window class, the ReleaseDC member function must be called to release the context after painting.
--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
-
How can I know if the device context belongs to windows? Which function/syntax shows that dc belongs to windows? ppatel
The simple answer is don't bother. Here's a quote from MSDN on the
ReleaseDC
function: "The ReleaseDC function releases a device context (DC), freeing it for use by other applications. The effect of the ReleaseDC function depends on the type of DC. It frees only common and window DCs. It has no effect on class or private DCs." So always callReleaseDC
and let the system worry about the details. Steve -
The simple answer is don't bother. Here's a quote from MSDN on the
ReleaseDC
function: "The ReleaseDC function releases a device context (DC), freeing it for use by other applications. The effect of the ReleaseDC function depends on the type of DC. It frees only common and window DCs. It has no effect on class or private DCs." So always callReleaseDC
and let the system worry about the details. SteveHi Stephen Hewitt and use DeleteDC() if use CreateCompatibleDC or CreateDC:)_**
**_
WhiteSky
-
Hi Stephen Hewitt and use DeleteDC() if use CreateCompatibleDC or CreateDC:)_**
**_
WhiteSky
From doco on
DeleteDC
"An application must not delete a DC whose handle was obtained by calling the GetDC function. Instead, it must call the ReleaseDC function to free the DC." If you useCreateCompatibleDC
ofCreateDC
you need to delete it when done by callingDeleteDC
. CallingReleaseDC
doesn't actually delete a DC. To quote again from MSDN: "The ReleaseDC function releases a device context (DC), freeing it for use by other applications." Steve