Click here to Skip to main content
6,292,811 members and growing! (11,226 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#.NET 1.1, Win2K, WinXP, Win2003VS.NET2003, Dev
Posted:14 May 2004
Views:66,215
Bookmarked:50 times
Announcements
Loading...
 
Search    
Advanced Search
printPrint   Broken Article?Report       add Share
  Discuss Discuss   Recommend Article Email
20 votes for this article.
Popularity: 4.87 Rating: 3.74 out of 5
1 vote, 5.0%
1
2 votes, 10.0%
2
5 votes, 25.0%
3
3 votes, 15.0%
4
9 votes, 45.0%
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


Member
Visit http://mike.pricklysoft.com

Occupation: Web Developer
Location: United States United States

Other popular Dialogs and Windows articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 25 of 26 (Total in Forum: 26) (Refresh)FirstPrevNext
Generalrendering problems sometime PinmemberSergey Kolomenkin3:48 17 Mar '09  
Generalsource code Pinmemberstadelmann-peter7:32 17 Dec '08  
GeneralRe: source code Pinmemberdonor5:52 23 Dec '08  
GeneralWhere do I find the MsgBoxCheck.dll file PinmemberGlade Ross12:02 14 Jul '08  
GeneralRe: Where do I find the MsgBoxCheck.dll file PinmemberHantou11:40 30 Apr '09  
GeneralParameter to set the default button please PinmemberSuperCoder!4:16 19 Jun '08  
QuestionVista Problem PinmemberTurulo10:33 10 Apr '08  
AnswerRe: Vista Problem PinmemberSuperCoder!4:11 19 Jun '08  
GeneralLicense Attached Pinmemberrsbiz20042:07 26 Mar '08  
GeneralAnd in vbnet ? Pinmemberscalpa989:31 22 Sep '07  
GeneralRe: And in vbnet ? Pinmemberrsbiz20043:44 24 Mar '08  
Generalhow to use this from a visual c++ sln? Pinmemberlaura_glow11:06 13 Jun '07  
Generalimplementation to HTML Pinmemberjameo184:48 6 Jun '07  
GeneralMsgBoxCheck.dll source code or reg path Pinmemberwilsoada13:37 13 Dec '06  
GeneralDon't like the use of registry PinmemberPiotr Perak5:06 20 Oct '06  
GeneralRe: Don't like the use of registry Pinmembermanisys13:31 24 Mar '08  
GeneralSource Code PinmemberMArrington4:23 6 Feb '06  
GeneralRe: Source Code PinmemberMike Scanlon9:09 9 Feb '06  
GeneralWorked ok for me in VB.NET PinmemberDrogil16:33 20 Jul '05  
GeneralNot useful for me ... unless.. PinmemberBrett Swift7:00 25 May '05  
GeneralRe: Not useful for me ... unless.. PinmemberAngeliyo0:53 15 Jul '05  
GeneralRe: Not useful for me ... unless.. PinmemberBlazetopher10:18 3 Jul '06  
Generaluseful Pinmembersreejith ss nair19:09 2 Mar '05  
GeneralOne Thing I'd Like PinmemberDalan Galma15:34 16 Feb '05  
GeneralThis is easy to achieve Pinmemberkonamiman3423:22 19 Nov '07  

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-2009
Web09 | Advertise on the Code Project