I am trying to make a transparent form that will be shown on the bottom right corner of the screen. In that form, I have an image as a background that I am rotating. The issue is, when I use the following code to make the form transparent, I am getting outlines on the image that is equivalent to the color I set for the transparency key/background. Is this because of the image, or is there a way to fix this programmatically?
CODE:
this.TransparencyKey = Color.Orange;
this.BackColor = Color.Orange;
This gives me an orange outline around my image.
You can't make the border transparent but you can get rid of it altogether.
To get rid of the border you would use this.
FormBorderStyle = FormBorderStyle.None;
Related
I turned the BackColor of the Form into Green and then the TransparencyKey into the BackColor (that would turn the background color of the WF into Transparent)
this.BackColor = Color.Green;
this.TransparencyKey = BackColor;
But when I run the project the label I got on the upper left-corner has a pixeled outline of color green...
I tried turning the label's BackColor into Green hoping that it will turn the pixels transparent... but that didn't happened.
Also I got an image with transparent background (.png with transparent background) and that image got the pixels too. Also tried chaning the BackColor from green to lime but that did nothing but worsening the situation (more pixels than before)...
Anyone out there know how to remove those green pixels?
I'm doing the table game battleship, by moving pictures boxes with the mouse, the problem is that all the picture boxes that I have contain an image without background, but i have the problem that when I move it through different points, it shows a default background instead of showing the background of the "map". This messes the aspect of the game table.
I've tried this code in my program ,but it makes the ships default position is in the panel(which I do not want) and it doesn't solve the problem I described earlier (when you move ships over the others spaces)
Barco1.Parent = panel1;
Barco1.BackColor = Color.Transparent;
An example of one of the ships
As you can see in the picture, there are:
Form with a BackgroundImage,
Panel with BackColor = Color.Transparent and BackgroundImage = some-image and
PictureBox with BackColor = Color.Transparent and an image as its Image property.
It should work for you.
It looks like You are setting the Image background as Transparent but You are adding that Image into another Panel!
Barco1.Parent = panel1;
So, Set the Background Color of the Panel1 as Transparent:
panel1.BackgroundColor=Color.Transparent;
I need to do something like paint, the only differ, you can draw on screen. When user click on a tool (pen, line, rect, text etc.) I take screenshot of the screen and put it as background image for a second full screen form. Then by handling mouse events draw on it. Im trying to follow MS Paint and draw text using third form with a RichTextBox inside it. This form must be transparent, and after I'll take new screenshot and load as background of second form.
This is code for third form which is transparent.
this.FormBorderStyle = FormBorderStyle.None;
this.TransparencyKey = Color.Turquoise;
this.BackColor = Color.Turquoise;
richTextBox1.BackColor = this.BackColor;
As you can see, text is being light blue. This is my problem.
I did not find a way how to fix that, and I decided to use label instead. By handling key press event and making label back color transparent I got expected result.
enter image description here
I have tried many ways to have a transparent background on my form. Transparency key does work, but problems arise when you put images that have opacity. I tried to override OnPaintBackground which only removed my background image. And I tried the SetStyle method.
Assuming you are using windows forms, try:
this.TransparencyKey = Color.Red;
this.BackColor = Color.Red;
when you have a color on the form which is the same as your transparency key, then it will be transparent. on the other hand, by that the red color is assigned for transparency only, you won't be able to use it.
(and this refers to the form)
You can set opacity of the form.100% is default for Windows form and lower values are more transparent.
I have a problem with:
BackColor = Color.Transparent;
It's not working correctly. I have a form with a blue background, and a picturebox with a picture loaded in it. It's not actually taking what's in the picture, but rather - the form's background color. Please tell me there's a simple way to go around this?
What you see in the following screenshot is a custom usercontrol with it's backColor set to transparent, on top of a picture, in a form with a blue background.
I need the usercontrol to display what's UNDER it, as real transparency, it should be showing the gradient and part of the image.
Try setting the picture box to be the parent of the custom user control.
myControl.Parent = this.myPictureBox;
Try calling "SetStyle(ControlStyles.SupportsTransparentBackColor, true);" on your user control constructor.
more details at: http://msdn.microsoft.com/en-us/library/wk5b13s4(v=vs.90).aspx