Hi, people!
I have some problems with reflection a text on CStatic. I read the first line of a text file with this function:
It runs in this way:
When program is running it sometimes works wrong. Why?
I have some problems with reflection a text on CStatic. I read the first line of a text file with this function:
Code:
char * o_file(const char *filename)
{
FILE *f=fopen(filename, "r");
if (f!=0)
{
char ch;
char *result=new char[];
int i=0;
fseek(f, 0, SEEK_SET);
while (!feof(f) && ch != '\n' && ch != \r')
{
ch = fgetc(f);
if ( ch != '\n' && ch != '\r' && !feof(f)) result[i]=ch;
CSize sz = dc.GetTextExtent(result,strlen(result));
i++;
while (sz.cx>=rcstat.right-rcstat.left)
{
rcstat.right++;
};
fclose(f);
return(result);
}
else
{
fclose(f);
AfxMessageBox("Error: File not found",MB_OK | MB_ICONSTOP,0);
return NULL;
};
};
Code:
if (MyStatic!=NULL) MyStatic->Create(o_file(filename),WS_CHILD|WS_VISIBLE|SS_CENTER|SS_CENTERIMAGE,
rcstat,this);