ok, If I change the message to ON_LBN_SELCHANGE(IDLB_MAINDIR, OnSelchangeMainDir) it compiles without errors, This message is used for another listbox clicking function. The problem now is a "Memory could not be read" at run-time when I click on an item in the listbox. I guess it's the function, here it is:
Code:
afx_msg void CTestDialog::OnSelchangeMainDir()
{
CFtpFileFind finder(gpConnect);
CString fname;
CListBox* pListMain = (CListBox*)GetDlgItem(IDLB_MAINDIR);
CListBox* pListSub = (CListBox*)GetDlgItem(IDLB_SUBDIR);
BOOL bWorking = finder.FindFile(_T("*"));
pListMain->GetText(pListMain->GetCurSel(), fname);
gpConnect->SetCurrentDirectory(fname);
bWorking = finder.FindFile(_T("*"));
pListMain->ResetContent( );
pListSub->ResetContent( );
while (bWorking)
{
bWorking = finder.FindNextFile();
fname = finder.GetFileName();
//fprintf(out,"%s\n", fname );
if( strchr(fname,'.') ) //strstr(fname,".txt") ||
pListSub->AddString(fname);
else
pListMain->AddString(fname);
}
}
and gpConnect is a gloal variable CFtpConnection* gpConnect; I establish a connection by a different function and make that connection pointer equal to the global one.