Ok,
I solved it. No compiler errors anymore however, if I load a file my program crasshes. Before I moved the code to a seperate unit it didn't crash.
The following message is displayed:
---------------------------
Debugger Exception Notification
---------------------------
Project NemaReview.exe raised exception class EAccessViolation with message 'Access violation
at address 0040B76A in module 'NemaReview.exe'. Read of address 000002F0'. Process stopped.
Use Step or Run to continue.
---------------------------
OK Help
---------------------------
---------------------------
NEMA Review
---------------------------
Access violation at address 0040B76A in module 'NemaReview.exe'. Read of address 000002F0.
---------------------------
OK
---------------------------
The program stops at:
OpenDialog->Filter = "Uniformity|*.ima"; see colored text
Code:
bool TUniformity::LeesUniformityMap()
{
int FileSize;
long *buffer;
int length,a;
char aFileName[20];
int ImageSize,ImagePosition,nImages = 1;
double filesize;
long tagsize;
ACR_TAG acrtag, *tag = NULL;
FILE *fp;
[COLOR=red]OpenDialog->Filter = "Uniformity|*.ima";[/color]
if (OpenDialog->Execute())
{
FileName = ExtractFileName(OpenDialog->FileName); // FileName = 5FOV.IMA
FileDir = ExtractFileDir(OpenDialog->FileName);
strcpy(aFileName,FileName.c_str()); // Converteer AnsiString naar chars
}
// Open the file:
if ((fp = fopen(aFileName, "r")) == NULL)
{
MessageBox(NULL,"Er is geen file geselecteerd. Er is geannuleerd.",NULL,0);
return 0;
}
//if (fp==NULL) exit (1);
a = IsDitEenDicomFile(fp);
if ( a == FRMT_DICM)
{
ShowMessage("Dit is een Dicom file");
}
else ShowMessage("Dit is geen Dicom file");
// get length of file:
FileSize = GetMyFileSize(fp);
// allocate memory:
buffer = (long*) malloc (FileSize);
//if (buffer == NULL) exit (2);
// read data as a block:
fread (buffer,1,FileSize,fp);
fclose(fp);
free (buffer);
//UpDateStatusLine(StatusLineRight,FileName + " file geladen !!!");
bDicomTags->Enabled = TRUE;
return 0;
}
If have no idea how to debug these type of problems.
Suggestions are very welcome!
Thanks in advance.
Johan