我如何获得的MessageBox按钮标题? [英] How do I get MessageBox button caption?

查看:227
本文介绍了我如何获得的MessageBox按钮标题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在做一个自定义的消息框,让您复制文本,但我希望它看起来就像一个标准的消息框,所以我想设置的按钮文字的任何系统的语言,因为MessageBox类确实。 有谁知道如何获得该文本(是,否,取消,等等)?

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

推荐答案

谢谢您的回答与Snarfblam链接我能想出的其余部分。

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

class Program {

[DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern int LoadString(IntPtr hInstance, uint uID, StringBuilder lpBuffer, int nBufferMax);
[DllImport("kernel32")]
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();

}

这篇关于我如何获得的MessageBox按钮标题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆