tags:

views:

62

answers:

3

I want to make My form "SYSTEM MODAL DIALOG" as in windowsXP "TURN OFF Dialog" so no operation can be made on window except in my form in C#

+3  A: 

According to Raymond Chen from Microsoft:

Win32 doesn't have system modal dialogs any more. All dialogs are modal to their owner.

Also, your question is a duplicate of this one.

Bernard
but some of the softwares have system modal form one of that is "TuneUP Utilities"
Javed Akram
I think in general it is considered "rude behaviour" for an application to take over control of the entire system.
Bernard
+1  A: 

I agree with Bernarnd that taking over the system in this way is "rude".

If you need this kind of thing though, you can create a similar effect as shown below . This is similar to the User Account Control ("Do you want to allow the following program to make changes to the computer") modal window introduced in Vista in that it shows a transparent background behind the modal window.

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        // show a "wrapper" form that covers the whole active screen
        // This wrapper shows the actual modal form
        Form f = new Form();
        f.WindowState = FormWindowState.Maximized;
        f.FormBorderStyle = FormBorderStyle.None;
        f.Opacity = 0.5;
        f.Load += new EventHandler(f_Load);
        f.Show();
    }

    void f_Load(object sender, EventArgs e)
    {
        MessageBox.Show("This is a modal window");
        ((Form)sender).Close();
    }        
}

This is a much less rude approach as the user can ALT-TAB out of the modal window etc.

steinar
+1 for a good compromise.
Nate Bross
Thanx i have done it by disabling system keys Alt and WIN key
Javed Akram
A: 

This can be done by maximizing form having and Setting opacity to 50%

and setting Form Always on Top property TRUE

and Disabling the Win key and Alt keys of keyboard using KeyHOOK.......

Javed Akram