“void CListBox::GetText(int,CString &) const”: 无法将参数 2 从“char *”转换为“LPTSTR”
时间: 2024-05-29 07:11:46 浏览: 139
&)
The GetText function is a member function of the CListBox class in MFC (Microsoft Foundation Classes). It is used to retrieve the text of a specified item in the list box.
The function takes two parameters: the index of the item whose text is to be retrieved, and a reference to a CString object where the text will be stored.
The syntax of the function is:
void CListBox::GetText(int nIndex, CString& rString) const;
Here, nIndex is the zero-based index of the item whose text is to be retrieved, and rString is a reference to a CString object where the text will be stored.
The function returns void, which means it does not return any value. Instead, the text of the specified item is stored in the CString object passed as the second parameter.
For example, to retrieve the text of the first item in a list box and store it in a CString object named strText, you can use the following code:
CString strText;
m_myListBox.GetText(0, strText);
Here, m_myListBox is an instance of a CListBox control, and GetText is called with the index parameter set to 0 and the CString reference parameter set to strText. The text of the first item in the list box will be stored in the strText variable.
阅读全文