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

Posted on 2006-05-04
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!
Question by:davidbermancom
    LVL 86

    Expert Comment

    >>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.

    Author Comment

    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?
    LVL 86

    Accepted Solution

    You'll find something like that e.g. at - but it's C++.
    LVL 3

    Expert Comment

      You can also look at the following links to get an idea of how to implement custom message boxes
    LVL 19

    Expert Comment

    by:Daniel Van Der Werken
    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.

    Author Comment

    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.
    LVL 3

    Assisted Solution

       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.


    Author Comment

    My apologies. Based on your advice I was able to get it done. Thank you, all!

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    Suggested Solutions

    An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
    Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
    The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them 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.

    729 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

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now