Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Greek Letters

Status
Not open for further replies.

timmay3141

Programmer
Dec 3, 2002
468
US
I want to make a dialog box where I can enter values for a three dimentional vector, but I want to be able to enter them in either spherical or cylindrical coordinates. I want to put the Greek letters commonly used for these values (rho, phi, theta) before edit boxes. It should look like this, except use actual Greek letters:
_________
rho = |________|

_________
phi = |________|

_________
theta = |________|

So my question is, how can I get Greek letters into static text? I tryed copying and pasting, but it pasted a question mark instead of the Greek letter.
 
Have you looked at doing an "owner-drawn" static text? That way you can specify the "symbol" font in it. Also, I think you can specify the font for any object derived from CWnd.
tellis.gif

[sup]programmer (prog'ram'er), n A hot-headed, anorak wearing, pimple-faced computer geek.[/sup]​
 
Alright, I've got it making Greek letters. It will display the appropriate Greek letters when I click the radio button to spherical or cylindrical coordinates using this code:

void CCoordsDlg::OnRadioCoords()
{
// Draw the appropriate cylindrical coordinate symbols
CFont fnGreek;
CDC* pDC = GetWindowDC();

fnGreek.CreatePointFont(120, "Math1", pDC);
m_Coord2.SetFont(&fnGreek);

m_Coord1.SetWindowText("r ="); // Normal letter r
m_Coord2.SetWindowText("q ="); // Greek letter theta
m_Coord3.SetWindowText("z ="); // Normal letter z

ReleaseDC(pDC);
}

void CCoordsDlg::OnRadioCoords2()
{
// Draw the appropriate spherical coordinate symbols
CFont fnGreek;

CDC* pDC = GetWindowDC();
fnGreek.CreatePointFont(120, "Math1", pDC);

m_Coord1.SetFont(&fnGreek);
m_Coord2.SetFont(&fnGreek);
m_Coord3.SetFont(&fnGreek);

m_Coord1.SetWindowText("r ="); // Greek letter rho
m_Coord2.SetWindowText("f ="); // Greek letter phi
m_Coord3.SetWindowText("q ="); // Greek letter theta

ReleaseDC(pDC);
}

Now when I do the SetWindowText for m_Coord1 or 3 on the first function, it draws it bigger than normal, but I didn't change the font on it. What do I need to do?
 
Try using GetDC() instead of GetWindowDC(). Also, you may want to try using CreateFont() instead of CreatePointFont().
Finally, is "Math1" a standard font? I would have thought "symbol" would be a better choice as this is usually a system font.
tellis.gif

[sup]programmer (prog'ram'er), n A hot-headed, anorak wearing, pimple-faced computer geek.[/sup]​
 
I didn't know that "symbol" was a standard font (I knew there was a symbol font, but I didn't know it was called "symbol"). I looked around in Word for fonts that would let me use the letters, and Math1 let me, so I used it. The problem was simpler than what you mentioned: I simply forgot to tell it to use the default font (MS Sans Serif) when I clicked on the first radio button again.
 
I've got another problem now. Apparently, the OnInitDialog function ignores any call to SetFont. Here's my code:

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);

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

ReleaseDC(pDC);

return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}

It sets the text of m_Coord1, 2, and 3 like it should, but the font isn't Math1 like it should be (I don't know exactly what font it is, but the text size is a lot bigger than it should be too). Any ideas?
 
Have you tried adding TRUE as an extra parameter?

[tt]m_Coord1.SetFont(&fnNormal,TRUE);
[/tt]

Other than that, have you checked the validity of the fonts and the return value from SetFont() in your debugger?
tellis.gif

[sup]programmer (prog'ram'er), n A hot-headed, anorak wearing, pimple-faced computer geek.[/sup]​
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top