private Font GetCaptionFont() { NONCLIENTMETRICS ncm = new NONCLIENTMETRICS(); ncm.cbSize = Marshal.SizeOf(typeof(NONCLIENTMETRICS)); try { bool result = SystemParametersInfo(SPI_GETNONCLIENTMETRICS, ncm.cbSize, ref ncm, 0); if (result) { return(Font.FromLogFont(ncm.lfCaptionFont)); } else { int lastError = Marshal.GetLastWin32Error(); return(null); } } catch (Exception /*ex*/) { //System.Console.WriteLine(ex.Message); } return(null); }
/// <summary> /// Discover the current system default font for menu items. /// </summary> /// <returns>A Font instance.</returns> private Font GetSystemMenuFont() { NONCLIENTMETRICS metrics = new NONCLIENTMETRICS(); metrics.cbSize = Marshal.SizeOf(typeof(NONCLIENTMETRICS)); try { bool result = SystemParametersInfo( SPI_GETNONCLIENTMETRICS, metrics.cbSize, ref metrics, 0); if (result) { return(Font.FromLogFont(metrics.lfMenuFont)); } else { var lastError = Marshal.GetLastWin32Error(); return(null); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } return(null); }
public NonClientMetrics() { this.win32Struct = GetSystemParameters(); this.MenuFont = new LogFont(win32Struct.lfMenuFont); this.StatusFont = new LogFont(win32Struct.lfStatusFont); this.MessageFont = new LogFont(win32Struct.lfMessageFont); this.CaptionFont = new LogFont(win32Struct.lfCaptionFont); this.SmallCaptionFont = new LogFont(win32Struct.lfSmCaptionFont); }
public static NONCLIENTMETRICS SystemParameterInfo_GetNONCLIENTMETRICS() { NONCLIENTMETRICS result = Utility.IsOSVistaOrNewer ? NONCLIENTMETRICS.VistaMetricsStruct : NONCLIENTMETRICS.XPMetricsStruct; if (!NativeMethods._SystemParametersInfo_NONCLIENTMETRICS(SPI.GETNONCLIENTMETRICS, result.cbSize, ref result, SPIF.None)) { HRESULT.ThrowLastError(); } return(result); }
public static NONCLIENTMETRICS GetWindowsNonClientMetrics() { var _ncm = new NONCLIENTMETRICS(); if (SystemParametersInfo(SPI_GETNONCLIENTMETRICS, _ncm.cbSize, _ncm, 0)) { return(_ncm); } return(null); }
private static Settings SetValues(NONCLIENTMETRICS metrics, ICONMETRICS iconmetrics) { var settings = new Settings(); settings.CaptionFontSize = metrics.lfCaptionFont.lfHeight; settings.SecondarytitlebarSize = metrics.lfSmCaptionFont.lfHeight; settings.MenuSize = metrics.lfMenuFont.lfHeight; settings.MessageBoxSize = metrics.lfMessageFont.lfHeight; settings.StatusbarSize = metrics.lfStatusFont.lfHeight; settings.BorderSize = metrics.iBorderWidth; settings.IconCaptionSize = iconmetrics.lfFont.lfHeight; return(settings); }
private NONCLIENTMETRICS GetSystemParameters() { NONCLIENTMETRICS win32Struct = new NONCLIENTMETRICS(); win32Struct.cbSize = Marshal.SizeOf(win32Struct); bool result = SystemParametersInfo(uiActions.SPI_GETNONCLIENTMETRICS, win32Struct.cbSize, ref win32Struct, 0); if (!result) { throw new System.ComponentModel.Win32Exception(); } return(win32Struct); }
public static extern bool SystemParametersInfo(uint action, uint intParam, ref NONCLIENTMETRICS metrics, uint update);
private static extern bool SystemParametersInfo(int uiAction, int uiParam, ref NONCLIENTMETRICS ncMetrics, int fWinIni);
public static void SetWindowsNonClientMetrics(NONCLIENTMETRICS metrics) { SystemParametersInfo(SPI_SETNONCLIENTMETRICS, 0, metrics, 3); }
public static extern bool SystemParametersInfoA(uint uiAction, uint uiParam, ref NONCLIENTMETRICS pvParam,uint fWinIni);
internal static extern int SystemParametersInfo(int uAction, int uParam, ref NONCLIENTMETRICS lpvParam, int fuWinIni);
private Font GetCaptionFont() { NONCLIENTMETRICS ncm = new NONCLIENTMETRICS(); ncm.cbSize = Marshal.SizeOf(typeof(NONCLIENTMETRICS)); try { bool result = SystemParametersInfo(SPI_GETNONCLIENTMETRICS, ncm.cbSize, ref ncm, 0); if(result) { return Font.FromLogFont(ncm.lfCaptionFont); } else { int lastError = Marshal.GetLastWin32Error(); return null; } } catch(Exception /*ex*/) { //System.Console.WriteLine(ex.Message); } return null; }
private static extern bool _SystemParametersInfo_NONCLIENTMETRICS(SPI uiAction, int uiParam, [In][Out] ref NONCLIENTMETRICS pvParam, SPIF fWinIni);
/// <summary> /// Discover the current system default font for menu items. /// </summary> /// <returns>A Font instance.</returns> private Font GetSystemMenuFont() { NONCLIENTMETRICS metrics = new NONCLIENTMETRICS(); metrics.cbSize = Marshal.SizeOf(typeof(NONCLIENTMETRICS)); try { bool result = SystemParametersInfo( SPI_GETNONCLIENTMETRICS, metrics.cbSize, ref metrics, 0); if (result) { return Font.FromLogFont(metrics.lfMenuFont); } else { int lastError = Marshal.GetLastWin32Error(); return null; } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } return null; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Gets the Windows system font. /// </summary> /// ------------------------------------------------------------------------------------ public static Font GetCaptionFont() { NONCLIENTMETRICS ncm = new NONCLIENTMETRICS(); ncm.cbSize = Marshal.SizeOf(typeof(NONCLIENTMETRICS)); try { bool result = SystemParametersInfo(SPI_GETNONCLIENTMETRICS, ncm.cbSize, ref ncm, 0); //int lastError = Marshal.GetLastWin32Error(); return (result ? Font.FromLogFont(ncm.lfCaptionFont) : null); } catch { } return null; }
// TODO-Linux: Implement if needed public static bool SystemParametersInfo(int uiAction, int uiParam, ref NONCLIENTMETRICS ncMetrics, int fWinIni) { return true; }
public static extern bool SystemParametersInfo(int uiAction, int uiParam, [In, Out] NONCLIENTMETRICS pvParam, int fWinIni);