Transparente VB-Form mit Ausnahme

Hi Leute!

Ich stehe vor einem Rätsel:

Ich möchte unter Visual Basic 6 eine Form (BorderStyle: 0) transparent machen (das klappt ja), aber auf der Form ist noch ein transparentes Label und wenn ich die Form transparent mache, wird auch der Inhalt des Labels durchsichtig...

Wie macht man es, dass von der ganzen Form nur die
Schrift des Labels zu sehen ist?

Würde mich freuen, wenns jemand rauskriegt.

Thanks.
 
BorderStyle: 0 schaltet normalerweise nur sen Fensterstyle auf nichts und setzt nicht die Tranzperenz. Da Musste man was komplieziertes per Timer und Fensterhandle machen. Aber wenns bei dir geht ?(
 
Naja,
die Transparenz hab' ich ja per API-Funktion hingekriegt, aber ich will, dass der Inhalt des Labels als einziges nicht transparent ist.
 
Poste mal deinen Code (also den tranzparenz teil)

p.s. Sorry ich hatte dich mit dem border style falsch verstanden
 
Das hier kommt in ein Modul:
Code:
Option Explicit

Declare Function GetWindowLong Lib "user32.dll" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Declare Function SetWindowLong Lib "user32.dll" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Declare Function SetLayeredWindowAttributes Lib "user32.dll" (ByVal hWnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long

Public Const GWL_EXSTYLE = (-20)
Public Const WS_EX_LAYERED = &H80000

'Macht nur eine Farbe transparent
'Public Const LWA_COLORKEY = &H1

'Macht das ganze Fenster transparent
Public Const LWA_ALPHA = &H2

Public Sub Mache_Transparent(hWnd As Long, Rate As Byte)

    Dim WinInfo As Long
    
    WinInfo = GetWindowLong(hWnd, GWL_EXSTYLE)
    
    If Rate < 255 Then
        WinInfo = WinInfo Or WS_EX_LAYERED
        SetWindowLong hWnd, GWL_EXSTYLE, WinInfo
        SetLayeredWindowAttributes hWnd, 0, Rate, LWA_ALPHA
    Else
        'Wenn als Rate 255 angegeben wird,
        'so wird der Ausgangszustand wiederhergestellt
        WinInfo = WinInfo Xor WS_EX_LAYERED
        SetWindowLong hWnd, GWL_EXSTYLE, WinInfo
    End If
End Sub

Und das hier macht die Form transparent:
Code:
Call Mache_Transparent(Me.hWnd, 128)

PS: Dieser Source kommt von ActiveVB.de
 
Hab lange ncht mehr Vb gecodet aber so müsste es gehen:
Ist nen Workaround(Sezt die Hintergrungfarbe auf tranzperent)
Kann es aber nicht testen
Änderungen zu Orginal sind fett

Code:
Option Explicit

Declare Function GetWindowLong Lib "user32.dll" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Declare Function SetWindowLong Lib "user32.dll" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Declare Function SetLayeredWindowAttributes Lib "user32.dll" (ByVal hWnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long

Public Const GWL_EXSTYLE = (-20)
Public Const WS_EX_LAYERED = &H80000

'Macht nur eine Farbe transparent
[B]Public Const LWA_COLORKEY = Me.BackColor[/B]

'Macht das ganze Fenster transparent
Public Const LWA_ALPHA = &H2

Public Sub Mache_Transparent(hWnd As Long, Rate As Byte)

    Dim WinInfo As Long
    
    WinInfo = GetWindowLong(hWnd, GWL_EXSTYLE)
    
    If Rate < 255 Then
        WinInfo = WinInfo Or WS_EX_LAYERED
        SetWindowLong hWnd, GWL_EXSTYLE, WinInfo
        SetLayeredWindowAttributes hWnd, 0, Rate, [B]LWA_COLORKEY[/B]
    Else
        'Wenn als Rate 255 angegeben wird,
        'so wird der Ausgangszustand wiederhergestellt
        WinInfo = WinInfo Xor WS_EX_LAYERED
        SetWindowLong hWnd, GWL_EXSTYLE, WinInfo
    End If
End Sub
 
Is schon mal eine gute Idee, aber hier hat er das Problem, das die Backcolor-Eigenschaft nicht zum Me-Objekt passt:

Code:
'Macht nur eine Farbe transparent
Public Const LWA_COLORKEY = [U]Me[/U].BackColor
 
Zurück
Oben