Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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..
Posted
Comments
Member 14064219 4-Apr-19 2:45am    
: vbscript:
Response = MsgBox("Yoyr Message", vbYesNo + MsgBoxStyle.MsgBoxSetForeground + vbDefaultButton2, " MSGBOX Title ")

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[^]
 
Share this answer
 
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
 
Share this answer
 
C#
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
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900