Code:
// Search.cpp
void ASearch::OnBnClickedButton1() //ok button to search
{
searchNumber();
if (resultCount > 0)
{
Search_result result; // YOU ARE CREATING A NEW OBJECT
result.DoModal();
}
else if (resultCount==0)
{
edittxt.SetWindowText(L"un ok");
}
UpdateData(TRUE);
// TODO: Add your control notification handler code here
}
void Search::searchNumber()
{
busDB bus_db;
resultCount = 0;
int dbsize = bus_db.getDbSize();
CString editbxNo;
edittxt.GetWindowText(editbxNo);
Bus AS_resultdb[817];
Search_result as_result; // AGAIN, YOU ARE CREATING A NEW, LOCAL OBJECT.
for (int i = 1; i <= 100; i++)
{
if (bus_db.getNumber(i).Find(editbxNo) >= 0)
{
details = bus_db.getRemark(i) + bus_db.getNumber(i) + bus_db.getTitle(i);
as_result.details = details;
UpdateData(TRUE);
++resultCount;
}
}
}
//Search_result.cpp:
void ASearch_result::OnLbnSetfocusList5() //listbox to start listing details
{
// TODO: Add your control notification handler code here
this->AS_result_list.AddString(details);
}
Your indentation is so horrible, I had to fix it for you.
Look where it's red - see? You're creating local objects! MFC works on the principle that all dialogs are objects - when they go our of scope, your dialog is destroyed.
So what are you doing wrong? You're creating a dialog class, assigning data to it, it then gets destroyed, along with all its data. Then you're creating a NEW dialog class and expect the data to still be there.
I suggest you read about classes, objects, references and pointers.
http://www.cprogramming.com/tutorial/