BUG: Transparent Label on Transparent Control Does Not Display
I have create a user control.
I require the background to be transparent.
If I do this then I can't have a label on my control with a thransparent backgorund...it just disappears at design time.
When editing the usercontrol. I can seethe l;abel, but once dropped onto a form it vanishes.
Also, I can't use the DarwText API on a transparent control
Not happy.
Woof
Last edited by Wokawidget; Sep 24th, 2004 at 08:30 AM.
I see.
U mean set the usercontrols backcolor to be transparent at runtime...
The code you posted, that was messed up in the txt file was:
VB Code:
Private Declare Function GetWindowLong Lib "User32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "User32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetLayeredWindowAttributes Lib "User32" (ByVal hwnd As Long, ByVal crey As Byte, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Private Const GWL_EXSTYLE = (-20)
Private Const WS_EX_LAYERED = &H80000
Private Const LWA_ALPHA = &H2&
Private Sub Command1_Click()
Dim LEVEL As Byte
LEVEL = 120
Call SetWindowLong(Me.hwnd, GWL_EXSTYLE, GetWindowLong(Me.hwnd, GWL_EXSTYLE) Or WS_EX_LAYERED)
What if you leave the Usercontrol backstyle to Opaque and then add the label to it and make that transparent but make sure the label is the same size as the usercontrol background that will work won,t it or am i missing something.
Because if you add a normal label and set the backstyle to transparent you get the same result at runtime
No. That doesn't work.
You will only see the background of the usercontrol.
So if you have a pic on the usercontrol then this will not be blocked by the label...well it's text obviously, but not it's grey background.
That's why I need the usercontrol to be transparent also, since I have a pic on my form.
Long answer: The way that lightweight controls are implemented on transparent usercontrols is a bit ropey- it relies on the usercontrol creating a clipping region for them then drawing the lightweight controls onto their respective clipped area using the standard TextOut type API.
Unfortunately TextOut does not add to a path for non TrueType fonts...