Kan det lade sig gøre, at lave en transparent picturebox, hvis ja, hvordan?
Ja, sagtens!
Den nemmeste måde at lave den transparent på, er ved at bitblt'e til den, fra baggrunden!
Så som noget i denne stil :
(Lav et nyt projekt, og i form1 laver du en picturebox (picture1), samt nogle objekter (bag ved picturebox'en).. Så du kan se at den er transparent!
Du skan også lige have en "timer1" med interval 500, og enabled!
(Paste så denne kode!) :
Option Explicit
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Private messages(10) As String
Private H As Long
Private Y As Long
Private Sub Form_Load()
Dim I As Long
messages(0) = "Dette er en Trasparent picturebox"
messages(1) = "Som du kan se, har jeg lagt selve"
messages(2) = "paint koden ind i formens paint runtime."
messages(3) = "dette vil KUN virke, hvis formens autoredraw"
messages(4) = "er slået fra"
messages(5) = "Men, nu kan du jo selv lege lidt med det!"
messages(6) = "Her er noget du kan starte med, som giver"
messages(7) = "en ide om, hvordan det evt. kan gøres !"
messages(8) = ""
messages(9) = "Hilsen"
messages(10) = "Brian Bergh (Duplex) www.gdsoftware.dk"
For I = 0 To UBound(messages)
H = H + Picture1.TextHeight(messages(I))
Next
Y = Picture1.ScaleHeight / 2 - H / 2
End Sub
Private Sub Form_Paint()
Dim BD As Long
BD = IIf(Picture1.BorderStyle = 1, 2, 0)
Picture1.Visible = False
DoEvents
BitBlt Picture1.hDC, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, hDC, (Picture1.Left / Screen.TwipsPerPixelX) + BD, (Picture1.Top / Screen.TwipsPerPixelY) + BD, vbSrcCopy
Picture1.Visible = True
End Sub
Private Sub Timer1_Timer()
Static M As Long
M = M + 1
If M > UBound(messages) + 1 Then
Timer1.Interval = 500
M = 1
Picture1.Cls
Y = Picture1.ScaleHeight / 2 - H / 2
End If
Picture1.CurrentX = Picture1.ScaleWidth / 2 - Picture1.TextWidth(messages(M - 1)) / 2
Picture1.CurrentY = Y
Y = Y + Picture1.TextHeight("X")
Picture1.Print messages(M - 1)
If M = UBound(messages) + 1 Then
Timer1.Enabled = False
Timer1.Interval = 0
Timer1.Interval = 4000
Timer1.Enabled = True
End If
End Sub
Good luck !
/Duplex