Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. 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
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 2.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lygstate
    wrote on last edited by
    #1

    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"

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved