timmay3141
Programmer
I have a dialog box and I'm using various Greek letters in static text. The following code works fine in most cases, but when I put it in the OnInitDialog function it doesn't work at all. Instead, I get abnormally large and bold letters instead of the Greek characters I should get. Here's the code I'm using to do try this. m_Coord1, 2, and 3 are CStatic controls mapped to text on the dialog box.
BOOL CCoordsDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CFont fnGreek;
CFont fnNormal;
CDC* pDC = GetDC();
//fnGreek.CreatePointFont(100, "Math1", pDC);
fnNormal.CreatePointFont(80, "MS Sans Serif", pDC);
fnGreek.CreateFont(20, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, SYMBOL_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Times New Roman"
m_Coord1.SetFont(&fnNormal);
m_Coord2.SetFont(&fnGreek);
m_Coord3.SetFont(&fnNormal);
m_Coord1.SetWindowText("r =" // Normal letter r
m_Coord2.SetWindowText("q =" // Greek letter theta
m_Coord3.SetWindowText("z =" // Normal letter z
fnGreek.DeleteObject();
fnNormal.DeleteObject();
ReleaseDC(pDC);
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
I commented out the CreatePointFont line for fnGreek, because I thought CreateFont might work correctly where CreatePointFont does not. It doesn't work any better though. I should also note that q is not theta in this new font (I don't know what character to use for theta in the symbols for Times). I also might be trying to use the symbols of Times incorrectly, because my book gives absolutely no clue as to how this is done, it simply says you can use SYMBOL_CHARSET instead of ASCII_CHARSET. So, if you could tell my why this isn't working, I would appreciate it.
BOOL CCoordsDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CFont fnGreek;
CFont fnNormal;
CDC* pDC = GetDC();
//fnGreek.CreatePointFont(100, "Math1", pDC);
fnNormal.CreatePointFont(80, "MS Sans Serif", pDC);
fnGreek.CreateFont(20, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, SYMBOL_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Times New Roman"
m_Coord1.SetFont(&fnNormal);
m_Coord2.SetFont(&fnGreek);
m_Coord3.SetFont(&fnNormal);
m_Coord1.SetWindowText("r =" // Normal letter r
m_Coord2.SetWindowText("q =" // Greek letter theta
m_Coord3.SetWindowText("z =" // Normal letter z
fnGreek.DeleteObject();
fnNormal.DeleteObject();
ReleaseDC(pDC);
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
I commented out the CreatePointFont line for fnGreek, because I thought CreateFont might work correctly where CreatePointFont does not. It doesn't work any better though. I should also note that q is not theta in this new font (I don't know what character to use for theta in the symbols for Times). I also might be trying to use the symbols of Times incorrectly, because my book gives absolutely no clue as to how this is done, it simply says you can use SYMBOL_CHARSET instead of ASCII_CHARSET. So, if you could tell my why this isn't working, I would appreciate it.