The
lpszText
argument of
SetItemText
is of type
LPCTSTR
string. When having an ANSI string (
LPCSTR
) it must be converted to wide char with Unicode builds.
While this can be converted using
MultiByteToWideChar function (Windows)[
^], using the
CString
class is simpler because that provides such conversions with constructors and assignment operators.
So simply create a
CString
from the ANSI string and pass that:
CString strMac(SP.mac);
m_List_1100.SetItemText(i, 1, strMac.GetString());
To know about the conversion rules see the
CStringT Class[
^].
It uses some predefined types to handle parameters of different types (see
CStringT Predefined Types in the above link). The interesting types for conversion are those with
Y (
YCHAR
,
PYSTR
,
PCYSTR
). They indicate support for characters not matching the build setting (
char
,
LPSTR
,
LPCSTR
for Unicode builds). So when a member function supports one of these types, you can pass an ANSI char or string with Unicode builds. See for example the
CStringT::operator =[
^] and the
CStringT::CStringT[
^] constructor.