|
急切求助!为什么我定义了m_osWrite还报错undeclared identifier?
[复制链接]
我是在EVC中写的MFC程序,已经定义了m_osWrite,但还是报错,不知为什么,如下:
OVERLAPPED m_osWrite;
memset(&m_osWrite,0,sizeof(OVERLAPPED));//这一行报错:error C2065: 'm_osWrite' : undeclared identifier
m_osWrite.hEvent=CreateEvent(NULL,TRUE,FALSE,NULL);//error C2228: left of '.hEvent' must have class/struct/union type
所有代码如下:
void CLq28Dlg::OnSend()
{
// TODO: Add your control notification handler code here
/*
if( !m_comm.GetPortOpen() )
m_comm.SetPortOpen(TRUE);//打开串口
UpdateData(TRUE);
*/
FILE *fp1 ;
if((fp1 = fopen("\\sdmmc\\a.txt","rt"))==NULL)
{
printf("ERROR on open a.txt!\n");
exit(1);
}
char ch='m';
while(ch!=EOF) {
CLq28Dlg dlg;
if(dlg.DoModal()==IDC_SLEEP||dlg.DoModal()==IDC_STOP) break;
if(dlg.DoModal()==IDC_STOP && dlg.DoModal()!=IDC_CONPLAY)
OVERLAPPED m_osWrite;
memset(&m_osWrite,0,sizeof(OVERLAPPED));
m_osWrite.hEvent=CreateEvent(NULL,TRUE,FALSE,NULL);
CString s;
while(ch!=','&&ch!='!'&&ch!='。'&&ch!='!')
{
s+=ch;
ch=fgetc(fp1);
}
int i,j,Count;
CString m_Data;
CString recive;
m_Data=s;
Count=m_Data.GetLength();
CByteArray m_Array;
j=(Count >> 8)&&0xFF;
m_Array.RemoveAll();
m_Array.SetSize(Count);
m_Array.Add(0xFE);
m_Array.Add(0x01);
m_Array.Add(j);
m_Array.Add(Count-j);
char lqq[100];
for(i=0;i
lqq=m_Data;
m_Array.Add(m_Data);
recive+=m_Data;
}
//m_comm.SetOutput(COleVariant(m_Array));
DWORD dwBytesWrite= Count;
COMSTAT ComStat;
DWORD dwErrorFlags;
BOOL bWriteStat;
ClearCommError(hCom,&dwErrorFlags,&ComStat);
bWriteStat=WriteFile(hCom,lqq,
dwBytesWrite,& dwBytesWrite,&m_osWrite);
if(!bWriteStat)
{
if(GetLastError()==ERROR_IO_PENDING)
{
WaitForSingleObject(m_osWrite.hEvent,1000);
}
}//if(!bWriteStat)
CString stem1="";
SetDlgItemText(IDC_EDIT1,stem1);
CString stem2=recive;
SetDlgItemText(IDC_EDIT1,stem2);
for(i=0;i
lqq=0;
}
}//while(ch!=EOF)
}
|
|