Click to See Complete Forum and Search --> : Errors with open a file.


hobbits
August 3rd, 2004, 06:37 AM
Hello, people. I have the following problem.

It is an MDI application with integrated dialogue form. Task - over
picture curve draw.

In dialogue form all computations for curve are accomplished. In
Pronzip everything functions, but I discovered errors.

In dialogue form in ComboBox an entry select and into CListBox a
list one loads accordingly.

If with the program start will first a document is opened and
afterwards dialogue form does not know, then in this dialogue form a
list is loaded (appropriate error message, the file comes can does
not open to become). But if opened with the program start first
dialogue form, then no Problemm, everything functioned
one-way-free. Thus, it pasiert always after that
document opens a Document(not again, but document open...).
Program is not broken off, only list in CListBox is not loaded.

With it you get better overview, I show here few fragments
from source code.

OnOpenDocument:

BOOL CKurierDoc::OnOpenDocument(LPCTSTR lpszPathName)
{
CString text;
CStdioFile file;
int nCou;
try
{

CFileDialog m_dlgOpen(TRUE);
file.Open(lpszPathName, CFile::typeText);

//It is first line read and according to a picture loaded

if(file.ReadString(text))
nCou = atoi(text);

CString sFileBild[125] = {"C:\\kur\\Kl_1.jpg","C:\\kur\\danes.jpg",
"C:\\kur\\eis.jpg","C:\\kur\\erfen.jpg","C:\\k .....};

for(int iFind = 0; iFind < 125; iFind++)
{
if(nCou == iFind)
filename = sFileBild[iFind];
}

//I use CImage, around JPG's load

int type = CIMAGE_FORMAT_JPEG;
image = new CImage(filename, type);
if (image->GetWidth() <= 0 || image->GetHeight() <= 0)
{
delete image;
image = NULL;
return FALSE;
}
int value;
DeleteContents(); //Old list (CList) delete.

while(file.ReadString(text))
{
value = atoi(text);
if(value < 0)
MessageBox(NULL,"Falsche Werte", "", MB_OK);
else
m_lkur.theData.AddTail(value);//Values from file in CList store.
}
UpdateAllViews(NULL);
SetModifiedFlag();

SetTitle(lpszPathName);
}
catch(CFileException *e)
{
e->ReportError();
e->Delete();
//return;
}
file.Close();
return TRUE;
}


and now from Dialog-Form



void CEingabe::OnCbnSelchangeCombo1()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
CStdioFile file;
CString text;

int iStadt = m_ctlStadt.GetCurSel();
switch(iStadt)
{
case 0:
m_ctlList.ResetContent();
m_ctlStreet.ResetContent();
if (file.Open("Land.txt", CFile::modeRead))
{
while (file.ReadString(text))
m_ctlStreet.InsertString(-1, text);
}
else
{
MessageBox ("Error", " ");
}
break;
case 1:
m_ctlList.ResetContent();
m_ctlStreet.ResetConten();
...
file.Close();
}

I see here no reason, why so which take place.
Can someone help me? I thank ahead.