5,695,118 members and growing! (13,182 online)
Email Password   helpLost your password?
Desktop Development » Dialogs and Windows » General     Intermediate

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

By Mike Scanlon

A C# class which uses Dino Esposito's LocalCbtHook component to add a "Don't show this again" checkbox to any .NET MessageBox.
C#Windows, .NET, .NET 1.1, Win2K, WinXP, Win2003VS.NET2003, Visual Studio, Dev

Posted: 14 May 2004
Updated: 14 May 2004
Views: 57,189
Bookmarked: 44 times
Announcements
Loading...



Search    
Advanced Search
Sitemap
19 votes for this Article.
Popularity: 4.74 Rating: 3.71 out of 5
1 vote, 5.3%
1
2 votes, 10.5%
2
5 votes, 26.3%
3
3 votes, 15.8%
4
8 votes, 42.1%
5

Sample Image - MessageBoxChk.gif

Introduction

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.

Background

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 = 
            dlg.Show(@"Software\PricklySoft\TestMsgBoxCheck",
            "DontShowAgain",DialogResult.OK,
            "Don't ask me this again",
            "Now is the time for all good men to check this message box", 
            "Hello",
            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.

License

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


Visit http://mike.pricklysoft.com

Occupation: Web Developer
Location: United States United States

Other popular Dialogs and Windows articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 22 of 22 (Total in Forum: 22) (Refresh)FirstPrevNext
GeneralWhere do I find the MsgBoxCheck.dll filememberGlade Ross12:02 14 Jul '08  
GeneralParameter to set the default button pleasememberSuperCoder!4:16 19 Jun '08  
QuestionVista ProblemmemberTurulo10:33 10 Apr '08  
AnswerRe: Vista ProblemmemberSuperCoder!4:11 19 Jun '08  
GeneralLicense Attachedmemberrsbiz20042:07 26 Mar '08  
GeneralAnd in vbnet ?memberscalpa989:31 22 Sep '07  
GeneralRe: And in vbnet ?memberrsbiz20043:44 24 Mar '08  
Generalhow to use this from a visual c++ sln?memberlaura_glow11:06 13 Jun '07  
Generalimplementation to HTMLmemberjameo184:48 6 Jun '07  
GeneralMsgBoxCheck.dll source code or reg pathmemberwilsoada13:37 13 Dec '06  
GeneralDon't like the use of registrymemberPiotr Perak5:06 20 Oct '06  
GeneralRe: Don't like the use of registrymembermanisys13:31 24 Mar '08  
GeneralSource CodememberMArrington4:23 6 Feb '06  
GeneralRe: Source CodememberMike Scanlon9:09 9 Feb '06  
GeneralWorked ok for me in VB.NETmemberDrogil16:33 20 Jul '05  
GeneralNot useful for me ... unless..memberBrett Swift7:00 25 May '05  
GeneralRe: Not useful for me ... unless..memberAngeliyo0:53 15 Jul '05  
GeneralRe: Not useful for me ... unless..memberBlazetopher10:18 3 Jul '06  
Generalusefulmembersreejith ss nair19:09 2 Mar '05  
GeneralOne Thing I'd LikememberDalan Galma15:34 16 Feb '05  
GeneralThis is easy to achievememberkonamiman3423:22 19 Nov '07  
GeneralGreat!memberMach00521:32 19 May '04  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 14 May 2004
Editor: Smitha Vijayan
Copyright 2004 by Mike Scanlon
Everything else Copyright © CodeProject, 1999-2008
Web16 | Advertise on the Code Project