You are here:

C++/Destruction of CDC class

Advertisement


Question
Hi again, Zlatko.

I am working on a VC++6 Graph program that analyses the contents of a file.

When the user clicks anywhere on the graph, text comes up with identifying information regarding that location within the file.

I'm using: CDC* pDC = this->GetDC(); as a constructor since OnLMouseDown won't accept another argument(I think it's called 'overloading') CDC* pDC within its parentheses. Then of course, I add the code to make the text visible on the graph.

My problem is that I don't know what to use as a destructor for the CDC class. I'm currently using 'this->ReleaseDC(pDC)', but is this sufficient?

Thank you for taking your time to read, analyze and answer my note,
-Neil

Answer
Hello Neil. I'm not really experienced in this part of MFC, but according to the msdn documentation, a release is all that is necessary. The GetDC is not really a constructor, it just gets the window's device context, so it would be incorrect to delete the DC. Have a look at
http://msdn.microsoft.com/en-us/library/71eseab0%28VS.80%29.aspx
There is some information about when a DC should not be released. I would test the program with releasing, and if there are no problems, keep it in.

Sorry that I could not give you a more definite answer. Try posting your question to an MFC forum.

Best regards
Zlatko

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


Zlatko

Expertise

No longer taking questions.

Experience

No longer taking questions.

Education/Credentials
No longer taking questions.

©2012 About.com, a part of The New York Times Company. All rights reserved.