Results 1 to 17 of 17

Thread: how to make a label box transparent

  1. #1

    Thread Starter
    Frenzied Member maged's Avatar
    Join Date
    Nov 2002
    Location
    Egypt
    Posts
    1,040

    how to make a label box transparent

    dear all,

    I am making my first software application using dot net ( VB) after using old versions of VB for 5 years. so i am a little bit experienced.


    what i want to do is very simple, I want to use a label box with transparent background.

    We usually do it in vb6 with backstyle property.

    Likely it is not found here.

    Could anyone tell me how to do it.

    THX in advance

  2. #2
    Junior Member
    Join Date
    Apr 2004
    Posts
    19
    click the label control and look in the property sheet, the backcolor property has a transparency setting
    www.mod2software.com
    Home of the VB.NET Class Builder Utility - Demo and Full versions available now!

  3. #3
    Junior Member
    Join Date
    Nov 2004
    Location
    Philippines
    Posts
    27

    Thumbs up Re: how to make a label box transparent

    Insert a Panel control in your form having transparent backcolor.

    Place a Label inside the panel and the label will be transparent.

  4. #4
    Lively Member
    Join Date
    Nov 2004
    Posts
    73

    Re: how to make a label box transparent

    Hi Oreo,

    The way you suggest that put the label on one panel seems doesn't work. What I want to do is put one label on one picturebox and same times make the label transparent, not to block the picture.

    Thanks for help in advance.

    Robert

  5. #5
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    Re: how to make a label box transparent

    search the codebank
    wossname made a transparent label control
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  6. #6
    Junior Member
    Join Date
    Nov 2004
    Location
    Philippines
    Posts
    27

    Re: Try this

    What i did was i set the background image of the form itself with the picture, and added a panel control having the same size of the form - transparent backcolor, then added labels inside the panel.

  7. #7
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: how to make a label box transparent

    Quote Originally Posted by MrPolite
    search the codebank
    wossname made a transparent label control
    Ahemmm, its was a joint effort.

    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  8. #8
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: how to make a label box transparent

    I was never satisfied with that transparent label, too jaggy. Irrevocably jaggy in fact, no way to smooth it. Worked better with big fonts.
    I don't live here any more.

  9. #9
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    Re: how to make a label box transparent

    Quote Originally Posted by RobDog888
    Ahemmm, its was a joint effort.

    ah that rat never admitted it
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  10. #10
    Fanatic Member
    Join Date
    May 2005
    Posts
    898

    Re: how to make a label box transparent

    Quote Originally Posted by wossname
    I was never satisfied with that transparent label, too jaggy. Irrevocably jaggy in fact, no way to smooth it. Worked better with big fonts.
    Is that because you couldn't use anti-aliasing because the region was limited to the string?
    "so just keep in mind that fantasy is not the same as realtiy and make sure u remember that wii sports may be fun but u cant count on it as exercise ok cool bye" - HungarianHuman

  11. #11
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: how to make a label box transparent

    Antialiasing can not be used with the GraphicsPath class, but I believe now that wossy has figured out a way to include antialiasing but not on a label, just direct draw so may be hard for design time viewing.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  12. #12
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: how to make a label box transparent

    Not entirely correct guys...

    * You can use Antialiasing with GraphicsPaths and any kind of drawing (except PathGradientbrushes for some reason).

    * You cannot use Antialiasing at the edges of regions because a region is defined by a hard edge of pixels, there is nowhere to put the interpolated pixels.

    Quote Originally Posted by grilkip
    Is that because you couldn't use anti-aliasing because the region was limited to the string?
    The thing about creating a region form a curvy text outline, is that it takes a smooth curve and makes it jaggy.

    You can use antialiasing on graphicspaths, but not when the region you are paint on is the same shape, the antialiased pixels fall off the edges and you can't tell the difference anyway because you are left with the jagged pixel edge of the region.

    Rob, have you tried inheriting from the Panel class? That might be easier than using regions. I have not tried it yet. Might be worth a look. If you do, let me know how you get on.
    I don't live here any more.

  13. #13
    Fanatic Member
    Join Date
    May 2005
    Posts
    898

    Re: how to make a label box transparent

    Quote Originally Posted by wossname
    Not entirely correct guys...

    You can use antialiasing on graphicspaths, but not when the region you are paint on is the same shape, the antialiased pixels fall off the edges and you can't tell the difference anyway because you are left with the jagged pixel edge of the region.
    Maybe I didn't put right but that is in fact what I meant.
    "so just keep in mind that fantasy is not the same as realtiy and make sure u remember that wii sports may be fun but u cant count on it as exercise ok cool bye" - HungarianHuman

  14. #14
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: how to make a label box transparent

    wossname, I have done tons of inheriting of the Panel control in classes and I'm sick of it. You remember my Panel usercontrol? Probably will be starting back on it. almost done. But yes, inheriting a panel and then drawing on it may be better since you can make a panel truely transparent.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  15. #15
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489

    Re: how to make a label box transparent

    I haven't seen the code for the control in the code bank..Is it using an overriden OnPaint method?

  16. #16
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    Re: how to make a label box transparent

    btw have you guys tried setting the Region property of the control to the visible text's region?
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  17. #17
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: how to make a label box transparent

    Quote Originally Posted by MrPolite
    btw have you guys tried setting the Region property of the control to the visible text's region?
    Yes, thats what the "joint-effort" was all about. Didn't work well. It was pseudotransparent... The text was solid but the rest of the control simply didn't exist, thus letting the background show through. Not pretty to look at but it was quite cool. Strangely, this made the font a few percent smaller than the original font was declared as, not sure why, couldn't find a way to fix that either.

    We also tried hiding the control, taking a screenshot of the underlying pixels, re-showing the control again and blitting back the pixels on top. Then antialiasing our text on top of that! That didn't work either because it flickered like crazy and was dead slow to refresh. Then I got bored of debugging API functions and gave up until now.
    I don't live here any more.

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