Example #1
0
        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);
        }
Example #2
0
        /// <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);
        }
Example #3
0
 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);
 }
Example #4
0
    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);
    }
Example #5
0
        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);
        }
Example #7
0
        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);
        }
Example #8
0
 public static extern bool SystemParametersInfo(uint action, uint intParam, ref NONCLIENTMETRICS metrics, uint update);
Example #9
0
 private static extern bool SystemParametersInfo(int uiAction, int uiParam,
                                                 ref NONCLIENTMETRICS ncMetrics, int fWinIni);
Example #10
0
 public static void SetWindowsNonClientMetrics(NONCLIENTMETRICS metrics)
 {
     SystemParametersInfo(SPI_SETNONCLIENTMETRICS, 0, metrics, 3);
 }
Example #11
0
	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);
Example #13
0
		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;
		}
Example #14
0
 private static extern bool _SystemParametersInfo_NONCLIENTMETRICS(SPI uiAction, int uiParam, [In][Out] ref NONCLIENTMETRICS pvParam, SPIF fWinIni);
Example #15
0
        /// <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;
        }
Example #16
0
		/// ------------------------------------------------------------------------------------
		/// <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;
		}
Example #17
0
		// TODO-Linux: Implement if needed
		public static bool SystemParametersInfo(int uiAction, int uiParam,
			ref NONCLIENTMETRICS ncMetrics, int fWinIni)
		{
			return true;
		}
Example #18
0
		private static extern bool SystemParametersInfo(int uiAction, int uiParam,
			ref NONCLIENTMETRICS ncMetrics, int fWinIni);
Example #19
0
 public static extern bool SystemParametersInfo(int uiAction, int uiParam, [In, Out] NONCLIENTMETRICS pvParam, int fWinIni);