C# win form transparency - c#

I am using C# to make my desktop applications.
But I want to make more graphical applications that have full transparency backgrounds and different levels of transparency for picture box controls.
Basically, not cookie cutter opacity of removing a solid color.
How can I accomplish this with C#?

It is simple, just go ahead with WPF. This gived me a good start point.

This should help:
http://www.c-sharpcorner.com/UploadFile/scottlysle/XparentFormsCS10282007212944PM/XparentFormsCS.aspx
also
form2.Opacity = .x; where x is percentage of transparency
or
transparency can be directly edited in appearance property of form in case you are using VSTO

Related

C# proper image alpha layer when form is invisible

I'm looking for a way to have images on invisible form that allow alpha transparency and allow to place and use buttons/labels etc.
I've tried this Transparent background on winforms?, layered window and many more, nothing fully successful. I've ended up with such failures http://imgur.com/a/t6nmF
Transparency key only makes one color transparent, which doesn't work on images that have smooth color gradients on the edges.
First of all, are you certain that your image has a transparent background?
Layered window is exactly what you should use to achieve the desired effect. Since you don't give much details, I don't know what's wrong with your implementation. Try to use the PerPixelAlphaForm from the following article: Per Pixel Alpha Blend in C#. When used correctly, it will work (even though the article is really old).

WinForm transparent image issue

I have a WinForm and I set a transparent PNG image for the label. In Windows XP, the transparency displays properly, but in Windows 7, the white text (as seen in the example URL below) becomes transparent (it should be solid white). I'm also wondering if there is a way to smooth the edges of the transparent image so it isn't as choppy.
label1.Image = global::WinProgram.Properties.Resources.image_name;
Example:
Due to your limited code, I'd be guessing on this one but i find this very likely to be your problem. In WinForms there is a so called TransparencyKey, I'm guessing that you sett'd the SolidWhite as your TransparencyKey.
You can refer to this post: Transparent Background

Control Screen Brightness in WIndows Phone 7

Is it possible to to use c# to change the screen brightness? I know some apps can control it so if there is not a direct way then does anyone know of a workaround?
Thanks
Unfortunately you don't have that level of hardware control, but if you only need to make the screen dimmer, you just need to scale down the RGB values of each pixel.
Depending on what you're working with, there are a number of approaches, but if you have a black background, you can just adjust the opacity of your front layer, which will effectively dim the content.

Draw TextBox border as in Vista / 7

In Windows.Forms, I was not able to reproduce the exact same TextBox border as you see it in Vista / 7 Aero. All I get is a gray rectangle instead the slightly sunken gray / blue 3d border. I tried the following methods with no success:
VisualStyleRenderer class
TextBoxRenderer class
Control.DrawToBitmap()
P/Invoke with UxTheme and friends
Drawing RichTextBox elements instead of TextBox ones
This problem has already been discussed here but with no solution: http://social.msdn.microsoft.com/Forums/hu-HU/winforms/thread/46e66852-b52e-420d-8fe0-b717f86ecb18
It looks like there's no obvious solution for this problem.
Does anyone know how to draw the exact same border as in Aero?
It's probably not going to happen for you.
I think the VisualStyleRenderer, including the TextBoxRenderer, were more meant for the XP themes.
Even the Control.DrawToBitmap(...) function magically draws a different version from what is on the screen.
I don't have the canonical answer for this, but it's most likely a result of Microsoft moving on with WPF and leaving behind the WinForm controls with those visual themes half-baked.
The only answer to this question is to use WPF or use a 3rd party system like DevExpress (which support custom themes) if you need to "theme" all of your controls.

"Transparent" Windows Form flickers when in front of DirectDraw Video Surface

I have an application where, beyond my control, several Windows Forms have a TransparencyKey property set. When these windows cover (are in front of) another form which has a DirectDraw video surface, the foreground form flickers (partly showing the form and partly showing the video beneath). The thing is, the color of the TransparencyKey doesn't appear anywhere in the application, so NOTHING should be transparent... in other words, the result should be that the foreground form is completely opaque.
Does anyone have experience with DirectDraw surfaces flickering when combined with Windows Forms that are in some form or other set up to be transparent? I've worked on this for weeks, with no success. Thanks!
I'm sorry but I would suggest that you abandon that goal completely and try to do it some other way.
DirectDraw is one way of displaying stuff on the screen, and forms with regions (that are created on the fly as masks from so called 'transparent key color') are done with GDI. As I see it (and would like to be proven otherwise) - you won't be able to combine that two windows anyway.
And you will probably get different results on different Windows, depending on the version, graphics card used, and so on.
On the other side, can you hack those forms that you don't have the control over and remove TransparencyKey property from them? Even with Win32 API?

Categories