找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 1126|回复: 0

[ARX程序]:请看看我的代码!!

[复制链接]
发表于 2002-4-27 11:38:46 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
我想把AUTOCAD做成类VC窗口的窗口,但加载CAD退出!!请帮忙!看看我的代码!!


// 材料成型CAD项目管理.cpp : Initialization functions
#include "StdAfx.h"
#include "StdArx.h"
#include "resource.h"
#include <afxdllx.h>
#include "DockBar.h"
#include <migrtion.h>
#include <dbapserv.h>
#include <Afxext.h>
#include "ManProjectVw1.h"
#include "ManProjectVw2.h"
#include "ManProjectVw3.h"
#include "CJTabCtrlBar.h"

void CreateSampToolBar();
void DeleteSampToolBar();
void CreateLeftView();
//SampToolWnd*    gpWnd = NULL;
CDockViewBar*   gpBar;
CCJTabCtrlBar* m_wndWorkspace;
CImageList        m_ImageList;
CImageList  m_TabImages;
HINSTANCE _hdllInstance =NULL ;

// This command registers an ARX command.
void AddCommand(const char* cmdGroup, const char* cmdInt, const char* cmdLoc,
                                const int cmdFlags, const AcRxFunctionPtr cmdProc, const int idLocal = -1);


// NOTE: DO NOT edit the following lines.
//{{AFX_ARX_MSG
void InitApplication();
void UnloadApplication();
//}}AFX_ARX_MSG

// NOTE: DO NOT edit the following lines.
//{{AFX_ARX_ADDIN_FUNCS
//}}AFX_ARX_ADDIN_FUNCS


////////////////////////////////////////////////////////////////////////////
//
// Define the sole extension module object.
AC_IMPLEMENT_EXTENSION_MODULE(CADDLL);

// Now you can use the CAcModuleRecourceOverride class in
// your application to switch to the correct resource instance.
// Please see the ObjectARX Documentation for more details

/////////////////////////////////////////////////////////////////////////////
// DLL Entry Point
extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
{
        if (dwReason == DLL_PROCESS_ATTACH)
        {
        _hdllInstance = hInstance;
                // Extension DLL one time initialization
                CADDLL.AttachInstance(hInstance);
                InitAcUiDLL();
                CreateLeftView();
        CreateSampToolBar();
        } else if (dwReason == DLL_PROCESS_DETACH) {
                // Terminate the library before destructors are called
                CADDLL.DetachInstance();
        DeleteSampToolBar();
        }
        return TRUE;    // ok
}



/////////////////////////////////////////////////////////////////////////////
// ObjectARX EntryPoint
extern "C" AcRx::AppRetCode
acrxEntryPoint(AcRx::AppMsgCode msg, void* pkt)
{
        switch (msg) {
        case AcRx::kInitAppMsg:
                // Comment out the following line if your
                // application should be locked into memory
                acrxDynamicLinker->unlockApplication(pkt);
                acrxDynamicLinker->registerAppMDIAware(pkt);
                InitApplication();
                break;
        case AcRx::kUnloadAppMsg:
                UnloadApplication();
                break;
        }
        return AcRx::kRetOK;
}

// Init this application. Register your
// commands, reactors...
void InitApplication()
{
        // NOTE: DO NOT edit the following lines.
        //{{AFX_ARX_INIT

        AddCommand("CADMFCTEST", "MANPROJECT", "MANPROJECT", ACRX_CMD_TRANSPARENT | ACRX_CMD_USEPICKSET, cadMfcTestManProject);
        //}}AFX_ARX_INIT

        // TODO: add your initialization functions

}

// Unload this application. Unregister all objects
// registered in InitApplication.
void UnloadApplication()
{
        // NOTE: DO NOT edit the following lines.
        //{{AFX_ARX_EXIT
        acedRegCmds->removeGroup("CADMFCTEST");
        //}}AFX_ARX_EXIT

        // TODO: clean up your application
}

// This functions registers an ARX command.
// It can be used to read the localized command name
// from a string table stored in the resources.
void AddCommand(const char* cmdGroup, const char* cmdInt, const char* cmdLoc,
                                const int cmdFlags, const AcRxFunctionPtr cmdProc, const int idLocal)
{
        char cmdLocRes[65];

        // If idLocal is not -1, it's treated as an ID for
        // a string stored in the resources.
        if (idLocal != -1) {

                // Load strings from the string table and register the command.
                ::LoadString(_hdllInstance, idLocal, cmdLocRes, 64);
                acedRegCmds->addCommand(cmdGroup, cmdInt, cmdLocRes, cmdFlags, cmdProc);

        } else
                // idLocal is -1, so the 'hard coded'
                // localized function name is used.
                acedRegCmds->addCommand(cmdGroup, cmdInt, cmdLoc, cmdFlags, cmdProc);
}

void  CreateLeftView()
{   
       
        InitCommonControls();
        CMDIFrameWnd* pFrame=acedGetAcadFrame();
    AfxSetResourceHandle(_hdllInstance);

   // Create the image list to be used with the control bars.
        m_ImageList.Create(IDB_BITMAP2, 13, 1, RGB(0,255,0));
        // CG: The following block was inserted by the 'Dialog Bar' component
       
        m_wndWorkspace->SetBtnImageList (&m_ImageList);
        m_wndWorkspace->SetMenuID(IDR_POPUP);
        // Initialize dialog bar m_wndWorkspace
        if (!m_wndWorkspace->Create(pFrame, ID_LEFTVIEW,
        _T("Workspace"), CSize(220,200)))
                {
                        TRACE0("Failed to create dialog bar m_wndWorkspace\n");
                                }

                // Add the views to the tab control.
                m_wndWorkspace->AddView(_T("Class"), RUNTIME_CLASS(CManProjectVw1));
                m_wndWorkspace->AddView(_T("Resource"), RUNTIME_CLASS(CManProjectVw2));
                m_wndWorkspace->AddView(_T("Files"),    RUNTIME_CLASS(CManProjectVw3));

                // Define the image list to use with the tab control
                m_TabImages.Create (IDB_BITMAP4, 16, 1, RGB(0,255,0));
                m_wndWorkspace->SetTabImageList(&m_TabImages);

            // allow bar to be resized when floating
            m_wndWorkspace->SetBarStyle(m_wndWorkspace->GetBarStyle() |
                    CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
                m_wndWorkspace->EnableDocking(CBRS_ALIGN_ANY);
        //        EnableDocking(CBRS_ALIGN_ANY);
//                DockControlBar(&m_wndWorkspace, AFX_IDW_DOCKBAR_LEFT);

}





void CreateSampToolBar()
{
        InitCommonControls();
        CMDIFrameWnd* pFrame=acedGetAcadFrame();
    AfxSetResourceHandle(_hdllInstance);

        gpBar = new CDockViewBar;
   // gpBar->SetBtnImageList (&m_ImageList);
//        gpBar->SetMenuID(IDR_POPUP);
        // Initialize dialog bar m_wndOutput
        if (!gpBar->Create(pFrame,_T("Output")))
                {
                        TRACE0("Failed to create dialog bar m_wndOutput\n");

                }

            // allow bar to be resized when floating
       gpBar->SetBarStyle(gpBar->GetBarStyle() |
                    CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);

             gpBar->EnableDocking(CBRS_ALIGN_ANY);
                gpBar->EnableDocking(CBRS_ALIGN_ANY);
        pFrame->EnableDocking(CBRS_ALIGN_ANY);
        pFrame ->DockControlBar(gpBar, AFX_IDW_DOCKBAR_TOP);
            pFrame->ShowControlBar(gpBar, TRUE, TRUE);
        pFrame ->RecalcLayout();
}

// clean up
void DeleteSampToolBar()
{
        if(m_wndWorkspace)
        {
                delete m_wndWorkspace;
                m_wndWorkspace= NULL;
        }
    if(gpBar)
        {
                delete gpBar;
                gpBar = NULL;
        }
        if(acedGetAcadFrame()->m_hWnd && acdbCurDwg())
                acedGetAcadFrame()->RecalcLayout();
}
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-12-24 11:41 , Processed in 0.375694 second(s), 31 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表