Wednesday, 17 August 2011

Message Box with custom commit buttons

Windows API and MFC framework offer ready to use Message Box dialog which can display, depending on a provided flag, one or group of more commit buttons with captions from a predefined set: OK, Yes, No, Cancel, Abort, Retry and Ignore. If dialog contains a question, it is a good practice to make buttons displaying specific responses, e.g. "Run" - "Don't run", "Apply" - "Don't apply" etc. The easiest and quickest way to achieve this is to create a new, custom dialog and add onto it buttons with desired text. Resource editor in Visual Studio creates by default dialog with two buttons, OK and Cancel and you can rename them, providing that new captions will match OK and Cancel functionality. For other buttons, add BN_CLICKED handlers (ON_BN_CLICKED entry in message map). The purpose of this dialog is just to pick the user's answer on a question and not to do any hard work. Caller should read return value of (custom) Message Box and take further actions depending on it.

Return value of the standard message box (one from a predefined set IDOK, IDYES, ...) identifies user's choice and we can return these predefined values or our custom return codes, e.g. ID_RUN, ID_APPLY...We can also reuse resource ID values of our custom buttons for this purpose. Standard Message Box is a modal dialog so our dialog needs to be created as modal (CDialog::DoModal). DoModal returns value that was passed to CDialog::EndDialog. This function should be called in our custom button BN_CLICKED handlers.

In the following example, our custom Message Box has button "Apply". Its BN_CLICKED handler is OnBnClickedButtonApply. Caller identifies user's choice with DoModal return value:

Our Message Box which has "Apply" button:

Caller:

27 comments:

Jack Alexa said...

I'm very Glad to visit your informational Post. Custom Window Boxes Packaging boxes are really necessary for any kind of product. If you want to pack your products in a stylish way then use these Custom Window Boxes with customized designs, styles, colors, shapes, and stocks. We are also offering error-free design and free shipping services all over the USA.

Custom Packaging Boxes said...

Your article has really good reading, thought-provoking information. You make several sound points I find agreeable. Your article is a good example of superior writing from a writer that cares. Thanks for sharing this information. Custom Window Boxes

thomasjack said...

I appreciate your post thanks for sharing the information.
Cake boxes Kentucky
Candle boxes Kentucky

thomasjack said...

Amazing product thanks for sharing with us It is very informative.
custom boxes Kansas
apparel box manufacturer

thomasjack said...

Amazing product thanks for sharing with us It is very informative.
custom boxes Kansas
apparel box manufacturer

markthomson said...

I felt exceptionally cheerful while perusing this site. This was truly extremely instructive site for me. I truly enjoyed it. This was truly a sincere post. Much obliged!. Custom Boxes with logo

Teresa D Dolan said...

Thank you for sharing this article. It's really informative article. I really enjoy your site I am waiting for a new article.
cigarette boxes
vape cartridge packaging

Serina johson said...

Good blog thanks for sharing the information.
Photography Packaging packaging USA
cheap custom Perfume Boxes

Chris Michael said...

All details you describe in your blog post about cigarette boxes is very informative for me. Cigarette boxes provides with suitable price.

Custom Packaging Boxes said...

Our service has been very supportive to our customers and especially in solving their problems and providing them with the best boxes which are fully credible and worthy of their trust.
reverse tuck end boxes
straight tuck end boxes
custom pen boxes

Custom Printing Solution USA said...

I am very glad to read your blog. Packaging is important for any kind of product but for candle boxes it's very important. CustomBoxesU provide every kind of boxes in different sizes, shapes and layout.

micheal pan said...

BE SMART AND BECOME RICH IN LESS THAN 3DAYS....It all depends on how fast 
you can be to get the new PROGRAMMED blank ATM card that is capable of
hacking into any ATM machine,anywhere in the world. I got to know about 
this BLANK ATM CARD when I was searching for job online about a month 
ago..It has really changed my life for good and now I can say I'm rich and 
I can never be poor again. The least money I get in a day with it is about 
$50,000.(fifty thousand USD) Every now and then I keeping pumping money 
into my account. Though is illegal,there is no risk of being caught 
,because it has been programmed in such a way that it is not traceable,it 
also has a technique that makes it impossible for the CCTVs to detect 
you..For details on how to get yours today, email the hackers on : (
atmmachinehackers1@gmail.com ). Tell your 
loved once too, and start to live large. That's the simple testimony of how 
my life changed for good...Love you all ...the email address again is ;
atmmachinehackers1@gmail.com

David Luke said...

Hi, I hope You are fine. Your work is very good. I read all your published blogs. Your blogs are very informative for me and hope so for everyone. I should be very thankful to you and Your Team. I offered all of You my business which is related to Custom Lotion Boxes. My company name is Rush Packaging. We offered You Custom Boxes all over the World with Free Shipping and Wholesale Rate. We delivered our service on time.
Custom Hairspray Boxes
Hair Extension Boxes
Custom Nail Polish Boxes
Custom Eyeliner Boxes
Custom Boxes

Marketing Expert said...

Well-manufactured cigarette boxesgives numerous benefits to your tobacco business. Marketing conditions are getting tough so, you can’t sell cigarettes without packaging boxes.

Jack Alexa said...

I'm very Glad to visit your informational Post. Cannabis Cigarette Boxes Packaging boxes are really necessary for any kind of product. If you want to pack your products in a stylish way then use these Cannabis Cigarette Boxes with customized designs, styles, colors, shapes, and stocks. We are also offering error-free design and free shipping services all over the USA.

manahilafzal123 said...

bespoke packaging boxes At Bespoke Packaging UK we strongly believe in the interests of bespoke packaging, which has multiple benefits.

manahilafzal123 said...

birthday blessings

Olaf Ae said...

We are specialized in providing express transportation (Heathrow Taxi), services for to and from all London, UK Cruise Ports, to and from anywhere in the UK.heathrow executive taxi

Olaf Ae said...

London Chauffeurs have been successfully delivering exceptional risk-based, protective driver services for vips and those with specialist requirements since our inception. If you are looking for the best stress-free service look no further.Heathrow chauffeur service

Olaf Ae said...

can cater for clients all around Kent and Builders South East London. We are specialists in building services such as new builds, loft conversions, extensions and renovations of existing properties.Plumbers in South East London

Olaf Ae said...

Make the most of your time, increase productivity while you travel London Chauffeurs or relax and unwind. Whether you’re an executive or travelling, our service is perfect for those who want a great, stress free, safe, travel experience.Heathrow chauffeur service

Olaf Ae said...

Understanding that many of you also have very different budgets to work with, we have evaluated best crossbow and carefully prepared a list of the best in each of five price points.best crossbow under 500

Olaf Ae said...

Once you purchase this Power Tools Report, we will deliver the Hand Power Tool Manufacturing in the UK report to you within 5 business days. Our team of in house analysts will immediately start work gathering data and industry insights. Purchase this report to get started. Best Single Stage Snow Blower
best 2 stage snow blower

Olaf Ae said...

We work with your best local Dry cleaners Norwich to provide the service directly to your door.Laundry service Norwich

UNKNOWN said...

Positive site, where did u come up with the information on this posting?I have read a few of the articles on your website now, and I really like your style. Thanks a million and please keep up the effective work. good choice of stash jars at Cannaline

Chris Michael said...


I am very glad to read your blog. Packaging is necessary for any kind of product but for pre roll boxes is very necessary. CustomBoxesU provide best quality packaging suitable price.

James Anderson said...
This comment has been removed by the author.