Font.ToHfont メソッド
アセンブリ: System.Drawing (system.drawing.dll 内)
構文
Dim instance As Font Dim returnValue As IntPtr returnValue = instance.ToHfont
この Font を識別する Windows ハンドル。
解説
使用例
Font を作成し、その Font を識別するハンドルを取得するコード例を次に示します。この例は、Windows フォームでの使用を意図してデザインされており、Paint イベント ハンドラのパラメータである PaintEventArgse が必要です。
' Reference the DeleteObject method in the GDI library. <System.Runtime.InteropServices.DllImportAttribute("GDI32.DLL")> _ Private Shared Function DeleteObject(ByVal objectHandle As IntPtr) As Boolean End Function Public Sub ToHfont_Example(ByVal e As PaintEventArgs) ' Create a Font object. Dim myFont As New Font("Arial", 16) ' Get a handle to the Font object. Dim hFont As IntPtr = myFont.ToHfont() ' Display a message box with the value of hFont. MessageBox.Show(hFont.ToString()) ' Dispose of the hFont. DeleteObject(hFont) End Sub
//Reference the GDI DeleteObject method. [System.Runtime.InteropServices.DllImport("GDI32.dll")] public static extern bool DeleteObject(IntPtr objectHandle); public void ToHfont_Example(PaintEventArgs e) { // Create a Font object. Font myFont = new Font("Arial", 16); // Get a handle to the Font object. IntPtr hFont = myFont.ToHfont(); // Display a message box with the value of hFont. MessageBox.Show(hFont.ToString()); //Dispose of the hFont. DeleteObject(hFont); }
//Reference the GDI DeleteObject method. public: [System::Runtime::InteropServices::DllImport("GDI32.dll")] static bool DeleteObject( IntPtr objectHandle ); void ToHfont_Example( PaintEventArgs^ /*e*/ ) { // Create a Font object. System::Drawing::Font^ myFont = gcnew System::Drawing::Font( "Arial",16 ); // Get a handle to the Font object. IntPtr hFont = myFont->ToHfont(); // Display a message box with the value of hFont. MessageBox::Show( hFont.ToString() ); //Dispose of the hFont. DeleteObject( hFont ); }
//Reference the GDI DeleteObject method. /** @attribute System.Runtime.InteropServices.DllImport("GDI32.dll") */ public static native boolean DeleteObject(IntPtr objectHandle); public void ToHfont_Example(PaintEventArgs e) { // Create a Font object. Font myFont = new Font("Arial", 16); // Get a handle to the Font object. IntPtr hFont = myFont.ToHfont(); // Display a message box with the value of hFont. MessageBox.Show(hFont.ToString()); //Dispose of the hFont. DeleteObject(hFont); } //ToHfont_Example
- SecurityPermission (アンマネージ コードへのアクセスに必要なアクセス許可)。UnmanagedCode (関連する列挙体)
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
- Font.ToHfont メソッドのページへのリンク