How create CWnd and use it in Qt as a Widget. along with how to setting the entrypoint as 'main' when using MFC as a dll
-
from "The original post":http://www.qtcentre.org/threads/24035-how-create-CWnd-and-use-it-in-Qt
This is the code to using the CWnd as a widget.
@#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));
//get m_Report
//
m_Report =m_Application->OpenReport ("World Sales Report.rpt");
//set report title
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
@But I've got a problem when using of that,
when I building it with MFC, the entrypoint always start in MFC dll.
From that post, the user ignore the default library: "mfc90d.lib;mfcs90d.lib", and when he
build and run, it's works. And the entrypoint is setting to 'main',The question is, how to ignore the default libary:"mfc90d.lib;mfcs90d.lib"