(added more stuff )
Howdy'
Small question regarding SelectObject (mosly the Win32 one, not the CDC one).
I'm reviewing a large piece of code that draws text and we query the text metrix after calling SelectObject( fontHandle) but we never keep the old object and never restore the old handle:
(1)
{
::SelectObject( validHDC, validHFONT );
}
normally I'm used to seeing seomthing like
(2)
void f{)
{
HFONT oldFont = ::SelectObject( validHDC, validHFONT );
::SelectObject( validHDC, oldFont);
}
Will that cause a lot of issues (resource leaks and/or performance) if I do (1) instead of (2) when there are gazillion SelectObject in the code ?
and finally, what is the preferred way to do it when I have multiple SelectObject in the same function? do I only need to keep the old handle for the first
SelectObject
and reset it at the end ?
void f{)
{
HFONT oldFont = ::SelectObject( validHDC, validHFONT );
::SelectObject( validHDC, anotherHFONT );
::SelectObject( validHDC, thirdHFONT );
::SelectObject( validHDC, fourthHFONT );
::SelectObject( validHDC, oldFont);
}
Thanks.
Max.