Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What bad things may happen without calling to ReleaseDC?

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?

like image 247
jondinham Avatar asked Aug 28 '11 07:08

jondinham


People also ask

What happens if you abstain from ejaculating?

In theory, increasing your T levels by not ejaculating might have benefits if your levels are low. Low testosterone can have a negative impact on your mood, energy levels, and sex drive. It can also lead to erection problems, loss of muscle mass, and higher body fat.

What happens if we release sperm daily disadvantages?

It can turn out to be a psychological disorder – It can impact you dangerously and can impact your lifestyle while diverting you from your routine or daily goals. The truth is that if your release sperms daily or twice a week, it can lead to physical exhaustion and make you feel physically and mentally tired.

What happens if we release sperms daily?

Daily ejaculation will not reduce a man's sperm count, sperm motility or sperm quality one bit at all. Sperm quality and quantity both for an individual is highly variable. On an average, a healthy individual will produce over 2500 sperms/minute and masturbation will not deplete your testicular sperm reserve!

How do we know that sperm has entered or not?

If you are sexually active and you've missed your period date, it is a sign that sperm has entered the body. Usually, a woman menstruates when the egg has been released and has not been fertilised by a sperm cell.


1 Answers

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
like image 176
Armen Tsirunyan Avatar answered Sep 19 '22 10:09

Armen Tsirunyan