MFC中設定CEdit控制項內容時間長度出現的錯誤

來源:互聯網
上載者:User

在用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方法……

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.