Solved

vb.net 2005 how to grey out all controls on the main form

Posted on 2012-03-29
7
861 Views
Last Modified: 2012-04-16
I have an app thats mdi and has a few 3rd party panel controls. I need to implement a 'lock application' feature where the user would click a button, the the entire app would appear disabled, and a unlock dialog box requesting password to unlock the app would display.

Currently I'm simulating the disabled app by opening a form, settings its opacity to 50%, removing its titlebar, and sizing/placing it in the main apps client area. I choose a form for my initial proof of concept as it has an opacity setting.

Questions:

2. I'm having a bit of trouble with the form as it seems to mess up the taskbar and the modality of the password dialog. Without the transparent form if you invoke a showdialog on the password form I can toggle between apps and the app/password dialog activate together. If I add the transparent form and toggle between apps the app sometimes displays without the password dialog even those its modal. Any ideas how to fix this?

1. Is there a better way then using a transparent form? Is it possible to use a panel or something and set its transparency. I can't get a panel to be transparent with vb.2005. Tried a bunch of suggestions I found while googling but can't get it to work.
0
Comment
Question by:glenn_r
7 Comments
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 37784434
See my answer here for a different approach:
http://www.experts-exchange.com/Programming/Misc/Q_27632423.html

It takes a screen shot of the form and then overlays a semi-transparent rectangle to get the disabled look.  Next it uses that composite image as the background of a panel that takes up the entire form.  You can display the login "dialog" inside that panel using containers (a groupbox in the example).
0
 

Author Comment

by:glenn_r
ID: 37784528
Sounds like an alternative, not sure if it will work if the form has toolbars, might not cover them in the client area.
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 37784551
Can't you just disable the form and display the login via ShowDialog()?  You pass in the owner to showdialog like this:  *simplified*
Public Class Form1

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Me.Enabled = False

        Dim f As New Form
        f.ShowDialog(Me)

        Me.Enabled = True
    End Sub

End Class

Open in new window

0
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 
LVL 16

Expert Comment

by:SriVaddadi
ID: 37785443
You can recursively lock (disable) all controls on the form.  Check the below link.  May be you could use it.

http://www.codeproject.com/Articles/37576/Extending-Forms-Control-Lock-and-Unlock
0
 
LVL 17

Expert Comment

by:nepaluz
ID: 37791734
Why do you need to dis-able the main form? Calling a modal dialog with ShowDialog() rather than Show() would anyway render the main form in-accessible until you dispose of the modal. All youhave to do is ensure that the modal dialog only closes when a correct password has been entered (or closes the entire program should the user decide to cancel).
0
 

Author Comment

by:glenn_r
ID: 37796434
Customers specification is to grey out all the controls. For now I'm disabling the main form but depending on the control it does not look very good. For example when you disable the main form with a treeview control each node gets its label background turned grey, which looks terrible.
0
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 150 total points
ID: 37796462
You could use the technique in my first post to get a screenshot of the form and then make the composite grayed out form.  Then, instead of using the same form with a panel, completely hide the main form and display a secondary form that will display the grayed out main form (as an image).  Now display your dialog box.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

820 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