public class MeTransperantPanel : System.Windows.Forms.Form
{
private System.ComponentModel.Container components = null;
public MeTransperantPanel()
{
InitializeComponent();
this.Opacity = 0.6;
}
public MeTransperantPanel(Form owner) : this()
{
this.Owner = owner;
this.Owner.Layout += new LayoutEventHandler(this.OwnerLayoutChanged);
this.Owner.Move += new EventHandler(this.OwnerMoved);
this.Owner.Closed += new EventHandler(this.OwnerClosed);
}
private void OwnerLayoutChanged(object sender, System.Windows.Forms.LayoutEventArgs e)
{
MoveMeGlassPane();
}
private void OwnerMoved(object sender, System.EventArgs e)
{
MoveMeGlassPane();
}
private void OwnerClosed(object sender, System.EventArgs e)
{
this.Close();
}
private void MoveMeGlassPane()
{
this.Location = new Point(this.Owner.Location.X+2, this.Owner.Location.Y+35);
this.Width = this.Owner.Width - 4;
this.Height = this.Owner.Height - 37;
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.SuspendLayout();
//
// MeGlassPane
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
this.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(255)), ((System.Byte)(192)));
this.ClientSize = new System.Drawing.Size(528, 260);
this.ControlBox = false;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "MeGlassPane";
this.Opacity = 0.8;
this.ShowInTaskbar = false;
this.ResumeLayout(false);
}
#endregion
}
/*
* To Implement this code just inherited in form
*/
public partial class Form1 : MeTransperantPanel
{
}
No comments:
Post a Comment