I'm trying to develop a Smart Device program for Windows CE 5.0 device in my car with Visual Stdio 2008 pro and c# with .NET 2.0. I want to add a font using AddFontResourceEx, but I can't get it to work. Here is the code:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private const uint FR_PRIVATE=0x10;
[DllImport("GDI32.dll",EntryPoint="AddFontResourceEx")]
static extern int AddFontResourceEx(string lpszFilename, uint fl, IntPtr pdv);
private void button1_Click(object sender, EventArgs e)
{
AddFontResourceEx(".\\ELEPHNT.TTF", FR_PRIVATE, IntPtr.Zero);
label1.ForeColor = Color.FromArgb(155, 25, 34);
label1.Font = new Font("ELEPHNT.TTF", 18, FontStyle.Regular);
label1.Text = "Hello world!";
}
}
It builds succesfully and I can run the program, but the font won't change. I added the font file to the same directory where the program is. Could you please tell me what is wrong?