3,245
社区成员
发帖
与我相关
我的任务
分享
vc代码
void CSvDlgPrintReport::OnDblclkListTemplates(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
if (m_ctrCRViewer.GetIsBusy())//非常重要,防止切换过快导致加载失败报错
{
return;
}
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
int nIndex = pNMListView->iItem;
if (nIndex == -1)//选中某icon
{
return;
}
CString strProfile = CSvToolkit::GetAppDir() + "\\Paras\\Templates\\" + m_arrstrTempName[nIndex];
//获取m_Report变量
VARIANT dummy;
VariantInit(&dummy);
dummy.vt = VT_EMPTY;
m_Report->Release();
m_Report = m_Application->OpenReport(_bstr_t(strProfile),dummy);
//设置报表作者
m_Report->PutReportAuthor ("andrew");
//将m_Report与报表控件连接
m_ctrCRViewer.SetReportSource(m_Report);
//显示报表工具条
m_ctrCRViewer.SetDisplayToolbar (TRUE);
//不显示报表左边的分组树
m_ctrCRViewer.SetDisplayGroupTree (FALSE);
//不显示控件边框
m_ctrCRViewer.SetDisplayBorder (FALSE);
//显示报表内容
m_ctrCRViewer.ViewReport();
//刷新数据
m_ctrCRViewer.Refresh();
*pResult = 0;
}