Take the 2-minute tour ×

I'm making a custom message box that lets you copy text, but I wanted it to look exactly like a standard message box, so I would like to set the buttons text to whatever the system language is, as the MessageBox class does. Does anyone knows how to get that text ("Yes", "No", "Cancel", etc)?.

share|improve this question
If you don't find a solution, perhaps you can put the message text on the clipboard instead and inform the user the message is on the clipboard. –  Stormenet May 31 '09 at 17:32
If you press Ctrl+C when a standard MessageBox is shown, it will copy the text to the clipboard by default. –  Dan Walker May 31 '09 at 17:49
Thanks for the tip, but anyway I need more customization like scroll bars for bigger messages. –  rodrigoq May 31 '09 at 18:18

5 Answers 5

up vote 6 down vote accepted

Thanks for your answers with Snarfblam link I could figure out the rest.

class Program {

static extern IntPtr LoadLibrary(string lpFileName);

private const uint OK_CAPTION = 800;
private const uint CANCEL_CAPTION = 801;
private const uint ABORT_CAPTION = 802;
private const uint RETRY_CAPTION = 803;
private const uint IGNORE_CAPTION = 804;
private const uint YES_CAPTION = 805;
private const uint NO_CAPTION = 806;
private const uint CLOSE_CAPTION = 807;
private const uint HELP_CAPTION = 808;
private const uint TRYAGAIN_CAPTION = 809;
private const uint CONTINUE_CAPTION = 810;

static void Main(string[] args) {
	StringBuilder sb = new StringBuilder(256);

	IntPtr user32 = LoadLibrary(Environment.SystemDirectory + "\\User32.dll");

	LoadString(user32, OK_CAPTION, sb, sb.Capacity);
	string ok = sb.ToString();

	LoadString(user32, CANCEL_CAPTION, sb, sb.Capacity);
	string cancel = sb.ToString();

	LoadString(user32, ABORT_CAPTION, sb, sb.Capacity);
	string abort = sb.ToString();

	LoadString(user32, RETRY_CAPTION, sb, sb.Capacity);
	string retry = sb.ToString();

	LoadString(user32, IGNORE_CAPTION, sb, sb.Capacity);
	string ignore = sb.ToString();

	LoadString(user32, YES_CAPTION, sb, sb.Capacity);
	string yes = sb.ToString();

	LoadString(user32, NO_CAPTION, sb, sb.Capacity);
	string no = sb.ToString();

	LoadString(user32, CLOSE_CAPTION, sb, sb.Capacity);
	string close = sb.ToString();

	LoadString(user32, HELP_CAPTION, sb, sb.Capacity);
	string help = sb.ToString();

	LoadString(user32, TRYAGAIN_CAPTION, sb, sb.Capacity);
	string tryAgain = sb.ToString();

	LoadString(user32, CONTINUE_CAPTION, sb, sb.Capacity);
	string cont = sb.ToString();

share|improve this answer

These strings appear to be stored in the User32.dll library. There are details in this discussion on the Pure BASIC forum, towards the bottom.

share|improve this answer
Thank you very much with that I could find the solution, I will post the code in a few minutes. –  rodrigoq May 31 '09 at 17:57

There is an article on codeproject.com that talks about localizing message boxes - you might find this link useful...


Hope it helps :)

share|improve this answer
Thank you I've been looking for this for so long! This is VERY useful –  BornToCode Sep 13 '12 at 19:47

You might open the System.Windows.Forms.dll in Reflector and see how it is setting the button text.

share|improve this answer
I did that, but the message box call is a function in user32.dll so the text is obtained in low level, I'm sure there is an api to get it. –  rodrigoq May 31 '09 at 17:24

In the time you typed that message, you could have typed "Yes", "No", "Ok", "Cancel"...

share|improve this answer
I'm pretty sure the OP wants to take the text from the system so that it's in the correct language (system locale) –  Adam Pope May 31 '09 at 17:10
Exactly Adam, that's what I need so I don't have to exhaust all languages –  rodrigoq May 31 '09 at 17:19

Your Answer


