Font.ToHfont Metodo
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Restituisce un handle per questo Font.
public:
IntPtr ToHfont();
public IntPtr ToHfont();
member this.ToHfont : unit -> nativeint
Public Function ToHfont () As IntPtr
nativeint
Handle di Windows per questo Font.
Operazione non riuscita.
Nell'esempio di codice seguente viene creato un Font e quindi viene creato un handle per tale Font. L'esempio è progettato per l'uso con Windows Form e richiede PaintEventArgse
, che è un parametro del gestore eventi Paint.
//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.
[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 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
Quando si usa questo metodo, è necessario eliminare i Hfont
risultanti usando il metodo di DeleteObject
GDI per assicurarsi che le risorse vengano rilasciate.
Prodotto | Versioni |
---|---|
.NET | 8 (package-provided), 9 (package-provided), 10 (package-provided) |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0 (package-provided) |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9, 10 |
Feedback su .NET
.NET è un progetto di open source. Selezionare un collegamento per fornire feedback: