2013-08-30 69 views
0

我在MFC DOC/VIEW應用程序中出現了一些錯誤,轉換LPCTSTR參數(szNewChr),錯誤:錯誤C2664:'int ATL :: CStringT :: Find(wchar_t,int)throw()const' :無法將參數1從'const char [2]'轉換爲'wchar_t', 和atof方法,我得到錯誤:錯誤C2664:'atof':無法將參數1從'CString'轉換爲'const char *'MFC轉換錯誤

這是我的方法:

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; 

}

這些數據成員中所定義.h文件中:

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

我想看到它的工作完全基於對話框的應用... 在此先感謝。

+0

請參閱[本](http://stackoverflow.com/a/18471079/1889329)。它解決了同樣的問題。 – IInspectable

回答

1

我認爲這是一個與多字節和unicode相關的問題。將屬性 - >常規 - >字符集切換到「使用多字節字符集」模式。

如果您仍想使用Unicode模式,請將所有常量字符串從「...」更改爲_T(「...」),將'*'更改爲_T('*')。將atof更改爲_ttof。

+0

謝謝你的幫助... – user2622378