开发者

Do I need to call DeleteObject on CFont

开发者 https://www.devze.com 2023-01-21 05:33 出处:网络
I was wondering, do I need to call DeleteObject in the following case? CFont* oldFont = label.GetFont();

I was wondering, do I need to call DeleteObject in the following case?

CFont* oldFont = label.GetFont();
L开发者_JAVA百科OGFONT oldLogFont;
oldFont->GetLogFont(&oldLogFont);
oldLogFont.lfWeight = FW_BOLD;
CFont newFont;
newFont.CreateFontIndirectW(&oldLogFont);
label.SetFont(&newFont, true);
// Do I need to call oldFont->DeleteObject() or newFont->DeleteObject()?

Thanks.


No you don't. MFC classes are RAII classes. When the object drops out of scope (ie gets deconstructed) the object will be deleted appropriately.

0

精彩评论

暂无评论...
验证码 换一张
取 消