开发者

Change language for MessageBox button's text

I'd like to have text on buttons of MessageBox to be, say it, in russian, french, etc. - different language than it's set by default in Windows.

Is there any way to do 开发者_如何学编程it without creating my custom MessageBoxes?


Avoid spending a lot of time and energy on this. The user of your app will always get the message box she's familiar with. It will show the text that matches her language, much like the rest of Windows. Somebody that speaks Russian as her native language is not going to need to switch to French on the fly. If she actually does then she would have purchased a license for the Ultimate edition of Windows which permits changing the Windows language quickly.

Your app will follow suit, as long as you don't override the default culture and have localized your app. Beware that overriding the default culture of the UI thread is a very dangerous thing to do, the threadpool threads that .NET uses (or you for that matter) still run in the default language. This can cause very subtle problems because of the different string comparison rules. For example, a SortedList filled in one thread will suddenly not be sorted anymore in another thread, causing a binary search to malfunction.


The System.Windows.Forms.MessageBox is based on the MessageBox function present in user32.dll which uses the current system language to display the text on the buttons. I don't know if there is a way of overriding that, and rolling your own message box looks like the best option available.


Change the Localizable property in your Form to True. Then set the language by changing the Language property.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜