Hi,
I've tried a number of things but just can't get this to work. I have a list box containing a number of strings:
All I want to be able to do is to store the selected string in a CString variable, which I tried doing like this:
The getString function could then be called to show the selected string somewhere else in my program.
What am I not understanding?
Thanks in advance
I've tried a number of things but just can't get this to work. I have a list box containing a number of strings:
Code:
void CInstrumentDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CInstrumentDlg)
DDX_LBString(pDX, IDC_LIST_INSTRUMENT, m_CursorSel);
//}}AFX_DATA_MAP
}
BOOL CInstrumentDlg::OnInitDialog()
{
pnListBox = (CListBox*) GetDlgItem (IDC_LIST_INSTRUMENT);
pnListBox->InsertString(-1, "Drums");
pnListBox->InsertString(-1, "Electric Guitar");
pnListBox->InsertString(-1, "Acoustic Guitar");
pnListBox->InsertString(-1, "Bass");
pnListBox->InsertString(-1, "Snare");
return CDialog::OnInitDialog();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
All I want to be able to do is to store the selected string in a CString variable, which I tried doing like this:
Code:
void CInstrumentDlg::OnOK()
{
pnListBox->GetText(pnListBox->GetCurSel(), m_CursorSel);
CDialog::OnOK();
}
CString CInstrumentDlg::getString()
{
return m_CursorSel;
}
The getString function could then be called to show the selected string somewhere else in my program.
What am I not understanding?
Thanks in advance