Hallo HarryLobster,
transparent zeichnen kann BltBit nur über den Umweg mit einer
Schwarz-Weiß-Maske. Mit einem Std-Picture wird es wahrscheinlich
auch nicht funktionieren, weil die Variable nur den Handle aus
der Imagelist übernimmt und dort läßt sich der Handle auch nicht
über eine selbsterzeugte DC ansprechen. Du könntest beim Programm-
start einmalig alle Icons von der Imagelist in eine Picturebox
übertragen und diese dann mit TransparentBlt in die sichtbare
Grafik zeichnen. Hier mal ein Ansatz:
Controls: Button, ImageList, 2 * Picturebox
Private Declare Function TransparentBlt Lib "msimg32.dll" (ByVal hdcDest As _
Long, _
ByVal nXOriginDest As Long, ByVal nYOriginDest As Long, ByVal nWidthDest As _
Long, ByVal nHeightDest As Long, _
ByVal hDCSrc As Long, ByVal nXOriginSrc As Long, ByVal nYOriginSrc As Long, _
ByVal nWidthSrc As Long, _
ByVal nHeightSrc As Long, ByVal crTransparent As Long) As Long
Private Mask&, maxX&, maxY&, N&, SW&, SH&, ImgH&, ImgW&
Private Sub Form_Load()
Dim i&, x1&, y1&
Me.ScaleMode = vbPixels
Me.WindowState = vbMaximized
Randomize
Mask = RGB(255, 0, 128)
With ImageList1
N = .ListImages.Count
ImgW = .ImageWidth
ImgH = .ImageHeight
.BackColor = Mask
End With
If N = 0 Then
MsgBox "Keine Icons!", vbExclamation + vbOKOnly
Unload Me
Exit Sub
End If
maxX = Int(0.5 + Sqr(N))
maxY = -Int(-(N / maxX))
With Picture2
.Visible = False
.BorderStyle = vbBSNone
.ScaleMode = vbPixels
.Move 8, 8, maxX * ImgW, maxY * ImgH
.AutoRedraw = True
For i = 1 To N
ImageList1.ListImages(i).Draw .hDC, ImgW * x1, ImgH * y1
x1 = (x1 + 1) Mod maxX
If x1 = 0 Then y1 = y1 + 1
Next i
End With
SW = 1024
SH = 768
With Picture1
.BorderStyle = vbBSNone
.ScaleMode = vbPixels
.Move 8, 8, SW, SH
.AutoRedraw = True
End With
Command1.TabIndex = 0
Command1.Caption = "Zeichne"
Command1.Move SW + 16, 8
Call Command1_Click
End Sub
Private Sub Command1_Click()
Dim i&, Pos&, x1&, y1&, P1hdc&, P2hdc&
P1hdc = Picture1.hDC
P2hdc = Picture2.hDC
Picture1.Line (0, 0)-(SW, SH), RGB(0, 0, 64), BF
For i = 1 To 200
Pos = Int(Rnd * N)
x1 = (Pos Mod maxX) * ImgW
y1 = (Pos \ maxX) * ImgH
Call TransparentBlt(P1hdc, Rnd * (SW - ImgW), Rnd * (SH - ImgH), ImgW, _
ImgH, _
P2hdc, x1, y1, ImgW, ImgH, Mask)
Next i
End Sub Gruss,
Zardoz |