首先是MessageBox中如何將按鈕中的文字顯示為其他語言。MessageBox要使用 MessageBoxEx才可以,其定義如下:
int WINAPI MessageBoxEx(
_In_opt_ HWND hWnd,
_In_opt_ LPCTSTR lpText,
_In_opt_ LPCTSTR lpCaption,
_In_ UINT uType,
_In_ WORD wLanguageId
);
最后一個參數MSDN上給出的解釋是:
wLanguageId [in]
Type: WORD
The language for the text displayed in the message box button(s). Specifying a value of zero (0) indicates to display the button text in the default system language. If this parameter is MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), the current language associated with the calling thread is used.
To specify a language other than the current language, use the MAKELANGID macro to create this parameter. For more information, see MAKELANGID.
意思就是我們需要用函數MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),來生成最后一個參數。它的定義為
WORD MAKELANGID(
USHORT usPrimaryLanguage,
USHORT usSubLanguage
);
微軟給我們提供了足夠多的語言支持,關于這兩個參數可以參見微軟提供的Language Identifier Constants and Strings表格。從表格中查找相應的語言的PrimaryLanguage和SubLanguage即可。如英語為:LANG_ENGLISH 和 SUBLANG_ENGLISH_US ,可以寫成MAKELANGID(LANG_ENGLISH , UBLANG_ENGLISH_US );
最后舉一個例子:
MessageBoxEx(NULL,L"This is an English MessageBox!",L"Alert",MB_OKCANCEL,MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));

下面介紹一下如何修改Dialog中的默認按鈕上的文字,這里只介紹系統定義的Dialog,如:CFileDialog。(Customer Dialog 也沒有做這些的意義了,因為直接修改按鈕的Caption 屬性即可)。修改Dialog的默認按鈕文字只需要在創(chuàng)建Dialog前加上一句:
SetThreadUILanguage(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT));
即可,參數中MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)的使用和上文的使用方法中一樣。