My main form has a horizontal splitcontainer on it. The top portion contains an Object List View control found here.
I am using code from a previous C# transparent overlay form answer.
My issue seems to have something to do with the Object List View. Using the code from the answer above, the transparent form covers all controls perfectly, however when it gets to the Object List View it seems to draw darker over this specific control.
If I close the transparent overlay and bring a blank panel to the front, when I open the transparent overlay, it still shows this darker section as if the object list view control is still visible.
I would first like to know why this is happening. But I would also like to know how I can fix this so that the overlay is consistant.
In case you wish to test this I created a simple project to demonstrate the issue here
To replicate what happens...
Drag the splitcontainer down a little and click the Overlay button.
Close the overlay by clicking in the White Panel. Click the Blank Panel button then click the Overlay button again.
Please note that in the Plexiglass class, it is taking a panel as a parameter only for the sake of this demonstration, in my actual project, it takes the main form as a parameter.
EDIT
I changed the color from dark gray to white and it works perfectly. I am not sure why the dark gray was causing that issue, but I am pleased with the way it looks with white so I will stick with that.
For some reason, the Color.DarkGray BackColor attribute for the transparent form was causing the issue. Changing the BackColor to Color.White fixed this.
Thanks to Patrice Gahide for helping me.
Related
I have a problem with screen flickering. I read some other topics on this case, but there are solutions that didn't work for me, I think that's because I don't know what exactly causes the problem.
My screen is has a large number of controls, maybe this is what causes the problem. I'll try to describe it as best, as I can.
First of all, I am using WinForms.
I am making a video game, so the screen should be maximized all the time.
To allow stretching all the controls I am using TablePanels, one large that is docked to fill the whole form and a few smaller that also dock fill the large Table cells. In smaller cells of those tables, Buttons are docked fill.
To show the background drawn buttons, I made control buttons completely transparent. It needs to stay that way.
The screen flickers white at positions of TableLayoutPanels borders.
The screen flickers when a mouse enters the position of a Button, any Button, no matter where it is located.
For now, only one element changes actively during gameplay - a Label. When mouse enters the field of button, this label shows what this button does. For example if I enter the area of "Use" button, the label displays the word "USE".
I haven't tried that yet, but I must implement, that some images of button will change or become transparent, or lose transparency during game-play. Like there could be one image for closed cupboard, but when player opens it, another image of open cupboard appears. I think I know how to do it, all I want is to prevent flickering.
If you suggest using some code (and I expect it will be needed), please specify where I should put it.
It seems problem was solved.
I'll answer my question myself, in case someone else needs it.
The problem was caused by one of labels, although I can't guess why.
I am using a number of TableLayoutPanels, one of them fills the whole form. It has a number of rows, each of them is also a TableLayoutPanel, or just a Panel.
Flickering appeared when I tried to put a label inside main TableLayoutPanel by its own, and not in a sub panel. When I put a Panel inside main Table, and label inside it, the majority of flickering was gone.
To remove it completely, I used both recommendations just in case:
1) DoubleBuffering: Here (answer from Fabjan)
2) Article also recommended by Fabian
After that, only a few minor glitches remained. I did a few tests and it seems that the last glitches happened when mouse left the screen, then returned back inside. My game screen is maximized, so it took some time to check. To fix it, I used an easy command:
"Cursor.Clip = this.Bounds;" on FormLoad
I learned it from another question from this site: Here
Unfortunately, I didn't understand, why misplaced label was behind flickering, but since the problem was solved, I decided to write it here, in case someone else needs it.
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
I started teaching myself C# a week ago. I started by writing Tetris to get myself acquainted with the language. I got the main game mechanics working by painting onto presized bitmap and displaying it in a picturebox, which at the time was the same size of the window. Now I have expanded the windows size and started adding other controls to the side of the picture box.
The problem is, now that I have expanded the window, displaying the form background, the background color is permanently white or I get a weird white to black faded look in the bottom corner.
I have tried several things:
- set the form backcolor manually, but it is only reflected on the labels
- checked that the transparencykey is empty
- set transparencykey to an unused color, nothing changes - added a bmp as the form's background image, still stays white - checked my code to see if I was every writing directly to the form background
I can't fingure out how to fix this; does anyone have any ideas?
EDIT: I found the answer to my question. SetStyle(ControlStyles.Opaque, true) was called in my constructor. I'm not sure what exactly that does, but I commented it out and it fixed my problem.
Please list out the requirements means exactly what you need?
After I read your question. The following are my understandings.
If your problem is with changing window size, then
make use of Split container, which is
available in toolbox from
'Containers' group.
set its Dock property to fill to
fill entire window if
resized/maximized.
Then use the right pane to contain your picture box and left pane for other controls.
If you require, you may also set dock property of picture box to fill to its parent container means right pane.
If your problem is with background color of the window, then
Actually Background color issue comes, If the form is an Mdi Container.
Check whether IsMdiContainer property is set to false. If true it is an MdiContainer.
The following code block sets Mdi Forms' backcolor to the forms' backcolor.
foreach (Control c in this.Controls)
{
if (c is MdiClient)
{
c.BackColor = this.BackColor;
}
}
I found the answer to my question. SetStyle(ControlStyles.Opaque, true) was called in my initialization. I'm not sure what exactly that does, but it was the cause of my background color issue.
I´m using WinForms. I want to make a little class, which modifys controls to show it´s working.
I want to draw an overlay over for example a button. It should be a half-transparent gray.
After that i want to draw a ProgressBar on over it (in the center). Similar to This, except using a progress bar.
How can i realize this? I don´t want to set the position of the progressbar, just drawing it on the other one.
How could i do this?
Thanks :)
I have done something similar before.
You need to use Button.DrawToBitmap(Bitmap, Rectangle) to get the image of the button. Then make the Bitmap grayscale (there are multiple algorithms available for this; I have used the last one successfully although probably not originally from this site).
Now, I did this with an entire form instead of a button, but I disabled the form, and then covered the entire form with an image of itself, altered and then covered it with the progress bar (itself in a panel with other controls).
You could just as easily disable the button, cover it with a panel containing the image and the progress bar on top of it.
I already made the background transparent but there is still some part left from the group box. How do I make those transparent also?
The blank line are what I want it to be transparent. It should give you the picture of what I want. Thanks.
And don't even ask what are the password for, all of them are just dummies :)
If you want to see and edit the code, here
That's just how the GroupBox control works. The Background property of that control includes the area that your screenshot points to. If you wanted to do a workaround for it, you should set the GroupBox background to be transparent as well, and draw a white box behind it, encompassing only the area you want to be white.
Form.Opacity doesn't work for you?
What is the GroupBox's parent container? Is it a Form or a Panel? Is that element also set to transparent? As a test I made a GroupBox and placed it on top of (inside) a Panel. I changed the background color of the Panel to red and the background color of the GroupBox to transparent and those ares of the GroupBox are properly transparent. My suggestion is to look at the parent container.
Also the GroupBox label may become hard to read in some cases, once the top strip is transparent.