Optimization of code
Is it possible to have the "void CMyAppDlg::OnSelchangeFilelist() " run in a
separate cpp file?
I mean, instead of adding more and more large functions within the main Dlg?
I have seen some apps where the main Dlg file is quite long over 5000lines.
Wouldnt it be better to break the functions into separate files then?
Also, in the code below, what is the best way to search for a text string
which is placed within this file which has many 0x00(null) within?
I am using VC6 so CStringA doesnt work as it has been suggested.
Should I just read byte by byte till I find the first char then the next
char till I find the string?
void CMyAppDlg::OnSelchangeFilelist()
{
CString selected;
TCHAR Select[500];
int nSelect;
nSelect = c_List.GetCurSel();
DlgDirSelect(Select, IDC_FILELIST);
c_List.GetText(nSelect, Select);
c_FileSelected.SetWindowText(Select);
selected = Select;
Fname = DEFAULT_PATH + selected;
CFile f;
if(!f.Open(Fname, CFile::modeRead)){
AfxMessageBox("Open failed");
return;
}
ULONGLONG len = f.GetLength();
CByteArray buffer;
buffer.SetSize(int(len) + sizeof(TCHAR));
if(!f.Read(buffer.GetData(), (UINT)len))
{
f.Close();
AfxMessageBox("Read failed");
return;
}
buffer[int(len)] = 0;
if(sizeof(TCHAR) > 1)
buffer[int(len) + 1] = 0;
f.Close();
// additional decode of file here
}