在线等,很急!!!【MFC中,局部函数如何修改控件变量?】 10
int32CVICALLBACKEveryNCallback(TaskHandletaskHandle,int32everyNsamplesEventType,uInt3...
int32 CVICALLBACK EveryNCallback(TaskHandle taskHandle, int32 everyNsamplesEventType, uInt32 nSamples, void *callbackData)
{
CNIREADPCIDlg dlg;
int32 error = 0;
char errBuff[2048] = { '\0' };
static int totalRead = 0;
int32 read = 0;
float64 data[500] = { 0 };
CString cstrTipMessage;
/*********************************************/
// DAQmx Read Code
/*********************************************/
DAQmxErrChk(DAQmxReadAnalogF64(taskHandle, numSampsPerChan, 10.0, DAQmx_Val_GroupByScanNumber, data, sampsPerChanRead, &read, NULL)); //DAQmx_Val_GroupByChannel
if (read>0) {
cstrTipMessage.Format(_T("Acquired %d samples. Total %d\r"), (int)read, (int)(totalRead += read));
dlg.GetDlgItem(IDC_STATIC_READCOUNTER)->SetWindowTextW(_T("HHH"));
//SetDlgItemTextW(IDC_STATIC_READCOUNTER, cstrTipMessage);?????????
//AfxMessageBox(cstrTipMessage);
if (totalRead>100000&>askHandle != 0)
{
totalRead = 0;
/*********************************************/
// DAQmx Stop Code
/*********************************************/
DAQmxStopTask(gtaskHandle);
DAQmxClearTask(gtaskHandle);
}
fflush(stdout);
}
return 0;
}
上面为MFC的回调函数,进行数据采集,怎么将 SetDlgItemTextW(..., cstrTipMessage);在这个全局函数中使用???
很急,请大神赐教! 展开
{
CNIREADPCIDlg dlg;
int32 error = 0;
char errBuff[2048] = { '\0' };
static int totalRead = 0;
int32 read = 0;
float64 data[500] = { 0 };
CString cstrTipMessage;
/*********************************************/
// DAQmx Read Code
/*********************************************/
DAQmxErrChk(DAQmxReadAnalogF64(taskHandle, numSampsPerChan, 10.0, DAQmx_Val_GroupByScanNumber, data, sampsPerChanRead, &read, NULL)); //DAQmx_Val_GroupByChannel
if (read>0) {
cstrTipMessage.Format(_T("Acquired %d samples. Total %d\r"), (int)read, (int)(totalRead += read));
dlg.GetDlgItem(IDC_STATIC_READCOUNTER)->SetWindowTextW(_T("HHH"));
//SetDlgItemTextW(IDC_STATIC_READCOUNTER, cstrTipMessage);?????????
//AfxMessageBox(cstrTipMessage);
if (totalRead>100000&>askHandle != 0)
{
totalRead = 0;
/*********************************************/
// DAQmx Stop Code
/*********************************************/
DAQmxStopTask(gtaskHandle);
DAQmxClearTask(gtaskHandle);
}
fflush(stdout);
}
return 0;
}
上面为MFC的回调函数,进行数据采集,怎么将 SetDlgItemTextW(..., cstrTipMessage);在这个全局函数中使用???
很急,请大神赐教! 展开
1个回答
2015-08-18
展开全部
你这里有个dlg,如果这行正确的话,那下面加上也应该可以
dlg.GetDlgItem(IDC_STATIC_READCOUNTER)->SetWindowTextW(_T("HHH"));
// dlg..
dlg.SetDlgItemTextW(IDC_STATIC_READCOUNTER, cstrTipMessage);
追问
关键这一行也不正确!不过已经找到方法了
CNIREADPCIDlg* pdlg = (CNIREADPCIDlg*)(AfxGetApp()->m_pMainWnd);
按这种写法来做,就能够访问到控件了。
追答
嗯,赞!
网易云信
2023-12-06 广告
2023-12-06 广告
UIkit是一套轻量级、模块化且易于使用的开源UI组件库,由YOOtheme团队开发。它提供了丰富的界面元素,包括按钮、表单、表格、对话框、滑块、下拉菜单、选项卡等等,适用于各种类型的网站和应用程序。UIkit还支持响应式设计,可以根据不同...
点击进入详情页
本回答由网易云信提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询