[英]C# - How to Determine a Form's Title bar font?
我想創建一個足以顯示標題欄字符串的窗體,該窗體是動態的。 要計算字符串的文本寬度,我需要知道標題欄字體。 如何查詢?
您可以使用SystemFonts.CaptionFont
屬性:
獲取用於在窗口標題欄中顯示文本的字體。
用法示例:
using System.Drawing;
var font = SystemFonts.CaptionFont;
以下似乎是等效的powershell:
function Get-CaptionFont {
$font_family = ([Windows.SystemFonts]::"CaptionFontFamily").Source
$font_size = [Windows.SystemFonts]::"CaptionFontSize"
return New-Object System.Drawing.Font($font_family, $font_size, [System.Drawing.FontStyle]"Regular")
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.