943,987 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 5587
  • C# RSS
Apr 29th, 2009
0

opacity control...?

Expand Post »
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?
Similar Threads
Reputation Points: 15
Solved Threads: 4
Posting Pro
anupam_smart is offline Offline
598 posts
since Feb 2006
Apr 29th, 2009
0

Re: opacity control...?

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.
Reputation Points: 11
Solved Threads: 9
Junior Poster in Training
vckicks is offline Offline
58 posts
since Jun 2008
Jul 3rd, 2009
0

Re: opacity control...?

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
chandru1984 is offline Offline
1 posts
since Jul 2009
Jul 3rd, 2009
0

Re: opacity control...?

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
Reputation Points: 442
Solved Threads: 89
Master Poster
Diamonddrake is offline Offline
721 posts
since Mar 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: tooltip on mouse click
Next Thread in C# Forum Timeline: Storing image to mysql in c#





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC