Solved

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

Posted on 2012-03-29
7
882 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
[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
7 Comments
 
LVL 86

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 86

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
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 
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 86

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
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.
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

734 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