Click here to Skip to main content
13,559,479 members
Click here to Skip to main content
Add your own
alternative version


67 bookmarked
Posted 14 May 2004

A "Don't show this again" checkbox for the .NET MessageBox

, 14 May 2004
Rate this:
Please Sign up or sign in to vote.
A C# class which uses Dino Esposito's LocalCbtHook component to add a "Don't show this again" checkbox to any .NET MessageBox.

Sample Image - MessageBoxChk.gif


Every developer is familiar with the Windows MessageBox, but sometimes we need just a little bit more. For instance, what if I want a "Don't show this warning again" checkbox at the bottom of my MessageBoxes, enabling the user to turn off certain alerts, but I don't want to write my own dialog from scratch, covering every possible button combination? The MsgBoxCheck class does just that.


This article, and the MsgBoxCheck class, is built on two columns by Dino Esposito which appeared in MSDN Magazine's "Cutting Edge" in October and November of 2002. These describe the use of Windows Hooks in C#, in particular how to hook the creation and activation of the Windows MessageBox.

Using the code

Using the MsgBoxCheck class is as simple as using the Windows MessageBox. First, add a reference to MsgBoxCheck.dll in your C# project. Most people will invoke the class as follows:

MsgBoxCheck.MessageBox dlg = new MsgBoxCheck.MessageBox();
DialogResult dr =
        "Don't ask me this again",
        "Now is the time for all good men to check this message box",
        MessageBoxButtons.OK, MessageBoxIcon.Information);

The first two parameters describe the registry key, and value name used to store a boolean variable which determines if the user does not want this message box shown. The third parameter is the default return value, which will be returned immediately if the message box is not shown. Next is the text for the check box, then the message box text itself, the title, button code, and icon code.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Mike Scanlon
Web Developer
United States United States

You may also be interested in...

Comments and Discussions

GeneralNot useful for me ... unless.. Pin
Brett Swift25-May-05 6:00
memberBrett Swift25-May-05 6:00 
This works ok for an "OK" messagebox.. but imagine this:

You have a yesno messagebox for confirmation of closing an application.

I check "don't ask me this again" but select the "no" button. It doesn't exit the program, but it does set my registry value to the 2nd time I click exit, the message box warning doesn't appear..and it should!

Maybe it could be added?
GeneralRe: Not useful for me ... unless.. Pin
Angeliyo14-Jul-05 23:53
memberAngeliyo14-Jul-05 23:53 
GeneralRe: Not useful for me ... unless.. Pin
Blazetopher3-Jul-06 9:18
memberBlazetopher3-Jul-06 9:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web04 | 2.8.180527.1 | Last Updated 15 May 2004
Article Copyright 2004 by Mike Scanlon
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid