Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6362975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:58:38+00:00 2026-05-24T23:58:38+00:00

Programming with C++, once we get the context device by GetDC to use. What

  • 0

Programming with C++, once we get the context device by GetDC to use. What bad things may happen if we exit the program without calling to ReleaseDC?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T23:58:39+00:00Added an answer on May 24, 2026 at 11:58 pm

    From the docs

    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.

    As you can see, it may be needed if other applications can access the same DC.

    In any case, it’s good idea to use C++ RAII idiom for this kind of things. Consider this class:

    class ScopedDC
    {
       public:
          ScopedDC(HDC handle):handle(handle){}
          ~ScopedDC() { ReleaseDC(handle); }
          HDC get() const {return handle; }
       //disable copying. Same can be achieved by deriving from boost::noncopyable
       private:
          ScopedDC(const ScopedDC&);
          ScopedDC& operator = (const ScopedDC&); 
    
       private:
          HDC handle;
    };
    

    With this class you can do this:

    {
       ScopedDC dc(GetDC());
       //do stuff with dc.get();
    }  //DC is automatically released here, even in case of exceptions
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just began learning network programming. My first program is very simple: once connected,
I once saw a programming pattern (not design), how to implement a fast copy
The Holy Grail of programming is to solve a problem once and make continual
I've tried using LaTeX and DocBook for documenting programming tools, to get PDF output.
I'm new to android programming, but one thing that I can't seem to get
This may be chalked up to exhaustion, but I am new to MVC programming
Once upon a time, I dabbled in programming Homebrew for the Nintendo DS. During
While doing variadic template programming in C++11 on GCC, once in a while I
Programming Student here...trying to work on a project but I'm stuck. The project is
Programming in vim I often go search for something, yank it, then go back

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.