Thanks!
Have you considered using a panel instead of a groupbox You can set the background color to the form's background color and set the border to 'none'.
If you need the groupbox's title and border you could also put the groupbox in a panel and show and hide the panel.
It sounds like I'm missing some key information about your problem.
Why is transparency to the form and not just the flash object a problem If the flash object is visible, is on the form and the group box or panel has a transparent background, anything behind it, including the flash object, should be visible, right
I think I understand the situation now. You're putting a flash object on the form as/or in a winform control and making the control large enough to cover the entire form, right
Unfortunately, transparent backgrounds in winforms controls aren't truly transparent, they just copy the part of the form's background that they would normally cover up. This means they are not transparent to other controls on the form.
I've never tried to make controls truly transparent myself, but maybe someone else here has.
One possible work around is to create a second form in your solution with its Opacity property set to 0% and with no borders or title bar. Put your input controls on the transparent form and position it over the form that contains the flash object. You can easily Show or Hide it and it will allow your flash object and any other controls on the main form to show through. It might be a little more work to coordinate events between the two forms, but it shouldn't be too bad.
In thinking about this a little more, you will probably want to create your transparent form with a title bar and the same border style and window controls (close, maximize, etc.) that your main form has. When you've done that you can just make your transparent form the same size as your main form. This will give you a way to capture the user's interactions with the transparent form and pass them along to the main form.
I tried to create a form within a form using the MDI functions but the only thing I get it to do is Form2 replaces the contents of Form1 and then nothing else works. I am not quite sure how to code a new form (Form2) to appear at the bottom of the parent form (Form1) that is floating on top of the contents of the parent form. Have any suggestions or examples
I've never tried it using MDI.
I used independent forms. I used a base form to display the content and launched the transparent form from the base form. The transparent form is the same size as the base form and is positioned directly over it. I added a BaseForm property to the transparent form to give me a reference back to the base form. This made it easy to move or resize the base form if the user moves or resizes the transparent form. I think I had to make sure the transparent form's opacity was greater than 0 in order for it to receive mouse and other input events.
This is a work around and not a perfect solution. One side effect of this approach is that the title bar doesn't look quite right. The transparent form has the input focus but it is transparent, so you see the underlying base form's title bar, which is not the right color because it doesn't have the focus.
Here's a very basic code example using two forms; baseForm (the base form) and clearForm (the transparent form).
public partial class baseForm : Form
{
ClearForm clearForm = new ClearForm();
public baseForm()
{
InitializeComponent();
}
public void MoveForm(int left, int top)
{
this.Left = left;
this.Top = top;
}
private void baseForm_Load(object sender, EventArgs e)
{
clearForm.BaseForm = this;
clearForm.Left = this.Left;
clearForm.Top = this.Top;
clearForm.Height = this.Height;
clearForm.Width = this.Width;
clearForm.BringToFront();
clearForm.Show();
}
private void baseForm_Activated(object sender, EventArgs e)
{
clearForm.Focus();
}
}
public partial class ClearForm : Form
{
public ClearForm()
{
InitializeComponent();
}
private void ClearForm_Move(object sender, EventArgs e)
{
if (this.BaseForm != null)
{
this.BaseForm.Left = this.Left;
this.BaseForm.Top = this.Top;
}
}
private baseForm baseForm;
public baseForm BaseForm
{
get { return baseForm; }
set { baseForm = value; }
}
private void ClearForm_FormClosed(object sender, FormClosedEventArgs e)
{
Application.Exit();
}
private void ClearForm_Resize(object sender, EventArgs e)
{
if (this.BaseForm != null)
{
this.BaseForm.Width = this.Width;
this.BaseForm.Height = this.Height;
}
}
}
You're welcome. In order to keep things simple, my example assumes you want to make the transparent form cover the base form entirely. Handling user events gets a lot more complicated once you start making one larger than the other. I expect you could make it work but the code will get messy and complicated pretty quickly.
Here's another approach that may help. This is still a work around, but approaches the problem from a different direction.
Add a user control to your project. I call it ClearControl in the following code. Making the modifications shown below will create a user control that has a real transparent background. Add a panel control to the design surface of this user control, dock it to fill the control, and set its background to transparent. You should be able to use the panel to gather your input. Once it's compiled, you can place an instance of the ClearControl on your base form in the form designer and make it any size you want.
The downside to this approach is that I have no idea how well it will work with an animation playing in the background. I do know that this approach doesn't support double buffering.
public partial class ClearControl : UserControl
{
public ClearControl()
{
InitializeComponent();
}
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x00000020; //WS_EX_TRANSPARENT
return cp;
}
}
protected override void OnPaintBackground(PaintEventArgs pevent)
{
// Prevents background painting
}
protected override void OnPaint(PaintEventArgs e)
{
// Put custom drawing code here if needed. Will appear over controls behind this control.
}
}
I think we were in the right direction before if I could
just find out how to offset the child form so that it is docked in the bottom
or at least appears there. For now it just appearing in the correct place
would be more then fine for me.
// changing this does nothing
clearForm.Left = this.Left;
// changing this does nothing
clearForm.Top = this.Top;
// I can minus the value
so the form becomes shorter but doesnĄ¯t do anything other then that
clearForm.Height = this.Height;
// Dont need to change this
clearForm.Width = this.Width;
I also tried using the DockStyle command to make it dock to the bottom but no
luck. Any thoughts
Sorry to take so long to reply. Our power went out last Thursday and just came back on a little while ago.
The DockStyle property won't have any effect, since neither form is a child of the other.
When you say that you want the clearForm to be docked at the bottom of the baseForm, do you mean that the clearForm should be the same height as the client area of the baseform and the top of the clearForm should be positioned at the top of the client area of the baseForm This would position it below the baseForm's title bar and menu bar, if it has one.
I'm assuming you want the width of the clearForm to be the same as the width of the baseForm, right