Results 1 to 15 of 15

Thread: BUG: Transparent Label on Transparent Control Does Not Display

  1. #1

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    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

  2. #2
    Fanatic Member laserman's Avatar
    Join Date
    Jan 2002
    Location
    Wales U.K
    Posts
    775
    Hi Woka,

    Tried this before and its difficult as I remember.

    This is a piece of code that you may be to implement,its for a form normally

    See if its any use to you.

    Cheers
    Attached Files Attached Files

  3. #3

  4. #4

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632
    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:
    1. Private Declare Function GetWindowLong Lib "User32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
    2. Private Declare Function SetWindowLong Lib "User32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    3. Private Declare Function SetLayeredWindowAttributes Lib "User32" (ByVal hwnd As Long, ByVal crey As Byte, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
    4. Private Const GWL_EXSTYLE = (-20)
    5. Private Const WS_EX_LAYERED = &H80000
    6. Private Const LWA_ALPHA = &H2&
    7.  
    8. Private Sub Command1_Click()
    9. Dim LEVEL As Byte
    10.     LEVEL = 120
    11.     Call SetWindowLong(Me.hwnd, GWL_EXSTYLE, GetWindowLong(Me.hwnd, GWL_EXSTYLE) Or WS_EX_LAYERED)
    12.     Call SetLayeredWindowAttributes(Me.hwnd, 0, LEVEL, LWA_ALPHA)
    13. End Sub
    Simple alpha bending code.

    Will try it oooot.

    MS Sucks.

  5. #5

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632
    Doesn't work
    It sets ALL controls that are in the container to be 100% transparent too...not just the background...

    Arrrghhhh...transparent label on transparent usercontrol MUST be a serious bug!!! How the hell are you supposed to create decent usercontrols

    Arrrghhhh.....

    Woof

  6. #6
    Fanatic Member laserman's Avatar
    Join Date
    Jan 2002
    Location
    Wales U.K
    Posts
    775
    Seems like it Woka.

    Will have a look through some old code samples I had on Transparent and see if we can nail the sucker.

    Cheers

  7. #7
    Fanatic Member laserman's Avatar
    Join Date
    Jan 2002
    Location
    Wales U.K
    Posts
    775
    Woka,

    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

    Cheers

  8. #8

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632
    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.

    This really sucks.

    Cheers for helping.

    Woof

  9. #9
    Fanatic Member laserman's Avatar
    Join Date
    Jan 2002
    Location
    Wales U.K
    Posts
    775
    Got ya, oh well lets see how thing go.

    Cheers

  10. #10
    PowerPoster
    Join Date
    Jul 2002
    Location
    Dublin, Ireland
    Posts
    2,148
    Are you prepared to eschew the label control in favour of some hairy CreateWindowEx() ...windows style is WS_STATIC type behaviour?

  11. #11

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632
    I tried replacing the label by drawing text, using API, onto the control, but since it's background is transparent then it doesn't show up

    What do you have in mind?

    Woka

  12. #12
    PowerPoster
    Join Date
    Jul 2002
    Location
    Dublin, Ireland
    Posts
    2,148
    There's a short answer and a long answer to this:

    Short answer: use a TrueType font in your label.

    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...

  13. #13
    PowerPoster
    Join Date
    Jul 2002
    Location
    Dublin, Ireland
    Posts
    2,148
    Did it work?

  14. #14
    New Member
    Join Date
    May 2007
    Posts
    11

    Re: BUG: Transparent Label on Transparent Control Does Not Display

    Is there any solution for that bug?

  15. #15

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: BUG: Transparent Label on Transparent Control Does Not Display

    This is an old thread. eeek.
    I am afraid I can'r even remember asking this question
    Which also means I can't work out if I got it working

    Woka

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width