public void SetFont(Font font) { var lf = new LogFont(); font.ToLogFont(lf); lf.lfPitchAndFamily = FIXED_PITCH | FF_MODERN; NativeMethods.SendMessage(hIMEWnd, (int) WindowMessage.WM_IME_CONTROL, IMC_SETCOMPOSITIONFONT, lf); }
public ICollection EnumFonts() { var bmp = new Bitmap(10, 10); Graphics g = Graphics.FromImage(bmp); IntPtr hDC = g.GetHdc(); Fonts = new Hashtable(); var lf = new LogFont {lfCharSet = 1}; FONTENUMPROC callback = CallbackFunc; Alsing.Windows.NativeMethods.EnumFontFamiliesEx(hDC, lf, callback, 0, 0); g.ReleaseHdc(hDC); g.Dispose(); bmp.Dispose(); return Fonts.Keys; }
public void SetFont(string fontname, float fontsize) { var tFont = new LogFont { lfItalic = 0, lfStrikeOut = 0, lfUnderline = 0, lfWeight = 400, lfWidth = 0, lfHeight = ((int) (-fontsize*1.3333333333333)), lfCharSet = 1, lfPitchAndFamily = (FIXED_PITCH | FF_MODERN), lfFaceName = fontname }; LogFont lf = tFont; NativeMethods.SendMessage(hIMEWnd, (int) WindowMessage.WM_IME_CONTROL, IMC_SETCOMPOSITIONFONT, lf); }
protected void Init(string fontname, float size, bool bold, bool italic, bool underline, bool strikethrough) { FontName = fontname; Size = size; Bold = bold; Italic = italic; Underline = underline; Strikethrough = strikethrough; var tFont = new LogFont { lfItalic = ((byte) (Italic ? 1 : 0)), lfStrikeOut = ((byte) (Strikethrough ? 1 : 0)), lfUnderline = ((byte) (Underline ? 1 : 0)), lfWeight = (Bold ? 700 : 400), lfWidth = 0, lfHeight = ((int) (-Size*1.3333333333333)), lfCharSet = 1, lfFaceName = FontName }; hFont = NativeMethods.CreateFontIndirect(tFont); }
public static extern int SendMessage(IntPtr hWnd, int msg, int wParam, LogFont lParam);