Jump to content
  • Advertisement
Sign in to follow this  
hupsilardee

Rules for creating/getting/releasing/deleting HDC

This topic is 2559 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

There are several ways to get hold of a HDC

BeginPaint()
CreateCompatibleDC()
GetDC()

If the creation method involves 'get', you should clean up by calling ReleaseDC()
If the creation method involves 'create' you should clean up with DeleteDC()
Cleanup BeginPaint() with EndPaint()

Are there any other rules I should know about? Especually, how do you deal with the HDC retrieved by GetDC(NULL)? or does that not need explicit release/deletion?

Share this post


Link to post
Share on other sites
Advertisement

If the creation method involves 'get', you should clean up by calling ReleaseDC()

yes

If the creation method involves 'create' you should clean up with DeleteDC()
[/quote]
yes

Cleanup BeginPaint() with EndPaint()
[/quote]
Don't do anything. (beyond calling EndPaint())

Are there any other rules I should know about?
[/quote]
Never call CreateCompatibleDC or CreateCompatibleBitmap on a memory device context.

Especually, how do you deal with the HDC retrieved by GetDC(NULL)? or does that not need explicit release/deletion?
[/quote]
ReleaseDC(NULL, hdcScr);

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!