user2622378
user2622378

Reputation: 1

MFC conversion error

I got some errors in my MFC DOC/VIEW app with conversion LPCTSTR parameter(szNewChr), the error: error C2664: 'int ATL::CStringT::Find(wchar_t,int) throw() const' : cannot convert parameter 1 from 'const char [2]' to 'wchar_t', and in atof method, I got error: error C2664: 'atof' : cannot convert parameter 1 from 'CString' to 'const char *'

This is my method:

void CmojaView::UpdateResultsWnd(LPCTSTR szNewChr)
{
// Ensure we are not trying to add a second decimal point!
if(szNewChr == "." && m_strCurrentEntry.Find(".") != -1)
    return;

// Update the private member variables
m_strCurrentEntry+=szNewChr;
CString strCurrentEntry(m_strCurrentEntry);
strCurrentEntry.Remove('*');
strCurrentEntry.Remove('/');
m_fResultsWndValue=atof(strCurrentEntry);
m_nClearBtnStatus=0;

}

These are data members defined in .h file:

CString m_strCurrentEntry;      
double m_fResultsWndValue;      
double m_fRunningTotal;         
char m_cLastOp;                 
int m_nClearBtnStatus;          
double m_fMemory;               
UINT m_nLastKey;

I would like to notice that it worked perfectly as dialog-based app... Thanks in advance.

Upvotes: 0

Views: 1544

Answers (1)

diwatu
diwatu

Reputation: 5699

I believe this is a problem related to multiple-byte and unicode. Switch you project to 'Use Multiple-Byte Character Set' mode from Properties->General->Character Set.

If you still want use Unicode mode, change all the constant string from "..." to _T("..."), '*' to _T('*'). Change atof to _ttof.

Upvotes: 1

Related Questions