当前位置: 代码迷 >> VC >> vs2005中的CString有关问题
  详细解决方案

vs2005中的CString有关问题

热度:5557   发布时间:2013-02-25 00:00:00.0
vs2005中的CString问题
void CText3View::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
CClientDC dc(this);
TEXTMETRIC tm;
dc.GetTextMetrics(&tm);
if( 0x0d == nChar)
{

m_strLine.Empty();
m_ptOrigin.y +=tm.tmHeight;

}
else if( 0x08d == nChar)
{
COLORREF clr = dc.SetTextColor(dc.GetBkColor());
dc.TextOut(m_ptOrigin.x,m_ptOrigin.y,m_strLine);
m_strLine = m_strLine.Left(m_strLine.GetLength() - 1);
dc.SetTextColor(clr);
}
else
{
m_strLine += nChar;[color=#FF0000][/color]
}
CSize sz = dc.GetTextExtent(m_strLine);
CPoint pt;
pt.x = m_ptOrigin.x +sz.cx;
pt.y = m_ptOrigin.y;
SetCaretPos(pt);
dc.TextOut(m_ptOrigin.x,m_ptOrigin.y,m_strLine);


CView::OnChar(nChar, nRepCnt, nFlags);
}

在小弟标记处出现错误'ATL::CStringT<BaseType,StringTraits>::operator +' : 3 overloads have similar conversions
  with
  [
  BaseType=wchar_t,
  StringTraits=StrTraitMFC_DLL<wchar_t>
  ]
  d:\program files\microsoft visual studio 8\vc\atlmfc\include\cstringt.h(2326): could be 'ATL::CStringT<BaseType,StringTraits> ATL::CStringT<BaseType,StringTraits>::operator +(const ATL::CStringT<BaseType,StringTraits> &,char)' [found using argument-dependent lookup]
  with
  [
  BaseType=wchar_t,
  StringTraits=StrTraitMFC_DLL<wchar_t>
  ]
  d:\program files\microsoft visual studio 8\vc\atlmfc\include\cstringt.h(2316): or 'ATL::CStringT<BaseType,StringTraits> ATL::CStringT<BaseType,StringTraits>::operator +(const ATL::CStringT<BaseType,StringTraits> &,wchar_t)' [found using argument-dependent lookup]
  with
  [
  BaseType=wchar_t,
  StringTraits=StrTraitMFC_DLL<wchar_t>
  ]
  or 'built-in C++ operator+(const wchar_t *, UINT)'
  while trying to match the argument list '(CString, UINT)'

以上是编译出错处,请高手来帮帮忙啊。很是郁闷啊。

------解决方案--------------------------------------------------------
m_strLine += (char)nChar;
  相关解决方案