Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2012-03-29
7
Medium Priority
?
952 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 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
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
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 450 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Loops Section Overview

886 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