Link to home
Start Free TrialLog in
Avatar of RekhaShah
RekhaShah

asked on

Can you create a Lightbox dialogbox in winforms using VB.net?

Hi Experts,
I was wondering, if one can create light box effect in win forms using vb.net like many websites have this technique where the background form is semi transparant and the modal form is bright and in focus?
Avatar of Meir Rivkin
Meir Rivkin
Flag of Israel image

can u post an example of website which has this effect? just to get a clear picture of whai u need.
Avatar of RekhaShah
RekhaShah

ASKER

It is called lightbox dialog effect. Even This website uses it when you post a question.  I think it is preety simple, I tried to set the opacity of the form =.5. then show the dialogbox and after the users' response, i set forms's transperancy back to 1.0. This is the closeset I can get. If you try this, you will have an idea of what I am talking about.
u simply change the Opacity property of the Form and also the background color of the form.change the opacity to 0.86 and the backcolor to whatever you like.
ok, u mean that u want to have like a semi transparent mask with some color, which covers also the controls on the form, is that correct?
I think in ASP.net, they use some JQuery to  bring the effect. With opacity change, one can see the window's desktop. What should really happen is that the form should look like watermarked document if you will, or disabled document.
in WPF it is built in, u simply use Opacity like in any winform.
in .net 3.5 and earlier is kinda complicated.
before displaying the messagebox you could do the following:

take screenshot of the form, save it as image and perform the algorithm which yields lightbox effect (you can google for it, i'm sure it's somewhere).
then you set the image as the form background and hide all controls.
after user click the messagebox, you restore the form backcolor and show all the controls.
There is a sample project on the folowing link, but it is in C#. i don't know C#. that will give you an idea. Thanks
http://cid-12d219ccfc930f76.skydrive.live.com/self.aspx/Code/LightBox000.zip 
ASKER CERTIFIED SOLUTION
Avatar of RekhaShah
RekhaShah

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
i can help you translate or u can use the following online conversion website:
http://www.developerfusion.com/tools/convert/vb-to-csharp/

here's the conversion for the Lightbox code:
Private Sub LBform_Load(sender As Object, e As EventArgs)
      Dim background As New Bitmap(Me.Width, Me.Height)
      Dim g As Graphics = Graphics.FromImage(background)
      g.FillRectangle(Brushes.Fuchsia, Me.ControlBounds)

      g.Flush()

      Me.BackgroundImage = background
      Me.Invalidate()
End Sub

LBform is the form which used as the Lightbox mask
We don't have to do any of these things, just look at my code that i have posted. It works like a charm and no complicated code. But thanks for your willingness to help.