Bitmap.FromHicon(IntPtr) Metodo
Definizione
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.
Crea un oggetto Bitmap da un handle di Windows per un'icona.
public:
static System::Drawing::Bitmap ^ FromHicon(IntPtr hicon);
public static System.Drawing.Bitmap FromHicon (IntPtr hicon);
static member FromHicon : nativeint -> System.Drawing.Bitmap
Public Shared Function FromHicon (hicon As IntPtr) As Bitmap
Parametri
- hicon
-
IntPtr
nativeint
Handle per un'icona.
Restituisce
Oggetto Bitmap creato con questo metodo.
Esempio
L'esempio di codice seguente è progettato per l'uso con Windows Forms e richiede PaintEventArgse
, che è un parametro del Paint gestore eventi. Il codice esegue le azioni seguenti:
Ottiene l'handle per un'immagine di icona esistente.
Crea un Bitmap oggetto dall'handle.
Disegna l'oggetto Bitmap sullo schermo.
private:
[System::Runtime::InteropServices::DllImportAttribute("user32.dll", CharSet = CharSet::Unicode)]
static IntPtr LoadImage( int Hinstance, String^ name, int type, int width, int height, int load );
private:
void Hicon_Example( PaintEventArgs^ e )
{
// Get a handle to an icon.
IntPtr Hicon = LoadImage( 0, "smile.ico", 1, 0, 0, 16 );
// Create a Bitmap object from the icon handle.
Bitmap^ iconBitmap = Bitmap::FromHicon( Hicon );
// Draw the Bitmap object to the screen.
e->Graphics->DrawImage( iconBitmap, 0, 0 );
}
[System.Runtime.InteropServices.DllImportAttribute("user32.dll", CharSet = CharSet.Unicode)]
private static extern IntPtr LoadImage(int Hinstance,
string name, int type, int width, int height, int load);
private void Hicon_Example(PaintEventArgs e)
{
// Get a handle to an icon.
IntPtr Hicon = LoadImage(0, "smile.ico", 1, 0, 0, 16);
// Create a Bitmap object from the icon handle.
Bitmap iconBitmap = Bitmap.FromHicon(Hicon);
// Draw the Bitmap object to the screen.
e.Graphics.DrawImage(iconBitmap, 0, 0);
}
<System.Runtime.InteropServices.DllImportAttribute("user32.dll", CharSet:=CharSet.Unicode)> _
Private Shared Function LoadImage(ByVal Hinstance As Integer, ByVal name As String, ByVal type As Integer, ByVal width As Integer, ByVal height As Integer, ByVal load As Integer) As IntPtr
End Function
Private Sub HICON_Example(ByVal e As PaintEventArgs)
' Get a handle to an icon.
Dim Hicon As IntPtr = LoadImage(0, "smile.ico", 1, 0, 0, 16)
' Create a Bitmap object from the icon handle.
Dim iconBitmap As Bitmap = Bitmap.FromHicon(Hicon)
' Draw the Bitmap object to the screen.
e.Graphics.DrawImage(iconBitmap, 0, 0)
End Sub
Si applica a
Commenti e suggerimenti
https://aka.ms/ContentUserFeedback.
Presto disponibile: Nel corso del 2024 verranno gradualmente disattivati i problemi di GitHub come meccanismo di feedback per il contenuto e ciò verrà sostituito con un nuovo sistema di feedback. Per altre informazioni, vedereInvia e visualizza il feedback per