Gets a string from a list box.
intGetText(intnIndex,LPTSTRlpszBuffer)const;voidGetText(intnIndex,CString&rString)const;
Parameters
- nIndex
- Specifies the zero-based index of the string to be retrieved.
- lpszBuffer
- Points to the buffer that receives the string. The buffer must have sufficient space for the string and a terminating null character. The size of the string can be determined ahead of time by calling theGetTextLenmember function.
- rString
- A reference to aCStringobject.
Return Value
The length (in bytes) of the string, excluding the terminating null character. IfnIndexdoes not specify a valid index, the return value isLB_ERR.
Remarks
The second form of this member function fills aCStringobject with the string text.
Example
// The pointer to my list box.extern CListBox* pmyListBox;// Dump all of the items in the list box.#ifdef _DEBUG CString str, str2; int n; for (int i=0;i < pmyListBox->GetCount();i++) { n = pmyListBox->GetTextLen( i ); pmyListBox->GetText( i, str.GetBuffer(n) ); str.ReleaseBuffer(); str2.Format(_T("item %d: %s\r\n"), i, str.GetBuffer(0)); afxDump << str2; }#endif
ex>
CString strServiceName = _T("");
m_ServiceList.GetText( m_ServiceList.GetCurSel(), strServiceName );
'Programming > MFC' 카테고리의 다른 글
WaitForSingleObject (0) | 2006.02.06 |
---|---|
CRITICAL_SECTION (0) | 2006.02.06 |
ResetContent (0) | 2006.02.06 |
UpdateData ( FALSE ) (0) | 2006.02.06 |
레지스트리에 등록하고 편리하게 사용 (0) | 2006.01.12 |