opacity control...?

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Feb 2006
Posts: 598
Reputation: anupam_smart is an unknown quantity at this point 
Solved Threads: 4
anupam_smart's Avatar
anupam_smart anupam_smart is offline Offline
Posting Pro

opacity control...?

 
0
  #1
Apr 29th, 2009
HI,
i'm working on c#.net 2008 edition and i want if we can control the opacity of a picture box on the form differently from the form itself i.e. if we can make the form transparent while still be able to see the picture box on it fully visible.
i did try several things but all i could manage was this...

SetStyle(ControlStyles.SupportsTransparentBackColor, true);
SetStyle(ControlStyles.Opaque, true);
this.BackColor = Color.FromArgb(0,Color.Black);

but it won't work good. Any help?
# Never say impossible 'cause impossible itself says:

"I M POSSIBLE":) :) :)

#Your I Can is more important than your I.Q.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 58
Reputation: vckicks is an unknown quantity at this point 
Solved Threads: 9
vckicks vckicks is offline Offline
Junior Poster in Training

Re: opacity control...?

 
0
  #2
Apr 29th, 2009
Unfortunately there is no way to make a Form semi-transparent and keep controls within it opaque (as far as I know).

The hackery way to do it is to have two forms, one semi-transparent, and the other one on top to hold the opaque controls. However I don't recommend this since it is really messy.
Visual C# Kicks - Free C# code resources and articles.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 1
Reputation: chandru1984 is an unknown quantity at this point 
Solved Threads: 0
chandru1984 chandru1984 is offline Offline
Newbie Poster

Re: opacity control...?

 
0
  #3
Jul 3rd, 2009
There is a third party control library called SemitranparentForm.dll (StForm). By referring this assembly and inheriting the StForm we can get Opaque controls on Semitransparent form. A demo application is available. Use the below link for more information.


http://www.stforms.net
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 324
Reputation: Diamonddrake is a jewel in the rough Diamonddrake is a jewel in the rough Diamonddrake is a jewel in the rough 
Solved Threads: 39
Diamonddrake's Avatar
Diamonddrake Diamonddrake is offline Offline
Posting Whiz

Re: opacity control...?

 
0
  #4
Jul 3rd, 2009
I don't think the OP was looking for a link to a product. But its a neat product I will admit. There are very few ways this can be done, you can custom draw your controls to the screen, which is complicated and can get very messy, but since its not drawn on the form. It can be whatever Opacity you want.

here's where the multiple forms concept comes to play. its not really that messy. its not that hard to do, It often yields great results. And using a "Form" overlay for your main form can get the job done.

it doesn't actually have to be a "Form" but just a separate "window" windows OS treats everything as a window, you just need to create another window, with its own handle, that can be modified separately. and the easiest way to do this is with a new form.

so. I suggest 2 methodologies for this.

1. if you don't intend to need to reuse, or use multiple controls with this feature, then just create a new form, with a formborderstyle of none, add the control you need on it. give it a transparent background. and create a public property that exposes the control.

Then in your original form, create an instance of the new form, set it where it needs to be, just as if it were just a control, then use and set the properties and methods of the control property you created just as if it were a normal control. and there you get the desired effect.

2. now if you want re-usability. then you can actually create a control that can be dropped onto a form. with a property of standard control types, that will automatically create the new form, set its position, and expose its control the way you want it. It wouldn't be that hard. and would be actually quite useful.

The hardest part, would be getting good transparency from the top controls. you would need them to all be custom controls that support transparent backgrounds. Exept the picturebox control, that would be easy because its a rectangle, so have it fill the control form, and adjust the control form's opacity. and you are golden.

I have a killer headache right now, and a ton of stuff to do for independence day, so I can't mock you up anything right now. but if you are still having trouble after the weekend. I can devote some time into showing what could be done in terms of this.

good luck and happy coding
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C# Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC