#ifndef MYCTRL_H
#define MYCTRL_H
#include "crviewer1.h"
#import "C:\\Program Files\\Common Files\\Crystal Decisions\\2.0\\bin\\craxddrt9.dll" no_namespace
#include <qwinhost.h>
#include <QtGui>
class HostWindow : public QWinHost
{
Q_OBJECT
public:
HostWindow
(QWidget *parent
= 0, Qt
::WFlags f
= 0) : QWinHost(parent, f)
{
setFocusPolicy(Qt::StrongFocus);
}
~HostWindow()
{
if(m_pCRViewer1)
{
m_pCRViewer1->DestroyWindow();
delete m_pCRViewer1;
}
}
HWND createWindow(HWND parent, HINSTANCE instance)
{
CString nn("hello");
CWnd* cwnd=CWnd::FromHandle(parent);
CRect rect;
cwnd->GetClientRect(&rect);
DWORD nStyle=cwnd->GetStyle();
AfxEnableControlContainer();
m_pCRViewer1=new CCrviewer1();
m_pCRViewer1->Create((LPCTSTR)nn, WS_CHILD | WS_VISIBLE , rect, cwnd, 10001 );
m_Application.CreateInstance (__uuidof(Application));
//获取m_Report变量
//staff.rpt为通过向导建立的报表文件,数据库采用SQL Server 7.0
m_Report =m_Application->OpenReport ("World Sales Report.rpt");
//设置报表标题
m_Report->put_ReportTitle (_bstr_t("Title"));
m_pCRViewer1->put_ReportSource(m_Report);
m_pCRViewer1->put_DisplayToolbar (TRUE);
m_pCRViewer1->put_DisplayGroupTree (FALSE);
m_pCRViewer1->put_DisplayBorder (FALSE);
//刷新数据
m_pCRViewer1->Refresh ();
//显示报表内容
m_pCRViewer1->ViewReport();
return m_pCRViewer1->m_hWnd;
}
signals:
void message
(const QString &msg,
int timeout
);
public slots:
void returnPressed()
{
QMessageBox::information(topLevelWidget
(),
"Message from Qt",
"Return pressed in QLineEdit!");
}
public:
CCrviewer1* m_pCRViewer1;
IApplicationPtr m_Application;
IReportPtr m_Report;
protected:
/*void resizeEvent(QResizeEvent *e)
{
QWinHost::resizeEvent(e);
if (m_pCRViewer1)
m_pCRViewer1->MoveWindow(0,0,width(),height());
}*/
};
#endif
#ifndef MYCTRL_H
#define MYCTRL_H
#include "crviewer1.h"
#import "C:\\Program Files\\Common Files\\Crystal Decisions\\2.0\\bin\\craxddrt9.dll" no_namespace
#include <qwinhost.h>
#include <QtGui>
class HostWindow : public QWinHost
{
Q_OBJECT
public:
HostWindow(QWidget *parent = 0, Qt::WFlags f = 0)
: QWinHost(parent, f)
{
setFocusPolicy(Qt::StrongFocus);
}
~HostWindow()
{
if(m_pCRViewer1)
{
m_pCRViewer1->DestroyWindow();
delete m_pCRViewer1;
}
}
HWND createWindow(HWND parent, HINSTANCE instance)
{
CString nn("hello");
CWnd* cwnd=CWnd::FromHandle(parent);
CRect rect;
cwnd->GetClientRect(&rect);
DWORD nStyle=cwnd->GetStyle();
AfxEnableControlContainer();
m_pCRViewer1=new CCrviewer1();
m_pCRViewer1->Create((LPCTSTR)nn, WS_CHILD | WS_VISIBLE , rect, cwnd, 10001 );
m_Application.CreateInstance (__uuidof(Application));
//获取m_Report变量
//staff.rpt为通过向导建立的报表文件,数据库采用SQL Server 7.0
m_Report =m_Application->OpenReport ("World Sales Report.rpt");
//设置报表标题
m_Report->put_ReportTitle (_bstr_t("Title"));
m_pCRViewer1->put_ReportSource(m_Report);
m_pCRViewer1->put_DisplayToolbar (TRUE);
m_pCRViewer1->put_DisplayGroupTree (FALSE);
m_pCRViewer1->put_DisplayBorder (FALSE);
//刷新数据
m_pCRViewer1->Refresh ();
//显示报表内容
m_pCRViewer1->ViewReport();
return m_pCRViewer1->m_hWnd;
}
signals:
void message(const QString &msg, int timeout);
public slots:
void returnPressed()
{
QMessageBox::information(topLevelWidget(), "Message from Qt", "Return pressed in QLineEdit!");
}
public:
CCrviewer1* m_pCRViewer1;
IApplicationPtr m_Application;
IReportPtr m_Report;
protected:
/*void resizeEvent(QResizeEvent *e)
{
QWinHost::resizeEvent(e);
if (m_pCRViewer1)
m_pCRViewer1->MoveWindow(0,0,width(),height());
}*/
};
#endif
To copy to clipboard, switch view to plain text mode
Bookmarks