Better still, use ClassWizard to create control variables. Rule of
thumb: if you write more than one GetDlgItem per year, you are not
using
MFC properly. I use a c_ prefix instead of the m_ prefix when
I'm creating a control variable.
CString s;
int sel = c_ListBox.GetCurSel();
if(sel != LB_ERR)
{
c_ListBox.GetText(sel, s);
c_EditControl.SetWindowText(s);
}
I find this code far easier to write and use.
joe
On Sat, 29 May 1999 23:45:56 +0100, "Adrian O' Neill"
Quote:
>Hi,
>Assuming that the list box is single selection (properties dialog in the
>dialog resource editor)
>CString strOut;
>CListBox* pListBox = (CListBox*) GetDlgItem(IDC...);
>int nSel = pListBox->GetCurSel();
>if (nSel != LB_ERR) {
> pListBox->GetText(nSel, strOut);
>}
>strOut is the string. Not compiled, but should work ok.
Joseph M. Newcomer
http://www3.pgh.net/~newcomer