www.mxdraw.com
内容索引主面
前一个向上下一个
McDbDatabaseReactor 类

数据库反应器类型

C++
class McDbDatabaseReactor : public McRxObject;

McDbDatabaseReactor.h

例如:监视数据库的WordDrawBackGround事件,用户自定义控件显示背景

    class CCustomDrawGround : public McDbDatabaseReactor
    {
    public:
        CCustomDrawGround();
        virtual ~CCustomDrawGround();

        virtual void WordDrawBackGround(const McDbDatabase* pDatabase,McGiWorldDraw* wd,McDbObjectId layoutId);
    };

    void CCustomDrawGround::WordDrawBackGround(const McDbDatabase* pDatabase,
        McGiWorldDraw* wd,
        McDbObjectId layoutId)
    {
        McDbObjectPointer<McDbLayout> spLayout(layoutId,McDb::kForRead);
        if(spLayout.openStatus() != Mcad::eOk)
            return;

        if(!spLayout->IsModelSpace() )
        {
            return ;
        }

        wd->subEntityTraits().setColor(9);

        // 写一个背景文字

        McDbText text;
        text.setHeight(20);
        text.setTextString(_T("梦想绘图控件,背景文字测试"));
        text.setPosition(McGePoint3d(0,0,0));
        text.setAlignmentPoint(McGePoint3d(0,0,0));
        text.worldDraw(wd);
        return;
    }

    
    CCustomDrawGround* m_pCustomDrawGround;

    // 创建一个反应器
    m_pCustomDrawGround = new CCustomDrawGround;

    // 注册反应器
    MxDraw::GetDatabase(m_hDrawOcx)->addReactor(m_pCustomDrawGround);

    void CTestDlg::OnDestroy()
    {
        // 在退出时,注销反应器
        MxDraw::GetDatabase(m_hDrawOcx)->removeReactor(m_pCustomDrawGround);

        CResizingDialog::OnDestroy();

    }
Copyright (c) 2010. All rights reserved.
你认为该帮助怎么样? 发送反馈信息!