i am working with C# v2.0 winform apps. i want to show user control on top of another form with dim background or semi transparent background whose mdiparent property has been assign. i wrote a code which works fine but when i am showing from a form which has mdiparent then background become full black instead of specifying opacity .5. here i will post my code. please have a look and tell me how could i show my user control with semi transparent background instead of full black.
here is my code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace reman
{publicpartialclassMaskedDialog:Form{staticMaskedDialog mask;staticForm frmContainer;privateForm dialog;privateUserControl ucDialog;privateMaskedDialog(Form parent,Form dialog){this.dialog = dialog;this.FormBorderStyle=FormBorderStyle.None;this.BackColor=System.Drawing.Color.Black;this.Opacity=0.50;this.ShowInTaskbar=false;this.StartPosition=FormStartPosition.Manual;this.Size= parent.ClientSize;this.Location= parent.PointToScreen(System.Drawing.Point.Empty);
parent.Move+=AdjustPosition;
parent.SizeChanged+=AdjustPosition;}privateMaskedDialog(Form parent,UserControl ucDialog){this.ucDialog = ucDialog;this.FormBorderStyle=FormBorderStyle.None;this.BackColor=System.Drawing.Color.Black;this.Opacity=0.50;this.ShowInTaskbar=false;this.StartPosition=FormStartPosition.Manual;this.Size= parent.ClientSize;this.Location= parent.PointToScreen(System.Drawing.Point.Empty);
parent.Move+=AdjustPosition;
parent.SizeChanged+=AdjustPosition;}privatevoidAdjustPosition(object sender,EventArgs e){Form parent = sender asForm;this.Location= parent.PointToScreen(System.Drawing.Point.Empty);this.ClientSize= parent.ClientSize;}publicstaticDialogResultShowDialog(Form parent,Form dialog){
mask =newMaskedDialog(parent, dialog);
dialog.StartPosition=FormStartPosition.CenterParent;
mask.Show();DialogResult result = dialog.ShowDialog(mask);
mask.Close();return result;}publicstaticDialogResultShowDialog(Form parent,UserControl dialog){
mask =newMaskedDialog(parent, dialog);
frmContainer =newForm();
frmContainer.ShowInTaskbar=false;
frmContainer.FormBorderStyle=System.Windows.Forms.FormBorderStyle.None;
frmContainer.StartPosition=FormStartPosition.CenterParent;
frmContainer.Height= dialog.Height;
frmContainer.Width= dialog.Width;
frmContainer.Controls.Add(dialog);
mask.MdiParent= parent.MdiParent;
mask.Show();DialogResult result = frmContainer.ShowDialog(mask);
frmContainer.Close();
mask.Close();return result;}publicstaticvoidCloseDialog(){if(frmContainer !=null){
frmContainer.Close();}}}}
the way i am calling my MaskedDialog form from another form.
privatevoid btnAct_Click(object sender,EventArgs e){
ucCheckInfo ucInfo =new ucCheckInfo();MaskedDialog.ShowDialog(this, ucInfo);}
can any one rectify my code as a result background should be semi-transparent. thanks