locked
Is there any event that triggered when application pop ups a message box ? RRS feed

  • Question

  • Hi all,

    There is a requirement that all the alert message boxes must be avoided if application is running in 'silent mode'. In order to that it will be better if i could handle an event which triggered whenever application is popping up a message box. So i could handle that event and check the condition in a single place. Otherwise i will have to check this condition whenever a message box has called in the code which would be a burden.

    Any answers ? Please let me know if you have any idea.

    Thanks in advance

    • Moved by CoolDadTx Friday, May 13, 2011 1:58 PM Winforms related (From:Visual C# General)
    Friday, May 13, 2011 11:13 AM

Answers

  • Better still; create your own MessageBox class/ method that wraps the standard one and detect the 'silent mode' condition in there.

     

    internal class MezzageBox
    {
      public static bool SilentMode = false; 
    
      public DialogResult ShowDialog( string text, string title, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton )
      {
       if ( SilentMode ) 
       { 
         // Work out the default/ first option 
         return defaultOrFirst; 
       } 
       else 
         return MessagBox.Show( text, title, buttons, icon, defaultButton ); 
      }
    }
    
    

    Of course you do have to change every instance of MessageBox.Show() in your code to use the new class/ method.  8-}

     

     


    Regards, Phill W.
    Friday, May 13, 2011 3:21 PM

All replies

  •  

    Is Enabling default reply works for you? if so follow the below link

    http://msdn.microsoft.com/en-us/library/ms940850(v=winembedded.5).aspx

    http://waytovc.blogspot.com/2010/01/enabling-default-reply.html

     

     


    Knowledge is like light; It spreads only when you have clear and transparent mind.
    Friday, May 13, 2011 11:51 AM
  • Better still; create your own MessageBox class/ method that wraps the standard one and detect the 'silent mode' condition in there.

     

    internal class MezzageBox
    {
      public static bool SilentMode = false; 
    
      public DialogResult ShowDialog( string text, string title, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton )
      {
       if ( SilentMode ) 
       { 
         // Work out the default/ first option 
         return defaultOrFirst; 
       } 
       else 
         return MessagBox.Show( text, title, buttons, icon, defaultButton ); 
      }
    }
    
    

    Of course you do have to change every instance of MessageBox.Show() in your code to use the new class/ method.  8-}

     

     


    Regards, Phill W.
    Friday, May 13, 2011 3:21 PM