SendMessage, fonts

2

2G

Hi everybody

I think i'm doing something wrong . :)

When I install a new font, all my programs (like photoshop) that are running
don't respond anymore for like 2 min, after that I can use the font whitout
restarting the applications but I can not delete the font untill i reboot my
pc (i tried killing all processes but that didn't work).

If anyone would take a look , I do the following :

[DllImport("user32.dll", CharSet=CharSet.Auto)] static extern IntPtr
SendMessage(IntPtr hwnd, int msg, int wParam, int lParam);



private const int HWND_BROADCAST = 0xffff;

private const int WM_FONTCHANGE = 0x001D;



private void cmdInstall_Click(object sender, System.EventArgs e){

clsFontFamily f = (clsFontFamily)cboFonts.SelectedItem;

string n = f.Path.Substring(f.Path.LastIndexOf("\\")+1);

File.Copy(f.Path, iPath + "\\" + n, false);

SendMessage((System.IntPtr)HWND_BROADCAST, WM_FONTCHANGE, 0, 0);

int i = AddFontResource(iPath + "\\" + n);

}



Thx in advance.
 
S

Stoitcho Goutsev \(100\) [C# MVP]

Hi 2G,
Probably you should notify after adding the font to the fornt resource pool.
Have you tried to change places of SendMessage and AddFontResource calls.
 
2

2G

Yep, did that but with the same result.

Grtz.

Stoitcho Goutsev (100) said:
Hi 2G,
Probably you should notify after adding the font to the fornt resource pool.
Have you tried to change places of SendMessage and AddFontResource calls.

--
HTH
B\rgds
100
2G said:
Hi everybody

I think i'm doing something wrong . :)

When I install a new font, all my programs (like photoshop) that are running
don't respond anymore for like 2 min, after that I can use the font whitout
restarting the applications but I can not delete the font untill i
reboot
my
pc (i tried killing all processes but that didn't work).

If anyone would take a look , I do the following :

[DllImport("user32.dll", CharSet=CharSet.Auto)] static extern IntPtr
SendMessage(IntPtr hwnd, int msg, int wParam, int lParam);



private const int HWND_BROADCAST = 0xffff;

private const int WM_FONTCHANGE = 0x001D;



private void cmdInstall_Click(object sender, System.EventArgs e){

clsFontFamily f = (clsFontFamily)cboFonts.SelectedItem;

string n = f.Path.Substring(f.Path.LastIndexOf("\\")+1);

File.Copy(f.Path, iPath + "\\" + n, false);

SendMessage((System.IntPtr)HWND_BROADCAST, WM_FONTCHANGE, 0, 0);

int i = AddFontResource(iPath + "\\" + n);

}



Thx in advance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top