1

I'm trying to develop a simple clock program for a Windows CE 5.0 device in my car, using Visual Studio 2008 professional and C#. I had to use .NET 2.0 since 3.5 doesn't work. The clock program was made as a Form application. It consists of a simple label and a timer, that's it. The clock program works on the device, but I only get a standard font and font-size, no matter what font and size I choose in the label properties in Visual Studio. On my computer the program works fine with several fonts and large font sizes. I can not add anything in the Windows/Font directory on my device since it will be erased after every shut down. It is clear the windows CE version is a totally simplified version with nearly no functions. I guess I have to add the font size in a different way in the program file. How can I do this?

jsanalytics
  • 13,058
  • 4
  • 22
  • 43
Michi
  • 23
  • 5

1 Answers1

1

You can call AddFontResource during your application startup to add additional fonts to the system ones: https://msdn.microsoft.com/en-us/library/ee489896(v=winembedded.60).aspx You can use pinvoke.net (http://www.pinvoke.net/) to find the right declaration to use to import this API in your managed code application.

Valter Minute
  • 2,177
  • 1
  • 11
  • 13
  • I tried namespace test2 { public partial class Test2 : Form { int AddFontResource(LPCTSTR lpszFilename); string filename = @"My Device\FLASH_STORAGE\Font2.FNT"; public Test2() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { label1.ForeColor = Color.FromArgb(155,25,34); label1.Font = new Font("Font2.FNT", 32, FontStyle.Italic); label1.Text = "Hello world!"; – Michi Feb 07 '18 at 22:24
  • I tried the code below but it is not working. Please let me know what is wrong (I'm a beginner) { public partial class Test2 : Form { int AddFontResource(LPCTSTR lpszFilename); string filename = @"My Device\FLASH_STORAGE\Font2.FNT"; public Test2() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { label1.ForeColor = Color.FromArgb(155,25,34); label1.Font = new Font("Font2.FNT", 32, FontStyle.Italic); label1.Text = "Hello world!"; – Michi Feb 07 '18 at 22:31
  • I don't see any actual call to AddFontResource here – Valter Minute Feb 12 '18 at 14:16
  • You are right, I had problems with putting my question here. Please look at the following: https://stackoverflow.com/questions/48674694/how-to-use-addfontresource-in-c-sharp-for-windows-ce-5-0-application-with-net-2 – Michi Feb 15 '18 at 10:34
  • Ok, but it's not a good idea to post multiple questions on the same topic. People searching for answers will be confused. – Valter Minute Feb 18 '18 at 10:33