Vielen Dank für die Antwort.
Leider blicke ich durch GDI+ noch nicht ganz durch!
Hier die LoadPic Funktion des Moduls:
Public Function LoadPic(Optional ByVal FileName As String, _
Optional ByVal Size As Variant, _
Optional ByVal ColorDepth As Variant, _
Optional ByVal x As Variant, _
Optional ByVal y As Variant, _
Optional ByRef Meldung As String, _
Optional ByVal LoadPicture_Erlaubt As Boolean = False, _
Optional ByVal BitmapPerGDIPLUS As Boolean = False) As StdPicture
' Ersatzfunktion für VB.Loadpicture
Dim ext As String ' Datei-Extension
Dim ext4 As String
Dim con As GdiPlusConnection ' GDIPlus einrichten
Dim GDI_Connection As Long
Dim Retcode As Long
Dim lp As Boolean ' VB.LoadPicture verwenden?
On Error GoTo fehler
Meldung = ""
Set LoadPic = Nothing
FileName = Trim(FileName)
' Löschfunktion von VB.Loadpicture ?
If FileName = "" Then
Set LoadPic = VB.LoadPicture()
Exit Function
End If
If Len(FileName) < 5 Then
Meldung = "Ungeeigneter Dateiname"
Exit Function
End If
' Datei vorhanden?
If Dir$(FileName, vbNormal Or vbReadOnly Or vbHidden) = "" Then
Meldung = "Datei nicht vorhanden/verfügbar"
Exit Function
End If
' Leere / kurze Datei ?
If FileLen(FileName) < 10 Then
Meldung = "Leere Datei"
Exit Function
End If
' File-Typ checken
ext = Right$(LCase$(FileName), 4)
ext4 = Right$(LCase$(FileName), 5)
' geeignetes Verfahren für Bildformat festlegen
If ext = ".bmp" Or ext = ".dib" Or ext = ".rle" Then
If BitmapPerGDIPLUS Then
lp = False ' GDIPLUS für Bitmaps verlangt
Else
lp = True ' Bitmaps per VB.Loadpicturey
End If
ElseIf ext = ".ico" Or ext = ".cur" _
Or ext = ".emf" Or ext = ".wmf" Then
lp = True ' stets VB.Loadpicture verwenden
ElseIf ext = ".gif" Or ext = ".png" _
Or ext = ".tif" Or ext4 = ".tiff" _
Or ext = ".jpe" Or ext = ".jpg" Or _
ext4 = ".jpeg" Or ext4 = ".jfif" Then
lp = False ' GDIPLUS verwenden
Else
Meldung = "Bildformat wird nicht unterstützt"
Exit Function
End If
' GDIPLus erforderlich oder angefordert?
If Not lp Then
' GDIPlus vorhanden ?
' Initialisierung durchführen
con.GdiplusVersion = 1
Retcode = 18
On Error Resume Next
Retcode = GdiplusStartup(GDI_Connection, con)
If Retcode <> 0 Then
If Not LoadPicture_Erlaubt Then
Meldung = "Initialisierung scheitert" + _
vbCrLf + GDIPLUS_Fehler(Retcode)
' GDIPLUS nicht verfügbar
Exit Function
Else
lp = True ' VB.Loadpicture verwenden
End If
End If
On Error GoTo fehler
End If
' Bild laden
If lp Then
' Dateiname verweist auf
'( Bitmap), (Enh)Metafile, Icon oder Cursor
' oder:
' GDIPlus fehlt
' ---> VB.Loadpicture verwenden
Set LoadPic = VB.LoadPicture(FileName, Size, ColorDepth, x, y)
If LoadPic Is Nothing Then
Meldung = "Laden des Bildes scheitert (Loadpicture)"
End If
Else
' Dateiname verweist auf ein komprim. Bildformat
' oder Bitmap falls gewünscht
' ---> GDIPlus verwenden
' Die LoadPicture-Parameter für Icons/Cursor
' werden hier nícht beachtet
Set LoadPic = iLoadPic(FileName, Meldung)
End If
' Wichtig: GDIPlus nach Gebrauch freigeben
' sonst droht IDE-Absturz
If GDI_Connection <> 0 Then
GdiplusShutdown GDI_Connection
End If
Exit Function
fehler:
Meldung = Err.Description
If GDI_Connection <> 0 Then
GdiplusShutdown GDI_Connection
End If
End Function Und so lade ich die Bilder. Leider funktioniert die Transparenz trotzdem nicht.
.PaintPicture LoadPic(sFile), 0, 0, nWidth, nHeight ' HIntergrund
.PaintPicture LoadPic("E:\Eigene Dateien\test.png"), 0, 0 'Text Mfg Baret |