?
Solved

How do I change the button label text on a one-button MessageBox to a phrase of my choice?

Posted on 2006-05-04
9
Medium Priority
?
222 Views
Last Modified: 2012-05-05
I am writing in C, and compiling with Visual Studio 6.0.
 
I have a message box coded as follows:

MessageBox(FocusWnd(), (LPSTR) s, (LPSTR) MsgCaption(),MB_ICONHAND | MB_OK | MB_SYSTEMMODAL);

However, I would like the OK button to instead be labelled "Continue".

Please advise me how to change this line of code to achieve that.

Also, I'd like the same solution for a two-button dialog box. Thank you in advance!
0
Comment
Question by:davidbermancom
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 16606279
>>However, I would like the OK button to instead be labelled "Continue".

That's not possible with a standard MessageBox. Your choices are

MB_ABORTRETRYIGNORE   The message box contains three pushbuttons: Abort, Retry, and Ignore.

MB_OK   The message box contains one pushbutton: OK.

MB_OKCANCEL   The message box contains two pushbuttons: OK and Cancel.

MB_RETRYCANCEL   The message box contains two pushbuttons: Retry and Cancel.

MB_YESNO   The message box contains two pushbuttons: Yes and No.

So either you go with one of them or you'll have to create your own little dialog for that.
0
 

Author Comment

by:davidbermancom
ID: 16606929
Thank you. Those choices are not sufficient for me. I am thinking that certainly someone has written a shareable MessageBoxImproved routine that allows the the text for each button to be specified as a parameter?
0
 
LVL 86

Accepted Solution

by:
jkr earned 1200 total points
ID: 16607803
You'll find something like that e.g. at http://www.codeproject.com/dialog/xmessagebox.asp - but it's C++.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:sathisemail
ID: 16636665
Hi,
  You can also look at the following links to get an idea of how to implement custom message boxes

http://www.codeproject.com/cs/miscctrl/MessageBoxEx.asp
http://www.codeguru.com/vb/controls/vb_othctrl/ocxcontrols/article.php/c1519/
0
 
LVL 20

Expert Comment

by:Daniel Van Der Werken
ID: 16658421
A message box is a resource that's pre-built and linked into your app.  In the standard message box case, it's part of another DLL.  You'll need to write your own custom message box.  You can do that with the resource editor in Visual Studio. Call this instead of the standard MessageBox() call.
0
 

Author Comment

by:davidbermancom
ID: 16687079
Thank you all. I implemented xmessagebox.asp as suggested by jkr, and seem to be one step from success; however now I get

"error LNK2001: unresolved external symbol "int __cdecl XMessageBox(struct HWND__ *,char const *,char const *,unsigned int,struct XMSGBOXPARAMS *)" (?XMessageBox@@YAHPAUHWND__@@PBD1IPAUXMSGBOXPARAMS@@@Z)
: fatal error LNK1120: 1 unresolved externals
Error executing link.exe."

when I enable my first call to xmessagebox. If I comment out the one call to xmessagebox, the error message does not occur.


This is the the call to XMessageBox:

if (IDCUSTOM1 == XMessageBox(
      NULL, //NULL = no owner window
      ss(1625), //message that appears within the dialog box
      (LPSTR) MsgCaption(), //window title is "xyz"
      MB_ICONQUESTION //display question mark icon
      | MB_DEFBUTTON2 //second button is default button
      | MB_TASKMODAL))

Thank you in advance.
0
 
LVL 3

Assisted Solution

by:sathisemail
sathisemail earned 800 total points
ID: 16687824
Hi,
   I think the error is because you havenot included XMessageBox.cpp and XMessageBox.h files in your project. If you have included these files, then have you given the #include "XMessageBox.h" line in your cpp file where you have called XMessageBox.

Regards
Sathis
0
 

Author Comment

by:davidbermancom
ID: 16877760
My apologies. Based on your advice I was able to get it done. Thank you, all!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.
Suggested Courses
Course of the Month15 days, 19 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question