Rubrik: Grafik & Zeichnen | 13.07.01 |
DestroyIcon-Funktion Entfernt ein Icon, das zuvor in den Speicher geladen wurde, und gibt die belgten Ressourcen wieder frei. | ||
Betriebssystem: Win95, Win98, WinNT 3.1, Win2000, WinME | Views: 9.922 |
Deklaration:
Declare Function DestroyIcon Lib "user32.dll" (ByVal hIcon As Long) As Long
Beschreibung:
Diese Funktion entfernt ein Icon, das zuvor in den Speicher geladen wurde, und gibt die belgten Ressourcen wieder frei.
Parameter:
hIcon | Erwartet den Handle des Icons, welches aus dem Speicher entfernt werden soll. |
Rückgabewert:
Ist die Funktion erfolgreich so ist der Rückgabewert "ungleich 0" andernfalls ist der Rückgabewert "0". Für erweiterte Fehlerinformationen rufen Sie die GetLastError-Funktion auf.
Beispiel:
Private Declare Function PickIconDlg Lib "shell32.dll" _ Alias "#62" ( _ ByVal hwndOwner As Long, _ ByVal lpstrFile As String, _ ByVal nMaxFile As Long, _ lpdwIconIndex As Long) As Long Private Declare Function ExtractIcon Lib "shell32.dll" _ Alias "ExtractIconA" ( _ ByVal hInst As Long, _ ByVal lpszExeFileName As String, _ ByVal nIconIndex As Long) As Long Private Declare Function DrawIcon Lib "user32" ( _ ByVal hdc As Long, _ ByVal x As Long, _ ByVal y As Long, _ ByVal hIcon As Long) As Long Private Declare Function DestroyIcon Lib "user32" (ByVal hIcon As Long) As Long
' Icon per Dialog wählen und in ein Bildfeld übertragen Private Sub Command1_Click() Dim hIco As Long, TmpIndex As Long, RetVal As Long, TmpIconFile As String * 256 ' Icon-Dialog aufrufen. ' Achtung!!! Unter Windows NT vorher in Unicode Konvertieren TmpIconFile = "c:\windows\system\pifmgr.dll" & vbNullChar RetVal = PickIconDlg(Me.hWnd, TmpIconFile, Len(TmpIconFile), TmpIndex) If RetVal = 0 Then MsgBox "Sie haben kein Icon gewählt", vbOKOnly + vbInformation, _ "Abbrechen" Exit Sub End If ' Extrahieren und Zeichnen hIcon = ExtractIcon(App.hInstance, Left$(TmpIconFile, InStr(1, _ TmpIconFile, vbNullChar) - 1), TmpIndex) Picture1.Cls DrawIcon Picture1.hdc, 0, 0, hIcon Picture1.Refresh DestroyIcon hIcon End Sub