如何在屏幕前显示消息框 [英] how to display messagebox on front of screen

查看:61
本文介绍了如何在屏幕前显示消息框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨大家..我创建了一个表单,我已经创建了一些代码..并且在该代码中我必须显示一个消息框...因为我将表单的TOPMOST属性更改为false ...
$运行代码后b $ b ...表单在屏幕前运行但是当我们打开任何其他应用程序时它返回屏幕...在特定情况下,将出现消息框..然后消息框也出现在应用程序的背面...我需要它显示在所有屏幕的前面....应该通知消息框,好像发生了一些错误..





MessageBox.Show(午餐时间);



请修改此.. .. div class =h2_lin >解决方案

你真的不能这样做:除了阿联酋和类似的系统信息之外,Windows对话框不再是系统范围的 - 而且在你可以的时候这样做是非常粗鲁的 - 因为你的盒子得到了重点,所以我输入的任何内容都在那里,而不是我的应用程序我必须注意到......



但是,你可以假装它: http://stackoverflow.com/questions/3999998/how-to-make-a-system-modal-dialog-in-c [ ^ ]


我可以建议2个选项来显示高优先级消息:

1.创建自定义 MessageBox表单,设置 TopMost = true 然后使用 ShowDialog()方法

2.使用 NotifyIcon control


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

private void button1_Click( object sender,EventArgs e)
{
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( 这是一个模态窗口);
((表格)发件人).Close();
}
}





这可以帮到你


hi guys.. i created a form and i have created some code.. and in that code i have to display a message box... as i changed the form's TOPMOST property to false...
after running the code... the form is running on front of screen but when we open any other application it goes back the the screen... at particular instance the message box will appear..then the message box also appearing on the back of the applications... i need it to display in the front of all screens....the message box should be notified as if some error had occurred..


MessageBox.Show("time to Lunch");

please modify this..

解决方案

You can't really do it: Windows dialogs are no longer system wide except for UAE and suchlike system messages - and it was spectacularly rude to do it in the days when you could - since your box got the focus, so anything I was typing went there instead of to my app without me necessarily noticing...

But, you can "fake" it: http://stackoverflow.com/questions/3999998/how-to-make-a-system-modal-dialog-in-c[^]


I can suggest 2 options to show a high priority message:
1. create custom MessageBox form, set TopMost = true and then use ShowDialog() method
2. display message in the notification area using NotifyIcon control


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

    private void button1_Click(object sender, EventArgs e)
    {
        Form f = new Form();// object of the 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 might help you


这篇关于如何在屏幕前显示消息框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆