2010-10-22 69 views

回答

5

我同意Bernarnd以这种方式接管系统是“粗鲁”。

如果您需要这种类型的东西,您可以创建一个类似的效果,如下所示。这与Vista中引入的用户帐户控制(“您是否希望允许以下程序对计算机进行更改”)模式窗口相似,因为它显示了模式窗口后面的透明背景。

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(); 
    }   
} 

这是一个更粗暴的方式因为用户可以ALT-TAB出模式窗口的等

+0

+1为妥协妥协。 – Nate 2010-10-22 20:45:16

+0

Thanx我已经通过禁用系统键Alt和WIN键 – 2010-10-23 05:39:11

+0

嗯Office Word并没有发现它那么粗鲁。至少只为他们的窗户。 – atomaras 2014-09-14 02:36:09

6

据雷蒙德陈从微软:

的Win32没有系统模态对话框 任何更多。所有对话框都是 模式对其所有者。

此外,您的问题是一个重复的this之一。

+1

但一些软件有系统模态形式,一个是“TuneUp Utilities的” – 2010-10-22 19:45:15

+2

我认为在总体上被认为是“粗鲁行为”的应用程序,接管的控制整个系统。 – Bernard 2010-10-22 20:04:16

1

这可通过最大化具有 形式和设置不透明度为50%

和完成设置Form Always on top属性TRUE

使用KeyHOOK禁用键盘的Win键和Alt键.......

0

您可以使用此:

string message = "Hello there! this is a msgbox in system modal"; 
MessageBox.Show(message is string ? message.ToString() : "Empty Message.", 
       "Message from server", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, (MessageBoxOptions)4096); 
相关问题