Similar Threads
1. CString.FormatMessage and CString.Format difference
2. CString link error in VC7 with MFC extersion dll which export functions using CString as parameter
3. CString.FormatMessage and CString.Format difference
4. 'CMap' of 'CString' to 'CString'
Hello!
I'm trying to create a dictionary with both key and value of type
'CString'. I declare the object of 'CMap' so it is as closer to
std::map, as possible:
CMap<CString, const CString&, CString, const CString&> m_appLangs;
and semantically it's like this:
std::map<std::string, std::string> m_appLangs;
But it seems 'CMap' is not realized as an RB-tree, I guess it must be
realized through hash table. The problem is when I make the above
declaration, my source file refuse to compile. Here is the simplified
error message:
cannot convert from 'const CString' to 'DWORD_PTR'
see reference to function template instantiation 'UINT
HashKey<ARG_KEY>(ARG_KEY)' being compiled with
[ARG_KEY=const CString &]
Here is the code of 'HashKey' function from "afxtempl.h":
template<class ARG_KEY>
AFX_INLINE UINT AFXAPI HashKey(ARG_KEY key)
{
// default identity hash - works for most primitive values
return (DWORD)(((DWORD_PTR)key)>>4);
}
And what does it mean? Can't I create a map of string to string just
because there is no conversion from 'CString' to 'DWORD_PTR'? I think/
hope I'm wrong. Would you please show me my mistake?
Thanks in advance
Martin
5. CString hex value to CString decimal value
6. Unable to convert from ATL::CString to vector<CString>::iterator
Hi Guys,
I am going through the lengthy process of upgrading from a VS6 project to
VS2005.
The only issue I am left with is that I cannot work how to convert from a
CString as part of an array to a vector iterator.
The code is as follows
vector<CString>::iterator ii =
vector<CString>&(m_vsOverallAgentRetrievalQueueNames[i]);
and the error message is as follows
error C2440: 'initializing' : cannot convert from
'ATL::CStringT<BaseType,StringTraits> *' to
'std::_Vector_iterator<_Ty,_Alloc>'
Can anyone help at all?
Regards
Tony
7. Array of CString s vs. CString Array
8. Locales and CString::MakeUpper() and CString::CollateNoCase()
I recently discovered that when running my Unicode application on an
English XP system with my locales all set to English (US), the
CString::MakeUpper() function did not convert a Russian text string from
mixed case ( ) to uppercase ( ). The
function that does the actual conversion is _wcsupr_s(). After some
digging, I eventually discovered that the conversion is dependent on the
locale set using the CRT setLocale() function. When I set the locale
using setLocale(LC_ALL, ".1251"), the CString::MakeUpper() function
worked as expected.
This seems wrong to me. If I have Unicode text in many different
languages, I cannot know which code page to set to make the MakeUpper()
function work. One reason for switching to Unicode is that we don't want
to worry about code pages.
The CString::CollateNoCase() works similarly. If I call this function
with the two Russian text strings listed above, the return is non-zero
unless I first set the locale to use code page 1251.
Why does CStringW::MakeUpper() use the locale dependent _wcsupr_s()
function rather than the CharUpperBuff() function, which works
correctly? At this point, it looks like my only option is to find all
places where we use CollateNoCase(), MakeUpper(), and MakeLower() and
replace them with our own functions to do these tasks. Am I missing
something? Does anyone have an idea for a better solution?