CFont clean-up
-
Hi, Please can you tell me the correct way to perform clean-up operation for a
Cfont
object? I use this in OnInitDialog() :CFont *m_pTitleFont = new CFont;
m_pTitleFont->CreateFont(25,0,0,0,800,0,0,0,0,0,0,ANTIALIASED_QUALITY,0,"Verdana");s_Title.SetFont(m_pTitleFont);
s_Title is a CStatic object. I use different font types for different Static controls. So I am usually creating three-four fonts. Thanks.
_
Fortitudine Vincimus!_
-
Hi, Please can you tell me the correct way to perform clean-up operation for a
Cfont
object? I use this in OnInitDialog() :CFont *m_pTitleFont = new CFont;
m_pTitleFont->CreateFont(25,0,0,0,800,0,0,0,0,0,0,ANTIALIASED_QUALITY,0,"Verdana");s_Title.SetFont(m_pTitleFont);
s_Title is a CStatic object. I use different font types for different Static controls. So I am usually creating three-four fonts. Thanks.
_
Fortitudine Vincimus!_
Tara14 wrote:
can you tell me the correct way to perform clean-up operation for a Cfont object?
How about delete m_pTitleFont; ? Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
-
Tara14 wrote:
can you tell me the correct way to perform clean-up operation for a Cfont object?
How about delete m_pTitleFont; ? Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
-
I wonder if the
CFont
destructor calls theDeleteObject
method, does it?If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
CPallini wrote:
the CFont destructor calls the DeleteObject method, does it?
Not directly. ~CGdiObject() does though. Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
-
I wonder if the
CFont
destructor calls theDeleteObject
method, does it?If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
You can look in the source and find out.....
Steve
-
CPallini wrote:
the CFont destructor calls the DeleteObject method, does it?
Not directly. ~CGdiObject() does though. Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
OK, thanks! :-D BTW this MS sample made me wondering about [^], since they explicitely call
CFont::DeleteObject
.If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
-
You can look in the source and find out.....
Steve
What an empirical boy!:-D Do you suggest to take sources as references? They're of course, for the current release... and..what if MS changes mind over time? :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
-
What an empirical boy!:-D Do you suggest to take sources as references? They're of course, for the current release... and..what if MS changes mind over time? :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
CPallini wrote:
Do you suggest to take sources as references? They're of course, for the current release... and..what if MS changes mind over time?
They are not going to change something like. They can hardly make the class not clean up the resources when it previously did of vice versa.
Steve
-
CPallini wrote:
Do you suggest to take sources as references? They're of course, for the current release... and..what if MS changes mind over time?
They are not going to change something like. They can hardly make the class not clean up the resources when it previously did of vice versa.
Steve
Stephen Hewitt wrote:
They can hardly make the class not clean up the resources when it previously did of vice versa.
I agree on the above observation, of course.:) I don't agree on the method, of course.:-D
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
-
Stephen Hewitt wrote:
They can hardly make the class not clean up the resources when it previously did of vice versa.
I agree on the above observation, of course.:) I don't agree on the method, of course.:-D
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
CPallini wrote:
I don't agree on the method, of course.
In a perfect world the documentation would be complete and answer all your questions. In the real world this is not always the case and you often need to find your answers elsewhere. In such situations a mixture of common sense and a peek at source code often save the day. This is just life in the trenches.
Steve
-
CPallini wrote:
I don't agree on the method, of course.
In a perfect world the documentation would be complete and answer all your questions. In the real world this is not always the case and you often need to find your answers elsewhere. In such situations a mixture of common sense and a peek at source code often save the day. This is just life in the trenches.
Steve
-
OK, thanks! :-D BTW this MS sample made me wondering about [^], since they explicitely call
CFont::DeleteObject
.If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
CPallini wrote:
BTW this MS sample made me wondering about
That's cool. The OP created his/hers with new so I chose delete as an idea :) For a local object, DeleteObject is great to free the HGDIOBJ when you no longer need it. When the CFont goes out of scope, it will be freed as well. Cheers! Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder