Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CListBox Problem

Status
Not open for further replies.

howardnl

Programmer
Apr 12, 2001
18
0
0
US
Hello,

I have an application that when the user presses a button a dialog box pops up. From that dialog box another button can be pushed that brings up a CFileDialog box that lets the user select multiplie files. The selected files are put into a CListBox control. That works fine.

My problem is when the user hits the ok button on the original dialog box and goes back to the main window. I try to access the listbox items, but it is always empty. If I put a button on the dialog box and access the listbox from there everything is fine. All of my other controls work fine, except for this one.

So, basically this is what I've got:

CMyDialog dialog;
CString temp;
if (dialog.DoModal() == IDCANCEL)
return;
else
{
some_function(dialog.m_editValue); // this works fine
some_function2.(dialog.m_listbox.GetCount());
// GetCount always returns 0
// even though there are items in the list
}

Does anyone have any ideas? I'm totally confused, but I'm almost certain I'm missing something simple. Thanks for any help.

Thanks,
Nick
 
You are trying to accessing a control after it
has been destroyed.(All child controls and also
the dialog infact are destroyed when the dialog
is dissmissed)

what u should be doing is use a CStringArray in the
dialog and set all the listbox's string in it
if u want to retrieve after the dialog is dissmissed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top