ObjectARX学习笔记(十六)--如何设置CAD选项对话框的配置AcApProfileManagerReactor反应器

<pre name="code" class="cpp">如何设置CAD选项对话框的配置
利用>反应器就可以设置


 
// (C) Copyright 1999-2006 by Autodesk, Inc. 
//
// Permission to use, copy, modify, and distribute this software in
// object code form for any purpose and without fee is hereby granted, 
// provided that the above copyright notice appears in all copies and 
// that both that copyright notice and the limited warranty and
// restricted rights notice below appear in all supporting 
// documentation.
//
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS. 
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE.  AUTODESK, INC. 
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
// UNINTERRUPTED OR ERROR FREE.
//
// Use, duplication, or disclosure by the U.S. Government is subject to 
// restrictions set forth in FAR 52.227-19 (Commercial Computer
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
// (Rights in Technical Data and Computer Software), as applicable.
//


#if defined(_DEBUG) && !defined(AC_FULL_DEBUG)
#error _DEBUG should not be defined except in internal Adesk debug builds
#endif

#include <rxregsvc.h>
#include <aced.h>
#include <dbxutil.h>
#include <acprofile.h>
#include <adslib.h>
#include "tchar.h"



// Define a class derived from AcApProfileManagerReactor to manage 
// the notifications.
//
class AsdkProfileManagerReactor : public AcApProfileManagerReactor
{
public:
    void currentProfileWillChange(const TCHAR *newProfile);
    void currentProfileChanged(const TCHAR *newProfile);
    void currentProfileWillBeReset(const TCHAR *curProfile);
    void currentProfileReset(const TCHAR *curProfile);
    void profileWillReset(const TCHAR *profName);
    void profileReset(const TCHAR *proName);
};

// Define the notification functions
//
void 
AsdkProfileManagerReactor::
currentProfileWillChange(const TCHAR *newProfile)
{
    acutPrintf(_T("\nCurrent profile will change: %s"), newProfile);
}

void 
AsdkProfileManagerReactor::
currentProfileChanged(const TCHAR *newProfile)
{
    acutPrintf(_T("\nCurrent profile changed: %s"), newProfile);
}

void 
AsdkProfileManagerReactor::
currentProfileWillBeReset(const TCHAR *curProfile)
{
    acutPrintf(_T("\nCurrent profile will be reset: %s"), curProfile);
}

void 
AsdkProfileManagerReactor::
currentProfileReset(const TCHAR *curProfile)
{
    acutPrintf(_T("\nCurrent profile has been reset: %s"), curProfile);
}

void 
AsdkProfileManagerReactor::
profileWillReset(const TCHAR *profName)
{
    acutPrintf(_T("\nA non-current profile will be reset: %s"), profName);
}

void 
AsdkProfileManagerReactor::
profileReset(const TCHAR *profName)
{
    acutPrintf(_T("\nA non-current profile has been reset: %s"), profName);
}


void
aFunction()
{
    acutPrintf(_T("This is AsdkProfileSample Test Application...\n"));

    // Attach the reactor for the duration of this command. Normally
    // this would likely be added upon application initialization.
    //
    AsdkProfileManagerReactor *pProfileRector = 
        new AsdkProfileManagerReactor();
    
    acProfileManagerPtr()->addReactor(pProfileRector);

    // Obtain the path for the registry keys and print it out.
    //
    TCHAR *pstrKey;
    acProfileManagerPtr()->ProfileRegistryKey(pstrKey, NULL);

    if (pstrKey != NULL) {
        acutPrintf(_T("\nThe profiles registry key is: %s"), pstrKey);
        acutDelString(pstrKey);
    }

    // Get the list of all profiles in the users configuration
    // and print them out.
    //
    AcApProfileNameArray arrNameList;
    int nProfiles = 
        acProfileManagerPtr()->ProfileListNames(arrNameList);

    acutPrintf(_T("\nNumber of profiles currently ")
        _T("in the user profile list is: %d"), nProfiles);
    for (int i = 0; i < nProfiles; i++)
        acutPrintf(_T("\nProfile name is: %s"), arrNameList[i]);
    
    // Copy the unnamed profile to the AsdkTestProfile
    //
    acProfileManagerPtr()->ProfileCopy(_T("AsdkTestProfile"), 
                                       _T("<<Unnamed Profile>>"), 
                                       _T("This is a test"));

    // Reset the newly copied profile to AutoCAD defualts.
    //
    acProfileManagerPtr()->ProfileReset(_T("AsdkTestProfile"));

    // Make this new profile current.
    //
    acProfileManagerPtr()->ProfileSetCurrent(_T("AsdkTestProfile"));
    
    // Change a value in the profile. We'll just make the 
    // cursor big.
    //
    struct resbuf rbCursorSize;
    rbCursorSize.restype = RTSHORT;
    rbCursorSize.resval.rint = 100;
    acedSetVar(_T("CURSORSIZE"), &rbCursorSize);

    // Rename the profile to a new name.
    //
    acProfileManagerPtr()->ProfileRename(_T("AsdkTestProfile2"), 
                                         _T("AsdkTestProfile"), 
                                         _T("This is another test"));

    // Export the profile.
    //
    acProfileManagerPtr()->ProfileExport(_T("AsdkTestProfile2"), 
                                         _T("./AsdkTestProfile2.arg"));

    // Import the profile.
    // 
    acProfileManagerPtr()->ProfileImport(_T("AsdkTestProfile3"), 
                                         _T("./AsdkTestProfile2.arg"), 
                                         _T("This is a copy of AsdkTestProfile2")
                                         _T("by Exporting/Importing"), 
                                         Adesk::kTrue);

    // Remove the reactor.
    //
    acProfileManagerPtr()->removeReactor(pProfileRector);

}

void
initApp()
{
    acutPrintf(_T("AsdkProfileSample ARX Test; Type ProfileSample to execute"));
    
    // register a command with the AutoCAD command mechanism
    //
    acedRegCmds->addCommand(_T("AsdkProfileSample_COMMANDS"), _T("AsdkProfileSample"), _T("ProfileSample"), ACRX_CMD_MODAL, aFunction);

}


void unloadApp()
{
    
    
    // Remove the command group added via acedRegCmds->addCommand
    //
    acedRegCmds->removeGroup(_T("AsdkProfileSample_COMMANDS"));

}

extern "C" AcRx::AppRetCode 
acrxEntryPoint(AcRx::AppMsgCode msg, void* appId)
{
    switch (msg) {
    case AcRx::kInitAppMsg:
        acrxDynamicLinker->unlockApplication(appId);
        acrxDynamicLinker->registerAppMDIAware(appId);
        initApp();
        break;
    case AcRx::kUnloadAppMsg:
        unloadApp();
        break;
    case AcRx::kLoadDwgMsg:

        break;
    case AcRx::kUnloadDwgMsg:

        break;
    case AcRx::kInvkSubrMsg:

        break;
    default:
        ;
    }
    return AcRx::kRetOK;
}

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值