找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 活动 交友 discuz
查看: 36|回复: 0

如何设置CAD选项对话框的配置AcApProfileManagerReactor反应器

[复制链接]

0

主题

0

回帖

26

积分

管理员

积分
26
发表于 2024-9-25 13:22:32 | 显示全部楼层 |阅读模式
<pre name="code" class="cpp">如何设置CAD选项对话框的配置
利用>反应器就可以设置
  1. // (C) Copyright 1999-2006 by Autodesk, Inc.
  2. //
  3. // Permission to use, copy, modify, and distribute this software in
  4. // object code form for any purpose and without fee is hereby granted,
  5. // provided that the above copyright notice appears in all copies and
  6. // that both that copyright notice and the limited warranty and
  7. // restricted rights notice below appear in all supporting
  8. // documentation.
  9. //
  10. // AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
  11. // AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
  12. // MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE.  AUTODESK, INC.
  13. // DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
  14. // UNINTERRUPTED OR ERROR FREE.
  15. //
  16. // Use, duplication, or disclosure by the U.S. Government is subject to
  17. // restrictions set forth in FAR 52.227-19 (Commercial Computer
  18. // Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
  19. // (Rights in Technical Data and Computer Software), as applicable.
  20. //
  21. #if defined(_DEBUG) && !defined(AC_FULL_DEBUG)
  22. #error _DEBUG should not be defined except in internal Adesk debug builds
  23. #endif
  24. #include <rxregsvc.h>
  25. #include <aced.h>
  26. #include <dbxutil.h>
  27. #include <acprofile.h>
  28. #include <adslib.h>
  29. #include "tchar.h"
  30. // Define a class derived from AcApProfileManagerReactor to manage
  31. // the notifications.
  32. //
  33. class AsdkProfileManagerReactor : public AcApProfileManagerReactor
  34. {
  35. public:
  36.     void currentProfileWillChange(const TCHAR *newProfile);
  37.     void currentProfileChanged(const TCHAR *newProfile);
  38.     void currentProfileWillBeReset(const TCHAR *curProfile);
  39.     void currentProfileReset(const TCHAR *curProfile);
  40.     void profileWillReset(const TCHAR *profName);
  41.     void profileReset(const TCHAR *proName);
  42. };
  43. // Define the notification functions
  44. //
  45. void
  46. AsdkProfileManagerReactor::
  47. currentProfileWillChange(const TCHAR *newProfile)
  48. {
  49.     acutPrintf(_T("\nCurrent profile will change: %s"), newProfile);
  50. }
  51. void
  52. AsdkProfileManagerReactor::
  53. currentProfileChanged(const TCHAR *newProfile)
  54. {
  55.     acutPrintf(_T("\nCurrent profile changed: %s"), newProfile);
  56. }
  57. void
  58. AsdkProfileManagerReactor::
  59. currentProfileWillBeReset(const TCHAR *curProfile)
  60. {
  61.     acutPrintf(_T("\nCurrent profile will be reset: %s"), curProfile);
  62. }
  63. void
  64. AsdkProfileManagerReactor::
  65. currentProfileReset(const TCHAR *curProfile)
  66. {
  67.     acutPrintf(_T("\nCurrent profile has been reset: %s"), curProfile);
  68. }
  69. void
  70. AsdkProfileManagerReactor::
  71. profileWillReset(const TCHAR *profName)
  72. {
  73.     acutPrintf(_T("\nA non-current profile will be reset: %s"), profName);
  74. }
  75. void
  76. AsdkProfileManagerReactor::
  77. profileReset(const TCHAR *profName)
  78. {
  79.     acutPrintf(_T("\nA non-current profile has been reset: %s"), profName);
  80. }
  81. void
  82. aFunction()
  83. {
  84.     acutPrintf(_T("This is AsdkProfileSample Test Application...\n"));
  85.     // Attach the reactor for the duration of this command. Normally
  86.     // this would likely be added upon application initialization.
  87.     //
  88.     AsdkProfileManagerReactor *pProfileRector =
  89.         new AsdkProfileManagerReactor();
  90.    
  91.     acProfileManagerPtr()->addReactor(pProfileRector);
  92.     // Obtain the path for the registry keys and print it out.
  93.     //
  94.     TCHAR *pstrKey;
  95.     acProfileManagerPtr()->ProfileRegistryKey(pstrKey, NULL);
  96.     if (pstrKey != NULL) {
  97.         acutPrintf(_T("\nThe profiles registry key is: %s"), pstrKey);
  98.         acutDelString(pstrKey);
  99.     }
  100.     // Get the list of all profiles in the users configuration
  101.     // and print them out.
  102.     //
  103.     AcApProfileNameArray arrNameList;
  104.     int nProfiles =
  105.         acProfileManagerPtr()->ProfileListNames(arrNameList);
  106.     acutPrintf(_T("\nNumber of profiles currently ")
  107.         _T("in the user profile list is: %d"), nProfiles);
  108.     for (int i = 0; i < nProfiles; i++)
  109.         acutPrintf(_T("\nProfile name is: %s"), arrNameList[i]);
  110.    
  111.     // Copy the unnamed profile to the AsdkTestProfile
  112.     //
  113.     acProfileManagerPtr()->ProfileCopy(_T("AsdkTestProfile"),
  114.                                        _T("<<Unnamed Profile>>"),
  115.                                        _T("This is a test"));
  116.     // Reset the newly copied profile to AutoCAD defualts.
  117.     //
  118.     acProfileManagerPtr()->ProfileReset(_T("AsdkTestProfile"));
  119.     // Make this new profile current.
  120.     //
  121.     acProfileManagerPtr()->ProfileSetCurrent(_T("AsdkTestProfile"));
  122.    
  123.     // Change a value in the profile. We'll just make the
  124.     // cursor big.
  125.     //
  126.     struct resbuf rbCursorSize;
  127.     rbCursorSize.restype = RTSHORT;
  128.     rbCursorSize.resval.rint = 100;
  129.     acedSetVar(_T("CURSORSIZE"), &rbCursorSize);
  130.     // Rename the profile to a new name.
  131.     //
  132.     acProfileManagerPtr()->ProfileRename(_T("AsdkTestProfile2"),
  133.                                          _T("AsdkTestProfile"),
  134.                                          _T("This is another test"));
  135.     // Export the profile.
  136.     //
  137.     acProfileManagerPtr()->ProfileExport(_T("AsdkTestProfile2"),
  138.                                          _T("./AsdkTestProfile2.arg"));
  139.     // Import the profile.
  140.     //
  141.     acProfileManagerPtr()->ProfileImport(_T("AsdkTestProfile3"),
  142.                                          _T("./AsdkTestProfile2.arg"),
  143.                                          _T("This is a copy of AsdkTestProfile2")
  144.                                          _T("by Exporting/Importing"),
  145.                                          Adesk::kTrue);
  146.     // Remove the reactor.
  147.     //
  148.     acProfileManagerPtr()->removeReactor(pProfileRector);
  149. }
  150. void
  151. initApp()
  152. {
  153.     acutPrintf(_T("AsdkProfileSample ARX Test; Type ProfileSample to execute"));
  154.    
  155.     // register a command with the AutoCAD command mechanism
  156.     //
  157.     acedRegCmds->addCommand(_T("AsdkProfileSample_COMMANDS"), _T("AsdkProfileSample"), _T("ProfileSample"), ACRX_CMD_MODAL, aFunction);
  158. }
  159. void unloadApp()
  160. {
  161.    
  162.    
  163.     // Remove the command group added via acedRegCmds->addCommand
  164.     //
  165.     acedRegCmds->removeGroup(_T("AsdkProfileSample_COMMANDS"));
  166. }
  167. extern "C" AcRx::AppRetCode
  168. acrxEntryPoint(AcRx::AppMsgCode msg, void* appId)
  169. {
  170.     switch (msg) {
  171.     case AcRx::kInitAppMsg:
  172.         acrxDynamicLinker->unlockApplication(appId);
  173.         acrxDynamicLinker->registerAppMDIAware(appId);
  174.         initApp();
  175.         break;
  176.     case AcRx::kUnloadAppMsg:
  177.         unloadApp();
  178.         break;
  179.     case AcRx::kLoadDwgMsg:
  180.         break;
  181.     case AcRx::kUnloadDwgMsg:
  182.         break;
  183.     case AcRx::kInvkSubrMsg:
  184.         break;
  185.     default:
  186.         ;
  187.     }
  188.     return AcRx::kRetOK;
  189. }
复制代码
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|膜结构网

GMT+8, 2024-12-27 22:34 , Processed in 0.138903 second(s), 19 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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