Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get an HDC object from a CDC object?

Tags:

c++

windows

mfc

cdc

I have an object, dc, of type CDC and I'd like to get an HDC object.

I read the MSDN documentation here, but don't really understand it.

Can someone provide me with a brief example/explanation on how to do this?

like image 440
samoz Avatar asked Aug 05 '09 16:08

samoz


People also ask

How do I find my HDC CDC?

Just assign it. CDC cdc = something. HDC hdc = cdc; if (hdc != 0) { //success... }

What is CDC * pDC?

Interferon-producing plasmacytoid dendritic cells (pDC) are a specialized branch of the dendritic cell (DC) family, and their differentiation in mice is closely linked to that of conventional DC (cDC).

What is CDC in mfc?

MFC provides a class called CDC that encapsulates a HDC, which is a handle to a Windows device context object. All operations with a device context should be made through such such a CDC object.

What is MFC HDC?

HDC is the data type for a device context handle.


1 Answers

When you have CDC object it will be implicitly converted to HDC when necessary:

CDC dc;
HDC hdc = dc; // HDC hdc = dc.operator HDC();

If you have pointer to CDC object then using function GetSafeHdc will look more clear:

CDC* pdc = SOME;
HDC hdc = pdc->GetSafeHdc();
like image 133
Kirill V. Lyadvinsky Avatar answered Sep 17 '22 22:09

Kirill V. Lyadvinsky