Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What type of DC is returned by calling GetDC(NULL)?

Tags:

winapi

gdi

The Windows API function GetDC() accepts a single parameter:

hWnd

A handle to the window whose DC is to be retrieved. If this value is NULL, GetDC retrieves the DC for the entire screen.

Further down the page, the following is noted:

After painting with a common DC, the ReleaseDC function must be called to release the DC. Class and private DCs do not have to be released. ReleaseDC must be called from the same thread that called GetDC. The number of DCs is limited only by available memory.

Unfortunately, it is unclear whether calling ReleaseDC() is necessary for a screen DC since its type is not mentioned anywhere. In fact, this page describes five types of DCs; but none of them mention "screen".

Do I need to call ReleaseDC() on a screen DC?

like image 680
Nathan Osman Avatar asked Sep 26 '18 02:09

Nathan Osman


1 Answers

A screen DC is not a class DC, and it's not a private DC, so yes - it needs to be released.

like image 149
Jonathan Potter Avatar answered Nov 08 '22 13:11

Jonathan Potter