Solved

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

Posted on 2012-03-29
7
824 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now