I need to call DeleteObject on CFont

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

CFont* oldFont = label.GetFont(); LOGFONT 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.

+4
source share
1 answer

No no. Classes MFC RAII classes. When an object goes out of scope (i.e. deconstructed), the object will be deleted accordingly.

+3
source

All Articles