This is a mirror of official site: http://jasper-net.blogspot.com/

Enhanced MFC Message Boxes

| Sunday, October 24, 2010
MessageBoxDialog.jpg

The Problem

Windows applications often use message boxes for asking the user for some actions or for displaying information messages. From week to week, more applications are getting published, which contain nice message boxes with checkboxes like "Do not display this message again" or "Do not ask this question" again, with which the user is able to customize the application behavior and to get rid of message boxes, which he always wants to answer in the same way.

I also wanted to offer this to the users of my applications. What features should be supported?

The message boxes should support some new style (the MB_??? flags used in a call of AfxMessageBox).
Such message boxes should be entirely written in MFC to enable other MFC developers to make quick and easy customization without having to know much about Windows API calls, just by using the standard MFC classes.
The new message boxes should support the checkboxes mentioned above and should manage automatically to save the state of the checkbox and the answer of the user and not to display the message box again, if the user didn't want it to appear again.
The message boxes should also be easy to integrate into existing applications. In existing applications, I didn't want to change every line of code containing a call to AfxMessageBox to something else. I'd just like to add a few lines of code and all messages boxes should appear in the new way.
Existing Solutions

At CodeProject, there are currently two different interesting solutions for modifying and enhancing the standard Windows message boxes, which can be invoked from MFC based applications by using the AfxMessageBox method:

XMessageBox by Hans Dietrich
TCX Message Box by Thales P. Carvalho
Although these solutions work fine, there were a few problems, because of which I was forced to offer a third solution:

  • Both solutions can be used in MFC based applications, but offer only little or even no support for the standard MFC classes. For example, in one application, all dialogs are not derived from the MFC CDialog class directly, but from another class, which draws a custom skin for the dialog instead of the standard skin. If I want to use the message boxes provided by the two solutions mentioned above in this case, I have to apply many changes in the source code. My solution is entirely based upon MFC classes. It can therefore be easily modified and is for people like me, who enjoy using MFC and do not want to get deep into Windows API calls and is more easy to understand.
  • The XMessageBox class supports "Do not ask again" or "Do not display again" checkboxes in the displayed message boxes. This feature is also supported by my CMessageBoxDialog class. The problem with the XMessageBox class from my point of view has been, that the state of the checkboxes, which has been stored in the registry, was stored there in a way, which is not the standard way by using the WriteProfileInt or GetProfileInt methods of the CWinApp class. This might seem to be only a little problem, but I'd like to get the values stored in the same places as all other profile values are stored automatically by the MFC framework.
  • At last, the layout of the message boxes generated by the two classes mentioned above didn't seem to me quite the way I'd like it to be, therefore I changed it a little bit.

How to Use CMessageBoxDialog

Read more: Codeproject

Posted via email from .NET Info

19 comments:

Anonymous said...

buy alprazolam online without prescription how to order xanax bars online - illegal order xanax online

Anonymous said...

buy ativan lorazepam 1mg tablets side effects - ativan overdose in elderly

Anonymous said...

ativan price ativan with alcohol side effect - ativan dosage .5

Anonymous said...

ambien without a rx buy ambien argentina - buy ambien hong kong

Anonymous said...

xanax online xanax overdose erowid - 2 mg xanax effects

Anonymous said...

cheap xanax online xanax side effects ed - xanax drug reference

Anonymous said...

valium 10mg valium vs ativan - valium dosage vasectomy

Anonymous said...

buy xanax online overnight delivery generic xanax pictures of pills - generic vs non generic xanax

Anonymous said...

buy generic ativan buy ativan online in canada - ativan side effects fda

Anonymous said...

valium diazepam diazepam generic drug - diazepam before surgery

Anonymous said...

lorazepam without prescription ativan 6 weeks - ativan juice

Anonymous said...

buy somas online somanabolic muscle maximizer and all bonus programs free download - buy soma safely online

Anonymous said...

buy ambien online ambien side effects withdrawal - zolpidem tartrate side effects

Anonymous said...

carisoprodol without prescription soma drug india - buy soma american express

Anonymous said...

buy ambien online image of ambien pill - ambien cr online pharmacy

Anonymous said...

buy ambien online buy ambien online - zolpidem or ambien cr

Anonymous said...

valium without prescriptions much does valium cost - can you order valium online

Anonymous said...

where to buy valium where to buy valium uk - methadone valium drug interactions

Anonymous said...

soma online pharmacy what is the drug soma used to treat - pass drug test soma