internal static Font FromLogFont(ref Interop.User32.LOGFONT logFont) { using (ScreenDC dc = ScreenDC.Create()) { return(FromLogFont(logFont, dc)); } }
/// <summary> /// Creates a <see cref="Font"/> from the given LOGFONT using the screen device context. /// </summary> /// <param name="lf">A boxed LOGFONT.</param> /// <returns>The newly created <see cref="Font"/>.</returns> public static Font FromLogFont(object lf) { using (ScreenDC dc = ScreenDC.Create()) { return(FromLogFont(lf, dc)); } }
internal static Font FromLogFont(ref SafeNativeMethods.LOGFONT logFont) { using (ScreenDC dc = ScreenDC.Create()) { return(FromLogFont(logFont, dc)); } }
public float GetHeight() { using (ScreenDC dc = ScreenDC.Create()) using (Graphics graphics = Graphics.FromHdcInternal(dc)) { return(GetHeight(graphics)); } }
public void ToLogFont(object logFont) { using (ScreenDC dc = ScreenDC.Create()) using (Graphics graphics = Graphics.FromHdcInternal(dc)) { ToLogFont(logFont, graphics); } }
/// <summary> /// Creates a <see cref='Font'/> from the specified Windows handle. /// </summary> public static Font FromHfont(IntPtr hfont) { Interop.User32.LOGFONT logFont = default; Interop.Gdi32.GetObject(new HandleRef(null, hfont), ref logFont); using (ScreenDC dc = ScreenDC.Create()) { return(FromLogFontInternal(ref logFont, dc)); } }
/// <summary> /// Creates a <see cref='Font'/> from the specified Windows handle. /// </summary> public static Font FromHfont(IntPtr hfont) { var logFont = new SafeNativeMethods.LOGFONT(); SafeNativeMethods.GetObject(new HandleRef(null, hfont), ref logFont); using (ScreenDC dc = ScreenDC.Create()) { return(FromLogFontInternal(ref logFont, dc)); } }
/// <summary> /// Returns a handle to this <see cref='Font'/>. /// </summary> public IntPtr ToHfont() { using (ScreenDC dc = ScreenDC.Create()) using (Graphics graphics = Graphics.FromHdcInternal(dc)) { Interop.User32.LOGFONT lf = ToLogFontInternal(graphics); IntPtr handle = Interop.Gdi32.CreateFontIndirectW(ref lf); if (handle == IntPtr.Zero) { throw new Win32Exception(); } return(handle); } }
/// <summary> /// Returns a handle to this <see cref='Font'/>. /// </summary> public IntPtr ToHfont() { using (ScreenDC dc = ScreenDC.Create()) using (Graphics graphics = Graphics.FromHdcInternal(dc)) { SafeNativeMethods.LOGFONT lf = ToLogFontInternal(graphics); IntPtr handle = IntUnsafeNativeMethods.CreateFontIndirect(ref lf); if (handle == IntPtr.Zero) { throw new Win32Exception(); } return(handle); } }