2010-10-22 35 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); 
相關問題