C# winforms pop up with background faded -
this question has answer here:
- make form's background transparent 4 answers
i have mainform, on user clicking button in mainform, need show child form popup in center of mainform. @ stage, free spaces(around inner box in attached image) on child form should transparent(greyed out) controls in main forms visible.
how achieve ? tried using opacity on child form, opacity being applied controls in form.
make form's background transparent: solution provided in link makes transparent. want opacity effect.
here how i've solved problem:
i've created form, , override it's onpaintbackground method this:
protected override void onpaintbackground(painteventargs e) { using (solidbrush brush = new solidbrush(color.fromargb(70, 0, 0, 0))) { e.graphics.fillrectangle(brush, e.cliprectangle); } } inside form i'm hosting user control that's panel label , 2 buttons (ok, cancel). once user clicks button set form's dialogresult ok or cancel (depending on button clicked).
this form shown main form dialog (frm.showdialog(this)). also, takes in it's constructor main form , set it's own display rectangle cover main form completly, , resize user control third of height , half of width of form, , centers it.
public frmthickbox(form owner, string message) { this.owner = owner; this.width = owner.width; this.height = owner.height; this.top = owner.top; this.left = owner.left; this.thickboxcontrol.text = message; this.thickboxcontrol.size = new size((int)this.width / 2, (int)this.height / 3); this.thickboxcontrol.top = (int)((this.height - thickboxcontrol.height) / 2); this.thickboxcontrol.left = (int)((this.width - thickboxcontrol.width) / 2); } and here how looks (of course, rounded corners entire different story):


Comments
Post a Comment