public NonClientMetrics(NONCLIENTMETRICS AData) { this.Data = AData; this.CaptionFontFamily = AData.lfCaptionFont.lfFaceName; // returns negative, sometimes this.CaptionFontSize = System.Math.Abs(AData.lfCaptionFont.lfHeight); }
static extern bool SystemParametersInfo(int action, int intParam, ref NONCLIENTMETRICS metrics, int update);
public static bool readMetrics(out NonClientMetrics thisMetrics) { bool Result = false; /* out */ thisMetrics = null; NONCLIENTMETRICS metrics = new NONCLIENTMETRICS(); metrics.cbSize = Marshal.SizeOf(metrics); Result = SystemParametersInfo( SPI_GETNONCLIENTMETRICS, 0, ref metrics, 0); // nota: "SystemParametersInfo" con "CharSet.Unicode", // y "LOGFONT" y "LOGFONT" con "CharSet.Auto", es el que funciona if (Result) { thisMetrics = new NonClientMetrics(metrics); } return Result; }