Thank you for the interesting question. Here is how to do this:
1) Please insert the following class into your project:
class CMyKeyTip : public CExtCustomizeCmdKeyTip
{
public:
DECLARE_SERIAL( CMyKeyTip );
CMyKeyTip() { }
CMyKeyTip( const CMyKeyTip & other ) : CExtCustomizeCmdKeyTip( other ) { }
CMyKeyTip( __EXT_MFC_SAFE_LPCTSTR str ) : CExtCustomizeCmdKeyTip( str ) { }
CMyKeyTip( __EXT_MFC_SAFE_TCHAR _tchr ) : CExtCustomizeCmdKeyTip( _tchr ) { }
virtual ~CMyKeyTip() { }
virtual CExtSafeString GetTipText( INT nIndent ) const
{
ASSERT_VALID( this );
HKL hKeyboardLayout = ::GetKeyboardLayout( ( ::AfxGetThread() ) -> m_nThreadID );
CExtSafeString strTipText( _T("") );
INT nIndex, nCount = KeyCodeGetCount();
for( nIndex = nIndent; nIndex < nCount; nIndex ++ )
{
DWORD dwKeyCode = KeyCodeGetAt( nIndex );
TCHAR vkTCHAR = (TCHAR)dwKeyCode;
BYTE lpKeyState[256];
::GetKeyboardState( lpKeyState );
UINT wScanCode = ::MapVirtualKey( vkTCHAR, 0 );
#if (defined _UNICODE)
TCHAR szChar[2] = { _T(’\0’), _T(’\0’) };
::ToUnicodeEx( vkTCHAR, wScanCode, lpKeyState, szChar, 1, 1, hKeyboardLayout );
#else
WORD nMapped = 0;
::ToAsciiEx( vkTCHAR, wScanCode, lpKeyState, &nMapped, 1, hKeyboardLayout );
TCHAR szChar[2] = { (TCHAR)nMapped, _T(’\0’) };
#endif
::CharUpper( szChar );
strTipText += szChar;
}
return strTipText;
}
};
IMPLEMENT_SERIAL( CMyKeyTip, CExtCustomizeCmdKeyTip, VERSIONABLE_SCHEMA|1 );
2) Please use the
CMyKeyTip
class instead of the
CExtCustomizeCmdKeyTip
class in the initialization code for all the ribbon nodes. You should specify English letters while initializing key tip texts.
3) Remove the application state from the system registry.
Now the ribbon bar will display key tips using currently selected keyboard input language. Is that what you need?