Hi,
i'd like to change font size more times...
in the constructor of my class, I create the font with a normal size.
m_mytitlefont.CreateFont(....);
After that, the program begin to start and the text will be drawn with this initial font.
Then, it could be possible that the user will change the font size, also more than one time.
I'd like to use m_mytilefont, the variable created before, but this is problem.
I use this function:
int SetFontSize(int pixelHeight)
{
LOGFONT lf;
CClientDC dc(this);
CFont *currentFont = dc.GetCurrentFont();
currentFont->GetLogFont(&lf);
LOGFONT lfNew = lf;
lfNew.lfHeight = pixelHeight;
currentFont->DeleteObject();
currentFont->CreateFontIndirect(&lfNew);
currentFont->CreateObject();
dc.SelectObject(currentFont);
return pixelHeight;
}
but when I do >>dc.SelectObject(currentFont);
the program crash...
How is it possible to reutilize the font created in the constructor?
Thank you.
i'd like to change font size more times...
in the constructor of my class, I create the font with a normal size.
m_mytitlefont.CreateFont(....);
After that, the program begin to start and the text will be drawn with this initial font.
Then, it could be possible that the user will change the font size, also more than one time.
I'd like to use m_mytilefont, the variable created before, but this is problem.
I use this function:
int SetFontSize(int pixelHeight)
{
LOGFONT lf;
CClientDC dc(this);
CFont *currentFont = dc.GetCurrentFont();
currentFont->GetLogFont(&lf);
LOGFONT lfNew = lf;
lfNew.lfHeight = pixelHeight;
currentFont->DeleteObject();
currentFont->CreateFontIndirect(&lfNew);
currentFont->CreateObject();
dc.SelectObject(currentFont);
return pixelHeight;
}
but when I do >>dc.SelectObject(currentFont);
the program crash...
How is it possible to reutilize the font created in the constructor?
Thank you.