int CGridView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CScrollView::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
FILE *fp;
int handle;
if((handle=open("C:\\My Documents\\wgcfull.txt",O_RDONLY))==-1)
{
AfxMessageBox("文件输入错误\n");
exit(0);
}
long int length=filelength(handle);//得到文件的长度
close(handle);
float Vd1,Vg1,Fs1;
int lineno1,stationno1;
int i=0;//数组下标
length=length-237;
float dataFs[2048],dataVd[2048],dataVg[2048];
int dataNo[2048];
int number=(int)length/55;// 得到测点数
if((fp=fopen("C:\\My Documents\\wgcfull.txt","r"))==NULL)
{
AfxMessageBox("文件输入错误\n");
exit(0);
}
fseek(fp, 237L, SEEK_SET);/////字节偏移237跳过文件头
while(!feof(fp))
{
fscanf(fp," %d, %d, %f, %f, %f\n",
&lineno1,&stationno1,&Vd1,&Vg1,&Fs1);
dataFs[i]=Fs1;
dataNo[i]=i;
dataVd[i]=Vd1;
dataVg[i]=Vg1;
i++;
}
fclose(fp);
m_fgrid.Create(NULL, WS_VISIBLE, CRect(0,0,350,400), this, 0); //用this 指针作为指向父窗口的指针
m_fgrid.SetRows(number);
m_fgrid.SetRows(10);
m_fgrid.SetTextMatrix(0,0,"测线号");
m_fgrid.SetTextMatrix(0,1,"测点号");
m_fgrid.SetTextMatrix(0,2,"Vd");
m_fgrid.SetTextMatrix(0,3,"Vg");
m_fgrid.SetTextMatrix(0,4,"Fs");
CString str;
for( i=0;i<number1;i++)
{
str="测线1";
m_fgrid.SetTextMatrix(i,0,str);
str.Format("%d",dataNo[i]);
m_fgrid.SetTextMatrix(i,1,str);
str.Format("%d",dataVd[i]);
m_fgrid.SetTextMatrix(i,2,str);
str.Format("%d",dataVg[i]);
m_fgrid.SetTextMatrix(i,3,str);
str.Format("%d",dataFs[i]);
m_fgrid.SetTextMatrix(i,4,str);
}
return 0;
}
当程序执行到m_fgrid.Create(NULL, WS_VISIBLE, CRect(0,0,350,400), this, 0); //用this 指针作为指向父窗口的指针
这一句时,就建立空文档失败,怎么一回事
{
if (CScrollView::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
FILE *fp;
int handle;
if((handle=open("C:\\My Documents\\wgcfull.txt",O_RDONLY))==-1)
{
AfxMessageBox("文件输入错误\n");
exit(0);
}
long int length=filelength(handle);//得到文件的长度
close(handle);
float Vd1,Vg1,Fs1;
int lineno1,stationno1;
int i=0;//数组下标
length=length-237;
float dataFs[2048],dataVd[2048],dataVg[2048];
int dataNo[2048];
int number=(int)length/55;// 得到测点数
if((fp=fopen("C:\\My Documents\\wgcfull.txt","r"))==NULL)
{
AfxMessageBox("文件输入错误\n");
exit(0);
}
fseek(fp, 237L, SEEK_SET);/////字节偏移237跳过文件头
while(!feof(fp))
{
fscanf(fp," %d, %d, %f, %f, %f\n",
&lineno1,&stationno1,&Vd1,&Vg1,&Fs1);
dataFs[i]=Fs1;
dataNo[i]=i;
dataVd[i]=Vd1;
dataVg[i]=Vg1;
i++;
}
fclose(fp);
m_fgrid.Create(NULL, WS_VISIBLE, CRect(0,0,350,400), this, 0); //用this 指针作为指向父窗口的指针
m_fgrid.SetRows(number);
m_fgrid.SetRows(10);
m_fgrid.SetTextMatrix(0,0,"测线号");
m_fgrid.SetTextMatrix(0,1,"测点号");
m_fgrid.SetTextMatrix(0,2,"Vd");
m_fgrid.SetTextMatrix(0,3,"Vg");
m_fgrid.SetTextMatrix(0,4,"Fs");
CString str;
for( i=0;i<number1;i++)
{
str="测线1";
m_fgrid.SetTextMatrix(i,0,str);
str.Format("%d",dataNo[i]);
m_fgrid.SetTextMatrix(i,1,str);
str.Format("%d",dataVd[i]);
m_fgrid.SetTextMatrix(i,2,str);
str.Format("%d",dataVg[i]);
m_fgrid.SetTextMatrix(i,3,str);
str.Format("%d",dataFs[i]);
m_fgrid.SetTextMatrix(i,4,str);
}
return 0;
}
当程序执行到m_fgrid.Create(NULL, WS_VISIBLE, CRect(0,0,350,400), this, 0); //用this 指针作为指向父窗口的指针
这一句时,就建立空文档失败,怎么一回事
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货