[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2010-08-19
10
Medium Priority
?
2,100 Views
Last Modified: 2013-12-26
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?
0
Comment
Question by:RekhaShah
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
10 Comments
 
LVL 42

Expert Comment

by:Meir Rivkin
ID: 33479197
can u post an example of website which has this effect? just to get a clear picture of whai u need.
0
 

Author Comment

by:RekhaShah
ID: 33479271
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.
0
 
LVL 42

Expert Comment

by:Meir Rivkin
ID: 33479327
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.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 42

Expert Comment

by:Meir Rivkin
ID: 33479399
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?
0
 

Author Comment

by:RekhaShah
ID: 33479437
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.
0
 
LVL 42

Expert Comment

by:Meir Rivkin
ID: 33479610
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.
0
 

Author Comment

by:RekhaShah
ID: 33479728
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 
0
 

Accepted Solution

by:
RekhaShah earned 0 total points
ID: 33479943
I got it to work. It is very simple. Attaching the code for others.
I added a form called DarkenArea to the project , set the properties of the form as below:
Back Color = Black
SizeGripStyle = Hide
ShowIntaskBar = false
Opacity = 50%
MaximizeBox = false
Minimizebox = false
FormBorderStyle = none
StartPosition=Manual

 Dim sFileName As String
        Dim lbform As New DarkenArea()
        lbform.SetBounds(Me.Left + 8, Me.Top + 30, Me.ClientRectangle.Width, Me.ClientRectangle.Height)
        lbform.Owner = Me
        lbform.Show()
        sFileName = InputBox("Plese Enter File Name")
        lbform.Close()

Open in new window

0
 
LVL 42

Expert Comment

by:Meir Rivkin
ID: 33479990
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
0
 

Author Comment

by:RekhaShah
ID: 33480163
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.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question