i've got this functions from MFC, but i want to rewrite it using std::string(or std::wstring)
CODE
CString CHotKeyCtrl::GetKeyName(UINT vk, BOOL fExtended)
{
LONG lScan = MapVirtualKey(vk, 0) << 16;
// if it's an extended key, add the extended flag
if (fExtended)
lScan |= 0x01000000L;
CString str;
int nBufferLen = 64;
int nLen;
do
{
nBufferLen *= 2;
LPTSTR psz = str.GetBufferSetLength(nBufferLen);
nLen = ::GetKeyNameText(lScan, psz, nBufferLen + 1);
str.ReleaseBuffer(nLen);
}
while (nLen == nBufferLen);
return str;
}
CString CHotKeyCtrl::GetHotKeyName() const
{
ASSERT(::IsWindow(m_hWnd));
CString strKeyName;
WORD wCode;
WORD wModifiers;
GetHotKey(wCode, wModifiers);
if (wCode != 0 || wModifiers != 0)
{
if (wModifiers & HOTKEYF_CONTROL)
{
strKeyName += GetKeyName(VK_CONTROL, FALSE);
strKeyName += szPlus;
}
if (wModifiers & HOTKEYF_SHIFT)
{
strKeyName += GetKeyName(VK_SHIFT, FALSE);
strKeyName += szPlus;
}
if (wModifiers & HOTKEYF_ALT)
{
strKeyName += GetKeyName(VK_MENU, FALSE);
strKeyName += szPlus;
}
strKeyName += GetKeyName(wCode, wModifiers & HOTKEYF_EXT);
}
return strKeyName;
}
but i can't rewrite it using std::string(in my program i use std::string instead CString), because i don't know std::string protypes for CString::GetBufferSetLength and CString::ReleaseBuffer
This post has been edited by miksayer: 3 Jul, 2009 - 12:15 AM