我怀疑是我定时器的原因,我设置的大约100ms闪一次,我的代码如下,但是确找不到具体哪不对,谢谢回答void CViewPropertySheet::OnTimer(UINT nIDEvent)
{
CPropPage4* cp4;
CString weijie;
CString a;
CString time;
CTime datime(2009,2,3);
strTimeStart2=datime;
CString str;
long lEventType,lResult;
#define iDataBufLen (MaxDataLen+1) //一共分配47个字节
char chDataBuf[iDataBufLen];
if(nIDEvent==1){
//if(m_bInit)//如果已经初始化成功就返回// return;
if(TV_Initialize())
{
TV_RegMsgWnd(GetSafeHwnd(),FALSE);//注册接受消息的窗口,和定时读取只需要同时使用一个
//初始化字符语音列表
TV_InitPlayStringList((LPTSTR)(LPCTSTR)(GetModulePath1()+"FileList.txt"));
m_bInit = TRUE;
CString str;
str.Format("初始化成功 序列号=%d 密码=%u",TV_GetSerial2(),TV_GetDevicePwd());
}
else
AddStatus("初始化失败");
bool init= false;
bool outit= false;
if(TV_RingDetect()!=0 && !init)
{
init=true;
SetActivePage(2);
AdjustPages();
char Num[20];
TV_ReceiveCallingID(Num,20);
a.Format("%s ", Num);
if(a.GetLength()!=0){
cp4 = (CPropPage4 *)GetActivePage();
cp4->ReCall(a);
time = CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S");
if(TV_GetTelState()==true)
{
outit = FALSE;
strTimeStart2=CTime::GetCurrentTime();
}
if( TV_GetTelState()==false)
{
init=FALSE;
outit=false;
strTimeEnd2=CTime::GetCurrentTime();
if(strTimeStart2==datime){
weijie="未接";
CString timelen="0";
cp4->TelHistory0(time,timelen,a,weijie);
}else{
CTimeSpan cts=strTimeEnd2-strTimeStart2;
CString timelen=cts.Format("%H:%M:%S");
weijie="来电";
cp4->TelHistory0(time,timelen,a,weijie);
}
}
}
}
}
if(nIDEvent==2)
{
if(TV_Initialize())
{
TV_RegMsgWnd(GetSafeHwnd(),FALSE);//注册接受消息的窗口,和定时读取只需要同时使用一个
//初始化字符语音列表
TV_InitPlayStringList((LPTSTR)(LPCTSTR)(GetModulePath1()+"FileList.txt"));
m_bInit = TRUE;
CString str;
str.Format("初始化成功 序列号=%d 密码=%u",TV_GetSerial2(),TV_GetDevicePwd());
}
else
AddStatus("初始化失败");
bool =false;
bool 1=false;
cp4 = (CPropPage4 *)GetActivePage();
if(cp4->sign==true)
{
if (TV_IsTalkState()==true)
{
=true;
}
if (==true && TV_GetTelState()==false)
{
cp4->strTimeEnd4=CTime::GetCurrentTime();
CTimeSpan cts=cp4->strTimeEnd4-cp4->strTimeStart4;
CString timelen=cts.Format("%H:%M:%S");
weijie="去电";
cp4->TelHistory0(time,timelen,a,weijie);
}
}
}
if(nIDEvent==4){ cp4 = (CPropPage4 *)GetActivePage(); if (TV_GetTelState()==true)
{
if (!m_bool)
{
m_bool = true;
m_time1 = CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S");
}
if (GetActiveIndex() != 2)
{
SetActivePage(2);
AdjustPages();
}
long lRet=TV_GetEventEx(&lEventType,&lResult,chDataBuf,iDataBufLen);
cp4 = (CPropPage4 *)GetActivePage();
if(lRet < 0) MessageBox("chDataBuf的内存长度分配不够");
else if(lRet > 0)
{
if (lEventType==TEvent_TelDial)
{
str.Format("%s",chDataBuf);
//MessageBox(str);
cp4->m_calling=str;
cp4->UpdateData(false);
// time = CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S");
}
}
// AfxMessageBox("TV_GetTelState==true");
}
if (TV_GetTelState()==false && TV_GetPcState()==false && m_bool==true )
{
m_bool=false;
CTimeSpan cts=strTimeEnd2-strTimeStart2;
CString timelen=cts.Format("%H:%M:%S");
CString str2;
str2=cp4->m_calling;
weijie="去电";
if(timelen.Find("-")==0){
timelen="00:00:00";
}
cp4->TelHistory0(m_time1,timelen,str2,weijie);
}
}
}
{
CPropPage4* cp4;
CString weijie;
CString a;
CString time;
CTime datime(2009,2,3);
strTimeStart2=datime;
CString str;
long lEventType,lResult;
#define iDataBufLen (MaxDataLen+1) //一共分配47个字节
char chDataBuf[iDataBufLen];
if(nIDEvent==1){
//if(m_bInit)//如果已经初始化成功就返回// return;
if(TV_Initialize())
{
TV_RegMsgWnd(GetSafeHwnd(),FALSE);//注册接受消息的窗口,和定时读取只需要同时使用一个
//初始化字符语音列表
TV_InitPlayStringList((LPTSTR)(LPCTSTR)(GetModulePath1()+"FileList.txt"));
m_bInit = TRUE;
CString str;
str.Format("初始化成功 序列号=%d 密码=%u",TV_GetSerial2(),TV_GetDevicePwd());
}
else
AddStatus("初始化失败");
bool init= false;
bool outit= false;
if(TV_RingDetect()!=0 && !init)
{
init=true;
SetActivePage(2);
AdjustPages();
char Num[20];
TV_ReceiveCallingID(Num,20);
a.Format("%s ", Num);
if(a.GetLength()!=0){
cp4 = (CPropPage4 *)GetActivePage();
cp4->ReCall(a);
time = CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S");
if(TV_GetTelState()==true)
{
outit = FALSE;
strTimeStart2=CTime::GetCurrentTime();
}
if( TV_GetTelState()==false)
{
init=FALSE;
outit=false;
strTimeEnd2=CTime::GetCurrentTime();
if(strTimeStart2==datime){
weijie="未接";
CString timelen="0";
cp4->TelHistory0(time,timelen,a,weijie);
}else{
CTimeSpan cts=strTimeEnd2-strTimeStart2;
CString timelen=cts.Format("%H:%M:%S");
weijie="来电";
cp4->TelHistory0(time,timelen,a,weijie);
}
}
}
}
}
if(nIDEvent==2)
{
if(TV_Initialize())
{
TV_RegMsgWnd(GetSafeHwnd(),FALSE);//注册接受消息的窗口,和定时读取只需要同时使用一个
//初始化字符语音列表
TV_InitPlayStringList((LPTSTR)(LPCTSTR)(GetModulePath1()+"FileList.txt"));
m_bInit = TRUE;
CString str;
str.Format("初始化成功 序列号=%d 密码=%u",TV_GetSerial2(),TV_GetDevicePwd());
}
else
AddStatus("初始化失败");
bool =false;
bool 1=false;
cp4 = (CPropPage4 *)GetActivePage();
if(cp4->sign==true)
{
if (TV_IsTalkState()==true)
{
=true;
}
if (==true && TV_GetTelState()==false)
{
cp4->strTimeEnd4=CTime::GetCurrentTime();
CTimeSpan cts=cp4->strTimeEnd4-cp4->strTimeStart4;
CString timelen=cts.Format("%H:%M:%S");
weijie="去电";
cp4->TelHistory0(time,timelen,a,weijie);
}
}
}
if(nIDEvent==4){ cp4 = (CPropPage4 *)GetActivePage(); if (TV_GetTelState()==true)
{
if (!m_bool)
{
m_bool = true;
m_time1 = CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S");
}
if (GetActiveIndex() != 2)
{
SetActivePage(2);
AdjustPages();
}
long lRet=TV_GetEventEx(&lEventType,&lResult,chDataBuf,iDataBufLen);
cp4 = (CPropPage4 *)GetActivePage();
if(lRet < 0) MessageBox("chDataBuf的内存长度分配不够");
else if(lRet > 0)
{
if (lEventType==TEvent_TelDial)
{
str.Format("%s",chDataBuf);
//MessageBox(str);
cp4->m_calling=str;
cp4->UpdateData(false);
// time = CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S");
}
}
// AfxMessageBox("TV_GetTelState==true");
}
if (TV_GetTelState()==false && TV_GetPcState()==false && m_bool==true )
{
m_bool=false;
CTimeSpan cts=strTimeEnd2-strTimeStart2;
CString timelen=cts.Format("%H:%M:%S");
CString str2;
str2=cp4->m_calling;
weijie="去电";
if(timelen.Find("-")==0){
timelen="00:00:00";
}
cp4->TelHistory0(m_time1,timelen,str2,weijie);
}
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货