zdqwy19 发表于 2014-8-6 22:40:00

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

在新版本cad中Ctrl+字母键基本上都被Autodesk公司定义了(在2014中除了Ctrl+R),改用Alt+字母键作为快捷键代替方案。
// 赵德强2014.6.21
//-----------------------------------------------------------------------------
//----- acrxEntryPoint.cpp
//-----------------------------------------------------------------------------
#include "StdAfx.h"
#include "resource.h"
//-----------------------------------------------------------------------------
#define szRDS _RXST("")
//-----------------------------------------------------------------------------
//监测函数
void AltB(const MSG * pMsg);
static BOOL AltBKey = FALSE;   
void AltB(const MSG *pMsg)
{
if (pMsg->wParam == 'B' && (pMsg->lParam>>29 & 1))//监测键盘ALT + B消息
{
    //调用自定义命令
    acDocManager->sendStringToExecute(acDocManager->curDocument(),_T("test "),false,true);
}
return;
}
//-----------------------------------------------------------------------------
//----- ObjectARX EntryPoint
class CtestApp : public AcRxArxApp {
public:
CtestApp () : AcRxArxApp () {}
virtual AcRx::AppRetCode On_kInitAppMsg (void *pkt) {
    // TODO: Load dependencies here
    // You *must* call On_kInitAppMsg here
    AcRx::AppRetCode retCode =AcRxArxApp::On_kInitAppMsg (pkt) ;
   
    // TODO: Add your initialization code here
    //加载快捷键
    if(AltBKey == TRUE)return;
    acedRegisterWatchWinMsg(AltB);
    acedPrompt(_T("\n提示:使用快捷键Alt+B已经可以使用!\n"));
    AltBKey = TRUE;
    return (retCode) ;
}
virtual AcRx::AppRetCode On_kUnloadAppMsg (void *pkt) {
    // TODO: Add your code here
    // You *must* call On_kUnloadAppMsg here
    AcRx::AppRetCode retCode =AcRxArxApp::On_kUnloadAppMsg (pkt) ;
    // TODO: Unload dependencies here
    //卸载快捷键
    if(AltBKey == TRUE)acedRemoveWatchWinMsg(AltB);
    return (retCode) ;
}
virtual void RegisterServerComponents () {
}
public:
// - bianhao._bianhao command (do not rename)
static void test_test(void)
{
    // Add your code for command bianhao._bianhao here
}
} ;
//-----------------------------------------------------------------------------
IMPLEMENT_ARX_ENTRYPOINT(CtestApp)
ACED_ARXCOMMAND_ENTRY_AUTO(CtestApp, test, _test, test, ACRX_CMD_TRANSPARENT, NULL)

   
**** Hidden Message *****

luowy 发表于 2014-8-8 11:25:00

代码要简洁化,模块化啊。
void initHook()
{
//注册钩子
}
unloadHook()
{
//移除钩子
}
此外,钩子还可以做好多事情

swjtu_csdn2 发表于 2014-8-15 04:06:00

这个办法确实还是可行。
页: [1]
查看完整版本: 使用Alt+字母键作为快捷键