how to get HDC from a CDC object in MFC

how can I get the HDC from a CDC object. I know it is storing in
m_hDC, but how to get the HDC. help please. Thanks
eugenengAsked:
Who is Participating?
 
chensuConnect With a Mentor Commented:
CDC dc;

...

HDC hdc = dc.GetSafeHdc();

or

HDC hdc = dc.m_hDC;

0
 
eugenengAuthor Commented:
right i'm calling an outside library function that require HDC as a parameter. i think the code you gave me is correct, but when i call the function with hdc be the parameter, after complied, it give me unresolve external symbol. the outside function i called want a traditional window HDC but i gave MFC hdc, are they compatible.
0
 
chensuCommented:
The unresolve external symbol has nothing to do with HDC. There must be other problems. HDC is a handle of device context. Only given an HDC, you cannot tell whether it is from MFC or not.
0
 
eugenengAuthor Commented:
thanks chensu

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.