Font.FromHfont メソッドとは? わかりやすく解説

Font.FromHfont メソッド

指定した Windows ハンドルから Font作成します

名前空間: System.Drawing
アセンブリ: System.Drawing (system.drawing.dll 内)
構文構文

Public Shared Function FromHfont
 ( _
    hfont As IntPtr _
) As Font
Dim hfont As IntPtr
Dim returnValue As Font

returnValue = Font.FromHfont(hfont)
public static Font FromHfont (
    IntPtr hfont
)
public:
static Font^ FromHfont (
    IntPtr hfont
)
public static Font FromHfont (
    IntPtr hfont
)
public static function FromHfont
 (
    hfont : IntPtr
) : Font

パラメータ

hfont

GDI フォント識別する Windows ハンドル

戻り値
このメソッド作成する Font

使用例使用例

次の例は、Windows フォームでの使用意図してデザインされており、Paint イベント ハンドラパラメータである PaintEventArgse が必要です。このコード次のアクション実行します

<System.Runtime.InteropServices.DllImportAttribute("GDI32.DLL")>
 _
Private Shared Function
 GetStockObject(ByVal fnObject As Integer)
 As IntPtr
End Function
Public Sub FromHfont_Example(ByVal
 e As PaintEventArgs)

    ' Get a handle for a GDI font.
    Dim hFont As IntPtr = GetStockObject(0)

    ' Create a Font object from hFont.
    Dim hfontFont As Font = Font.FromHfont(hFont)

    ' Use hfontFont to draw text to the screen.
    e.Graphics.DrawString("This font is from a GDI HFONT",
 hfontFont, _
    Brushes.Black, 0, 0)
End Sub
[System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")]
private static extern IntPtr GetStockObject(int
 fnObject);
public void FromHfont_Example(PaintEventArgs
 e)
{
             
    // Get a handle for a GDI font.
    IntPtr hFont = GetStockObject(0);
             
    // Create a Font object from hFont.
    Font hfontFont = Font.FromHfont(hFont);
             
    // Use hfontFont to draw text to the screen.
    e.Graphics.DrawString(
        "This font is from a GDI HFONT", hfontFont,Brushes.Black, 
        0, 0);
       
        
        
        
}
private:
   [System::Runtime::InteropServices::DllImportAttribute("gdi32.dll")]
   static IntPtr GetStockObject( int fnObject
 );

public:
   void FromHfont_Example( PaintEventArgs^ e )
   {
      // Get a handle for a GDI font.
      IntPtr hFont = GetStockObject( 0 );

      // Create a Font object from hFont.
      System::Drawing::Font^ hfontFont = System::Drawing::Font::FromHfont( hFont
 );

      // Use hfontFont to draw text to the screen.
      e->Graphics->DrawString( "This font is from a GDI HFONT", hfontFont,
 Brushes::Black, 0, 0 );
   }
/** @attribute System.Runtime.InteropServices.DllImportAttribute(
    "gdi32.dll")
 */
private static native IntPtr GetStockObject(int
 fnObject);

public void FromHfont_Example(PaintEventArgs
 e)
{
    // Get a handle for a GDI font.
    IntPtr hFont = GetStockObject(0);

    // Create a Font object from hFont.
    Font hfontFont = Font.FromHfont(hFont);

    // Use hfontFont to draw text to the screen.
    e.get_Graphics().DrawString("This font is from a GDI HFONT", hfontFont
,
        Brushes.get_Black(), 0, 0);
} //FromHfont_Example
.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からFont.FromHfont メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からFont.FromHfont メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からFont.FromHfont メソッド を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

Font.FromHfont メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Font.FromHfont メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS