在用VS2008開發MFC應用程式時,我們經常會往編輯框設定常值內容:
如:m_usr.SetWindowTextA("Anonymous");//其中,m_usr是一個與CEdit關聯的Control類型變數。
這時候編譯的時候常常會出現下面類型的錯誤:
1>SelfFtpUpDownloader.cpp
1>SelfFtpUpDownloaderDlg.cpp
1>.\SelfFtpUpDownloaderDlg.cpp(183) : error C2039: “SetWindowTextA”: 不是“CEdit”的成員
1> D:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\afxwin.h(3572) : 參見“CEdit”的聲明
1>.\SelfFtpUpDownloaderDlg.cpp(184) : error C2039: “SetWindowTextA”: 不是“CEdit”的成員
1> D:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\afxwin.h(3572) : 參見“CEdit”的聲明
1>.\SelfFtpUpDownloaderDlg.cpp(196) : error C2039: “SetWindowTextA”: 不是“CEdit”的成員
1> D:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\afxwin.h(3572) : 參見“CEdit”的聲明
1>.\SelfFtpUpDownloaderDlg.cpp(197) : error C2039: “SetWindowTextA”: 不是“CEdit”的成員
1> D:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\afxwin.h(3572) : 參見“CEdit”的聲明
1>正在產生代碼...
這時,因為之前我用m_usr.的時候出現了SetWindowTextW這個方法,所以我就把上面的SetWindowTextA這個方法換成了SetWindowTextW方法。但是換了之後會出現下面的錯誤提示:
1>.\SelfFtpUpDownloaderDlg.cpp(183) : error C2664: “CWnd::SetWindowTextW”: 不能將參數 1 從“const char [10]”轉換為“LPCTSTR”
1> 與指向的類型無關;轉換要求 reinterpret_cast、C 樣式轉換或函數樣式轉換
1>.\SelfFtpUpDownloaderDlg.cpp(184) : error C2664: “CWnd::SetWindowTextW”: 不能將參數 1 從“const char [1]”轉換為“LPCTSTR”
1> 與指向的類型無關;轉換要求 reinterpret_cast、C 樣式轉換或函數樣式轉換
1>.\SelfFtpUpDownloaderDlg.cpp(196) : error C2664: “CWnd::SetWindowTextW”: 不能將參數 1 從“const char [1]”轉換為“LPCTSTR”
1> 與指向的類型無關;轉換要求 reinterpret_cast、C 樣式轉換或函數樣式轉換
1>.\SelfFtpUpDownloaderDlg.cpp(197) : error C2664: “CWnd::SetWindowTextW”: 不能將參數 1 從“const char [1]”轉換為“LPCTSTR”
1> 與指向的類型無關;轉換要求 reinterpret_cast、C 樣式轉換或函數樣式轉換
我想到了之前碰到的由於使用字元集的錯誤,於是就把使用Unicode字元集換成使用多字元集的形式,問題還真解決了……
而是設定成使用多字元集形式之後,點之後會出現響應的SetWindowTextA方法……