Logfont Structure

23/07/2008 - 15:36 von D. Blocher | Report spam
Hi,

I got different values in the Logfont Structure when I create it ouf of a C#
Font that I get back from that FontDialog or create it out of a C++
CFontDialog. Same Font, same Attributes. What is different there? Is there
any solution?

C# Code

private void buttonSelectFont_Click(object sender, EventArgs e)
{
FontDialog dlg = new FontDialog();

dlg.Font = selectedFont;

if (DialogResult.OK == dlg.ShowDialog())
{
textBoxFontInformation.Text = dlg.Font.ToString();

pointSize = Convert.ToInt32(dlg.Font.SizeInPoints);
selectedFont = dlg.Font;

LOGFONT myLogFont = new LOGFONT();

selectedFont.ToLogFont(myLogFont);
}
}


C++

void CDemoAppDlg::OnBnClickedButtonSelectFont()
{
// create the standard font dialog
CFontDialog fontDlg( &m_logfont, CF_TTONLY | CF_SCREENFONTS );
if ( IDOK != fontDlg.DoModal() )
{
return;
}

// clear logfont structure
ZeroMemory( &m_logfont, sizeof (m_logfont) );
// and get the selected logfont structure
fontDlg.GetCurrentFont( &m_logfont );

m_pointSize = fontDlg.m_cf.iPointSize;

CString tmpString;
tmpString.Format( _T( "%s - %d pt" ), m_logfont.lfFaceName, m_pointSize /
10 );
c_editFontName.SetWindowText( tmpString );
}
 

Lesen sie die antworten

#1 Herfried K. Wagner [MVP]
23/07/2008 - 17:38 | Warnen spam
"D. Blocher" <D. schrieb:
I got different values in the Logfont Structure when I create it ouf of a
C#
Font that I get back from that FontDialog or create it out of a C++
CFontDialog. Same Font, same Attributes. What is different there? Is there
any solution?



Worin unterscheiden sich die beiden 'LOGFONT'-Werte?

M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Ähnliche fragen