PDA

View Full Version : Set Message Box Button Text at runtime



meercat
04-24-2008, 04:04 AM
Is it possible to set the button text at run time. I want to use three buttons on a Message Box, but with different strings, and I don't want to change the language string values to do that.

Thanks,
Alex

linder
04-24-2008, 05:29 AM
Alex,

I assume you mean the button text in "Display Message Box..." (e.g. OK, Yes, No) and not in the Dialog Wizard (Next, Back, etc.), right?

You can't change the text on a "Display Message Box" because this is a call to the MessageBoxA Windows API and Windows displays the button text automatically (based on the selected Windows version language).

Does this help?

Friedrich

meercat
04-24-2008, 07:17 AM
Yes and no.

It helps that I now know I have to look to try something else.

It doesn't help because I wish I didn't have to.

Does that explain my position?

Regards,
Alex

linder
04-24-2008, 07:37 AM
Yes, that explains your position very well.

What you can do is to develop your own MessageBox function in form of a DLL and call it from the installer. In your DLL, install a window hook, so you can intercept the standard message-box creation, and customize it.

BTW, the uninstaller itself uses such a "hooked" MessageBox function to display the DeleteSharedFile (Yes, Yes to All, No) and DeleteFile (Retry, Continue) message boxes. It's a native Windows MessageBox, but the hook allows us to change the text of the buttons.

Friedrich

meercat
04-24-2008, 07:41 AM
Hi,

Is it possible to call the DLL you already have, or is it not accessible?

Regards,
Alex

linder
04-24-2008, 07:59 AM
Alex,

In our case, the function is not in a DLL. It's directly in the SetupBuilder installer engine and is used internally. We had to provide a way to have the text "Yes", "Yes to All" and "No" and "Retry" and "Continue" on buttons in a standard Windows MessageBox. The MessageBox Windows API does not allow to change the text on message boxes, so we developed the "hook" solution. Because you would like to change the text on standard Windows message boxes, my suggestion was develop a DLL that supports a similar method and call it from the installer. If you are a C/C++ developer, you can develop such a MessageBox "hook" with 20-25 lines of C/C++ code and the DLL will be only 10 KB uncompressed (compiled with Visual Studio).

Friedrich