This is like the last one but now I am just working one function at a time.
So this function is for saving the configuration which I want to be a text file that contains the filenames of the WAVs in the list control. So to outline here is what I have done
1. Open the filedialog to allow the name to be set
2. Create a CStringArray to hold the names in the ListControl and loop
3. Create a CFile and loop as I write out each name
I know I could skip a step but I figure if I put everything in a array I can modify the function more later if I have the need...
comments please?
So this function is for saving the configuration which I want to be a text file that contains the filenames of the WAVs in the list control. So to outline here is what I have done
1. Open the filedialog to allow the name to be set
2. Create a CStringArray to hold the names in the ListControl and loop
3. Create a CFile and loop as I write out each name
I know I could skip a step but I figure if I put everything in a array I can modify the function more later if I have the need...
comments please?
- Code:
void CHartmanDlg::OnSavecfg()
{
CFile savefile;
CString fname = "theconfig";
CFileDialog fileDialog(FALSE, NULL, fname, NULL, (_T("All Files (*.*)|*.*|")), NULL);
if (fileDialog.DoModal() == IDOK){}
CStringArray thelist;
int nCount = m_lcsounds.GetItemCount();
for (int i = 0;i < nCount;i++)
{
CString xxx = m_lcsounds.GetItemText(i, 0);
thelist.Add(xxx);
}
savefile.Open(fileDialog.m_ofn.lpstrFile,CFile::modeCreate | CFile::modeNoTruncate);
for (int j = 0; i < thelist.GetSize(); i++)
{
CString str = thelist.GetAt(0);
savefile.Write (str, str.GetLength());
savefile.Write ("\n", 1);
}
savefile.Close();
}