Groupbox and transparent background
Groupbox and transparent background
Groupbox and transparent background
Groupbox and transparent background
Groupbox and transparent background
Groupbox and transparent background Groupbox and transparent background Groupbox and transparent background Groupbox and transparent background Groupbox and transparent background Groupbox and transparent background Groupbox and transparent background Groupbox and transparent background
Groupbox and transparent background Groupbox and transparent background
Groupbox and transparent background
Go Back  Xtreme Visual Basic Talk > > > Groupbox and transparent background


Reply
 
Thread Tools Display Modes
  #1  
Old 02-07-2009, 03:37 PM
3dkingpin 3dkingpin is offline
Junior Contributor
 
Join Date: Feb 2008
Posts: 256
Default Groupbox and transparent background


on the form i have a groupbox with a few textboxes and labels inside of it. Behind the group box i have a picturebox image. I want this image to be seen around the textboxs etc.. through the groupbox

Ive tried changing the background colour in the properties to transparent but you can still see the background colour and so the groupbox covers up the picture.

I want the background of the groupbox to be completely transparent.

can it be done?
__________________
Hey, Looking for entry level job in VB net programming. Got basic qualification, years of programming experience (mainly self taught) and good portfolio. (UK)
Reply With Quote
  #2  
Old 02-08-2009, 04:34 AM
Goggy's Avatar
Goggy Goggy is offline
Contributor
 
Join Date: Sep 2005
Location: Enschede,The Netherlands
Posts: 670
Default

i think the backcolor of a groupbox can be set to transparent... its just one of its properties.
__________________
As finishing touch, god created the Dutch!

utterly useless, but always trying to help
Reply With Quote
  #3  
Old 02-08-2009, 05:05 AM
3dkingpin 3dkingpin is offline
Junior Contributor
 
Join Date: Feb 2008
Posts: 256
Default

i tried that
__________________
Hey, Looking for entry level job in VB net programming. Got basic qualification, years of programming experience (mainly self taught) and good portfolio. (UK)
Reply With Quote
  #4  
Old 02-09-2009, 10:14 AM
AtmaWeapon's Avatar
AtmaWeaponGroupbox and transparent background AtmaWeapon is offline
Fabulous Florist

Forum Leader
* Guru *
 
Join Date: Feb 2004
Location: Austin, TX
Posts: 9,500
Default

Transparency doesn't behave like you'd expect in Windows Forms controls. They behave like normal controls in the Windows API and assume that every control "owns" its rectangular region of the form; originally transparency wasn't supported at all so overlapping controls made no sense. Because of this, Windows was able to optimize drawing transparent regions by simply drawing the background of the window. Somewhere around Win2k the concept of "layered windows" allowed controls to be transparent and show the controls beneath them; for a control to be a layered window you have to set some flags when it's created. Bob Powell explains this well in his transparent Windows Forms controls article.
__________________
.NET Resources
My FAQ threads | Tutor's Corner | Code Library
I would bet money 2/3 of .NET questions are already answered in one of these three places.
Reply With Quote
  #5  
Old 02-09-2009, 12:51 PM
Under Study Under Study is offline
Regular
 
Join Date: Jul 2008
Posts: 83
Default

Hey, from the sound of it, i think we are having the same problem. If you find anything out let me know, i will be more then happy to post anything i find.
Reply With Quote
  #6  
Old 02-09-2009, 08:29 PM
3dkingpin 3dkingpin is offline
Junior Contributor
 
Join Date: Feb 2008
Posts: 256
Default

Quote:
protected override CreateParams CreateParams

{

get

{

CreateParams cp=base.CreateParams;

cp.ExStyle|=0x00000020; //WS_EX_TRANSPARENT

return cp;

}

}
how does that translate to vb.net 2008

do you have to set a value to createparams. I dont know. Bobo powells code isnt related to vb.net although im sure (maybe) the principles may be similar
__________________
Hey, Looking for entry level job in VB net programming. Got basic qualification, years of programming experience (mainly self taught) and good portfolio. (UK)
Reply With Quote
  #7  
Old 02-10-2009, 10:24 AM
AtmaWeapon's Avatar
AtmaWeaponGroupbox and transparent background AtmaWeapon is offline
Fabulous Florist

Forum Leader
* Guru *
 
Join Date: Feb 2004
Location: Austin, TX
Posts: 9,500
Default

You're suffering from a mysterious malady that affects VB .NET programmers; I call it curlyphobia. For some reason, long-time VB programmers get the idea in their head that they can't read anything that isn't VB. This is particularly silly in VB .NET , where both languages use the same runtime and thus the same method calls. I guarantee that if you are at least an intermediate VB .NET programmer and you spend an hour reading basic C# tutorials, you'll know both C# and VB .NET.

Anyway, here's the translation, followed by a discussion of the concepts that don't translate directly:
Code:
Protected  ReadOnly Overrides Property CreateParams As CreateParams
    Get
        Dim cp As CreateParams = MyBase.CreateParams
        cp.ExStyle = cp.ExStyle Or &H20
        Return cp
    End Get
End Property
Here's the parts that require basic knowledge of C#; this should help you in the future when you encounter:
  • |= is a shortcut operator that is equivalent to:
    lhs = lhs | value
    What does | do? Search for C# operators and you'll find that it's logical OR, equivalent to the VB .NET Or operator.
  • 0x00000020: this is how hexadecimal numbers are denoted in practically every language but VB. Google can answer this, and it's usually near the beginning of C# tutorials.
Give C# a chance; 75% of the online examples I find are in C# so you're only hurting yourself if you don't learn it at a basic level

*edit* I read "ComboBox" where you said "GroupBox"; the below paragraph is invalid. ComboBox is really frustrating; I don't think GroupBox is going to be so bad.


That aside, I'm not sure how well it's going to work for the ComboBox. I tried it with PictureBox in Under Study's thread, and it seems that tacking transparency onto the basic Windows Forms controls might be impractical if at all possible. I do know that transparency works as expected in the WPF. This leads me to believe your best options are to either use WPF or implement a custom ComboBox control (though I'm going to experiment with the ComboBox later; I have a crazy idea.)

*edit* I just tried it with a derived GroupBox and it worked; as I pointed out in the last thread, most of the time setting the Opaque control style is required:
Code:
Public Class MyGroupBox
    Inherits GroupBox

    Protected Overrides ReadOnly Property CreateParams() As CreateParams
        Get
            Dim cp As CreateParams = MyBase.CreateParams
            cp.ExStyle = cp.ExStyle Or &H20
            Return cp
        End Get
    End Property

    Public Sub New()
        SetStyle(ControlStyles.Opaque, True)
        BackColor = Color.Transparent
    End Sub

End Class
__________________
.NET Resources
My FAQ threads | Tutor's Corner | Code Library
I would bet money 2/3 of .NET questions are already answered in one of these three places.

Last edited by AtmaWeapon; 02-10-2009 at 11:18 AM.
Reply With Quote
  #8  
Old 02-10-2009, 12:00 PM
3dkingpin 3dkingpin is offline
Junior Contributor
 
Join Date: Feb 2008
Posts: 256
Default

curlyphobia? Not really Im use to using curlys and those are not the problem The problem is trying to 'translate' a piece of non VB.NET code to VB.NET code which you have absolutely no knowledge of.

'cp.ExStyle|=0x00000020'

I already knew what the | stands for normally but i have normally seen it being used as this for example:

API_Window_create(hwnd,0,0,320,240,W_CHILD|W_MAXIMIZE,0)

where it is used to specify multiple flags/parameters for a control/object etc..

so what does ''cp.ExStyle|=0x00000020' mean in layman's terms? I mean i take it that we want to assign a value to cp.ExStyle. Am i right in understanding that the cp.ExStyle already has a value assigned to it (say for example 19898) therefore:

cp.ExStyle|=0x00000020
would be same as saying
cp.ExStyle = 19898|(0x00000020) ?



Finally the code you gave at the end, does that work and where does have to be put, Id say I was less than intermediate at VB.NET especially when it comes to adding code to areas which cant be accessed by double clicking on the control on the form.
__________________
Hey, Looking for entry level job in VB net programming. Got basic qualification, years of programming experience (mainly self taught) and good portfolio. (UK)
Reply With Quote
  #9  
Old 02-10-2009, 12:06 PM
Cerian Knight's Avatar
Cerian KnightGroupbox and transparent background Cerian Knight is offline
Polymath (in disciplina)

Super Moderator
* Expert *
 
Join Date: May 2004
Location: Michigan
Posts: 4,199
Default

Correct. So 'X = X + 1' becomes 'X += 1', which helped with compiler optimization at one time (IIRC), so became part of standard syntax.
__________________
I got all the answers wrong on the GLAT, apparently even #9 (where I put a period in the middle of the box and labeled it 'singularity ripe for rapid inflation').
Reply With Quote
  #10  
Old 02-10-2009, 01:18 PM
AtmaWeapon's Avatar
AtmaWeaponGroupbox and transparent background AtmaWeapon is offline
Fabulous Florist

Forum Leader
* Guru *
 
Join Date: Feb 2004
Location: Austin, TX
Posts: 9,500
Default

Also, |= was on the page I linked It's obviously an operator, so the search for "C# operators" seemed like a good idea.

I know for sure that VB .NET has +=, -=, *=, and /= but I'm too lazy to go look up the rest. VB's choice of words rather than symbols to form the logical operators made it silly to try and make shortcuts like this. It's a convenience, because the pattern lhs = lhs op rhs shows up very frequently in code. Combine this with descriptive variable names and you end up with statements that are 90% redundant. C-style languages also tend to acknowledge that x = x + 1 and x = x - 1 show up very frequently and provide the increment/decrement operators (x++, ++x, x--, --x; look up the difference for fun!).

I always miss having ++ when writing VB :/
__________________
.NET Resources
My FAQ threads | Tutor's Corner | Code Library
I would bet money 2/3 of .NET questions are already answered in one of these three places.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Groupbox and transparent background
Groupbox and transparent background
Groupbox and transparent background Groupbox and transparent background
Groupbox and transparent background
Groupbox and transparent background
Groupbox and transparent background Groupbox and transparent background Groupbox and transparent background Groupbox and transparent background Groupbox and transparent background Groupbox and transparent background Groupbox and transparent background
Groupbox and transparent background
Groupbox and transparent background
 
Groupbox and transparent background
Groupbox and transparent background
 
-->