MB_RTLREADING should be treated as an explicit request to mirror the message box, so pass it only when the language of the message being displayed has a right-to-left reading layout.
Why the entire box is mirrored
This is normal Win32 behavior. The window-layout documentation explicitly says that message boxes do not inherit layout and that passing MB_RTLREADING is how an application mirrors one.^1^
An RTL window layout affects more than glyph order: it can change the positions of icons, buttons, the coordinate origin, and other window elements.^1^ That accounts for the icon, OK button, and title-bar close button moving in the screenshot. Mirroring the surrounding UI is also the expected localization model for Arabic and Hebrew interfaces.^2^
It does not reverse the characters in English text. Unicode bidirectional processing still keeps an English run left-to-right even when its containing layout is RTL.^3^
What “on Hebrew and Arabic systems” means
That phrase in the MessageBoxW flag table is misleading if read as a prerequisite enforced by Windows. The same documentation elsewhere describes MB_RTLREADING as the option used to mirror a message box, and the flag is honored even when the current Windows UI is English.^4^
Do not use the Windows installation language to gate the flag. On current MUI versions of Windows, the install language has a limited role; applications can have user, process, and thread UI-language preferences that differ from it.^5^
Recommended decision rule
Base the decision on the actual localized resource language used for that message box:
- Determine which locale your resource-loading/localization layer selected for
lpTextandlpCaption. - Query that locale’s
LOCALE_IREADINGLAYOUT. - Add
MB_RTLREADINGwhen the returned layout is1, meaning right-to-left.^6^ - Optionally add
MB_RIGHTwhen the message text should also be right-justified; it is a separate flag from RTL reading order.^4^
#include <windows.h>
bool IsRtlLocale(PCWSTR localeName)
{
DWORD layout = 0;
int result = GetLocaleInfoEx(
localeName,
LOCALE_IREADINGLAYOUT | LOCALE_RETURN_NUMBER,
reinterpret_cast<LPWSTR>(&layout),
sizeof(layout) / sizeof(WCHAR));
return result != 0 && layout == 1;
}
UINT flags = MB_OK | MB_ICONERROR;
if (IsRtlLocale(activeResourceLocaleName))
flags |= MB_RTLREADING | MB_RIGHT;
MessageBoxW(owner, message, caption, flags);
GetLocaleInfoEx supports numeric locale information through LOCALE_RETURN_NUMBER and returns zero on failure, in which case GetLastError provides the error.^7^
Your current user-UI-language check is sensible if the application always displays resources in that language. If the application has its own language selector, uses thread/process preferred UI languages, or falls back to another resource language, test the language actually selected for the displayed strings instead. Otherwise, an Arabic UI preference combined with an English fallback message could produce exactly the mixed result shown: mirrored chrome around English text.
References