C
C#2y ago
Enenra

❔ WM_FONTCHANGE

Hi, I was recommended to give WM_FONTCHANGE a try yesterday but after reading through mcs docs and watching a video I still have no idea how I'd implement this. https://learn.microsoft.com/en-us/windows/win32/gdi/wm-fontchange https://learn.microsoft.com/en-us/previous-versions/dd398104(v=vs.100) I tried implementing it by pasting somebody else's code but I've failed even at that:
public const int WM_FONTCHANGE = 0x001D;

[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern int SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
void Test()
{
long msg = SendMessage(IntPtr.Zero, WM_FONTCHANGE, IntPtr.Zero, IntPtr.Zero);
MessageBox.Show(msg.ToString());
}
public const int WM_FONTCHANGE = 0x001D;

[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern int SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
void Test()
{
long msg = SendMessage(IntPtr.Zero, WM_FONTCHANGE, IntPtr.Zero, IntPtr.Zero);
MessageBox.Show(msg.ToString());
}
https://stackoverflow.com/questions/19453516/c-sharp-font-able-to-be-used-after-loading I couldn't find where they declared and assigned to HWND_BROADCAST so I passed IntPtr.Zero like I've seen in a youtube video(although it was not related to this function). I am not getting any errors but when I MB.Show(msg.ToString()) it shows 0 and my font isn't updated. There is a possibility that this function is not working but I don't have an idea how I'd test it.
WM_FONTCHANGE message (Winuser.h) - Win32 apps
An application sends the WM_FONTCHANGE message to all top-level windows in the system after changing the pool of font resources.
Stack Overflow
C# font able to be used after loading
I figures out how to load a PS font from C# app, it shows up and is useable in all the app on my system like word, notepad etc. except in my c# app (and of course this is where I needed it). I ne...
2 Replies
Enenra
EnenraOP2y ago
please @ me if you are able to help ok, I've got the whole code completed but it doesn't seem to be working:
public const int WM_FONTCHANGE = 0x001D;

[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern int SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);

void Test()
{
long msg = SendMessage(0xffff, WM_FONTCHANGE, IntPtr.Zero, IntPtr.Zero);
MessageBox.Show(msg.ToString());
}
public const int WM_FONTCHANGE = 0x001D;

[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern int SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);

void Test()
{
long msg = SendMessage(0xffff, WM_FONTCHANGE, IntPtr.Zero, IntPtr.Zero);
MessageBox.Show(msg.ToString());
}
Even after changing the font it stays the same, my approach is working 100% because once I restart the computer or log out and back in it's changed, it's something to do with this if it's what I needed in the first place.
Accord
Accord2y ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server