明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1320|回复: 2

使用Alt+字母键作为快捷键

  [复制链接]
发表于 2014-8-6 22:40 | 显示全部楼层 |阅读模式
本帖最后由 zdqwy19 于 2014-8-6 22:42 编辑

     在新版本cad中Ctrl+字母键基本上都被Autodesk公司定义了(在2014中除了Ctrl+R),改用Alt+字母键作为快捷键代替方案。
  1. // 赵德强  2014.6.21
  2. //-----------------------------------------------------------------------------
  3. //----- acrxEntryPoint.cpp
  4. //-----------------------------------------------------------------------------
  5. #include "StdAfx.h"
  6. #include "resource.h"
  7. //-----------------------------------------------------------------------------
  8. #define szRDS _RXST("")
  9. //-----------------------------------------------------------------------------
  10. //监测函数
  11. void AltB(const MSG * pMsg);
  12. static BOOL AltBKey = FALSE;   
  13. void AltB(const MSG *pMsg)
  14. {
  15.   if (pMsg->wParam == 'B' && (pMsg->lParam>>29 & 1))//监测键盘ALT + B消息
  16.   {
  17.     //调用自定义命令
  18.     acDocManager->sendStringToExecute(acDocManager->curDocument(),_T("test "),false,true);
  19.   }
  20.   return;
  21. }
  22. //-----------------------------------------------------------------------------
  23. //----- ObjectARX EntryPoint
  24. class CtestApp : public AcRxArxApp {

  25. public:
  26.   CtestApp () : AcRxArxApp () {}

  27.   virtual AcRx::AppRetCode On_kInitAppMsg (void *pkt) {
  28.     // TODO: Load dependencies here

  29.     // You *must* call On_kInitAppMsg here
  30.     AcRx::AppRetCode retCode =AcRxArxApp::On_kInitAppMsg (pkt) ;
  31.    
  32.     // TODO: Add your initialization code here
  33.     //加载快捷键
  34.     if(AltBKey == TRUE)return;
  35.     acedRegisterWatchWinMsg(AltB);
  36.     acedPrompt(_T("\n提示:使用快捷键Alt+B已经可以使用!\n"));
  37.     AltBKey = TRUE;

  38.     return (retCode) ;
  39.   }

  40.   virtual AcRx::AppRetCode On_kUnloadAppMsg (void *pkt) {
  41.     // TODO: Add your code here

  42.     // You *must* call On_kUnloadAppMsg here
  43.     AcRx::AppRetCode retCode =AcRxArxApp::On_kUnloadAppMsg (pkt) ;

  44.     // TODO: Unload dependencies here
  45.     //卸载快捷键
  46.     if(AltBKey == TRUE)  acedRemoveWatchWinMsg(AltB);

  47.     return (retCode) ;
  48.   }

  49.   virtual void RegisterServerComponents () {
  50.   }

  51. public:

  52.   // - bianhao._bianhao command (do not rename)
  53.   static void test_test(void)
  54.   {
  55.     // Add your code for command bianhao._bianhao here
  56.   }
  57. } ;

  58. //-----------------------------------------------------------------------------
  59. IMPLEMENT_ARX_ENTRYPOINT(CtestApp)

  60. ACED_ARXCOMMAND_ENTRY_AUTO(CtestApp, test, _test, test, ACRX_CMD_TRANSPARENT, NULL)

     

本帖子中包含更多资源

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

x
发表于 2014-8-8 11:25 | 显示全部楼层
代码要简洁化,模块化啊。
void initHook()
{
//注册钩子
}
unloadHook()
{
//移除钩子
}
此外,钩子还可以做好多事情
发表于 2014-8-15 04:06 | 显示全部楼层
这个办法确实还是可行。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-3-29 01:57 , Processed in 0.500719 second(s), 28 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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