明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 224|回复: 2

o3年编的的程序能否转换成现在高版本的程序

[复制链接]
发表于 2025-7-8 08:44:50 | 显示全部楼层 |阅读模式
10明经币
本帖最后由 fundoll 于 2025-7-8 10:00 编辑

一个是输入法自动转换成英文,比较简单,

一个是型材程序,用到了WTL
二十几年前的了,现在不会编程了


//////////////////////////////////////////////////////////////
//
// Includes
//
//////////////////////////////////////////////////////////////
#define _AFX_NOFORCE_LIBS // we do not want to link to MFC DLLs or libs
#ifdef _DEBUG
#define WAS_DEBUG
#undef _DEBUG
#endif

#include "afxwin.h"  // need this because ******rxmfcapi.h****** needs windows header.

#ifdef WAS_DEBUG
#undef WAS_DEBUG
#define _DEBUG
#endif

#include "aced.h"
#include "adslib.h"
#include "rxmfcapi.h"
#include "acedads.h"

#include "acdocman.h"


//////////////////////////////////////////////////////////////
//
// Standard C Test function
//
//////////////////////////////////////////////////////////////

void autoime();                   // ARX callbacks
void mouse();
void unautoime();
void unmouse();


BOOL filterLC(MSG *pMsg);      // hook function for autoimeing.
BOOL filterMouse(MSG *pMsg);   // hook function for making mouse dragging
                               // only horizontal or vertical based on
                               // SHIFT or Control key is pressed or not.

static BOOL vMode; // holds mouse vertical Mode status
static BOOL hMode; // holds mouse horizontal Mode status

// preventing from inserting the same hook twice.
static BOOL autoimeDone = FALSE;
static BOOL mouseDone = FALSE;


//////////////////////////////////////////////////////////////
//
// Rx interface
//
//////////////////////////////////////////////////////////////


void initApp()
{

  acedRegCmds->addCommand( "MKEvents",      // Group name
                           "autoime",      // Global function name
                           "autoime",          // Local function name
                           ACRX_CMD_MODAL,    // Type
                           &autoime );         // Function pointer
  acedRegCmds->addCommand( "MKEvents",      // Group name
                           "vhmouse",      // Global function name
                           "vhmouse",          // Local function name
                           ACRX_CMD_MODAL,    // Type
                           &mouse );         // Function pointer
  acedRegCmds->addCommand( "MKEvents",      // Group name
                           "unautoime",      // Global function name
                           "unautoime",          // Local function name
                           ACRX_CMD_MODAL,    // Type
                           &unautoime );         // Function pointer
  acedRegCmds->addCommand( "MKEvents",      // Group name
                           "unvhmouse",      // Global function name
                           "unvhmouse",          // Local function name
                           ACRX_CMD_MODAL,    // Type
                           &unmouse );         // Function pointer

  //acutPrintf( ".OK!\n" );

}

void unloadApp()
{
  // Remove the command group because we are unloading
  //  
  acedRegCmds->removeGroup( "MKEvents" );

  // Removing all hooks <no matter they're planted or not>

  if (autoimeDone == TRUE)
      acedRemoveFilterWinMsg(filterLC);

  if (mouseDone == TRUE)
      acedRemoveFilterWinMsg(filterMouse);

}


//////////////////////////////////////////////////////////////
//
// Entry point
//
//////////////////////////////////////////////////////////////

extern "C" AcRx::AppRetCode acrxEntryPoint( AcRx::AppMsgCode msg, void* pkt)
{
  switch( msg )
  {
    case AcRx::kInitAppMsg:
      initApp();
      acrxUnlockApplication(pkt);
          acrxDynamicLinker->registerAppMDIAware(pkt);
          //initialize
      autoime();
      break;
    case AcRx::kUnloadAppMsg:
      unloadApp();
      break;
    default:
      break;
  }
  return AcRx::kRetOK;
}



//////////////////////////////////////////////////////////////

BOOL filterLC(MSG *pMsg)
{   
        //HWND hCmdLineHWnd =  acedGetAcadTextCmdLine()->m_hWnd;
        if (acDocManager->curDocument() == NULL) return FALSE;

        static struct resbuf rb;
        acedGetVar("CMDACTIVE", &rb);

        static HKL hklCurrent;
    hklCurrent=GetKeyboardLayout(0);       
    if (rb.resval.rint == 0 && (int)hklCurrent<0 )
        //acutPrintf("\n%d:%d",hklCurrent,rb.resval.rint);
                ActivateKeyboardLayout(0,KLF_SETFORPROCESS);//激活输入法,注意复制文本时有非法字符 error C2018: 未知字符“0xa1”;不支持 unicode 标识符

    return FALSE; // continue
}


// Pressing CTRL key when dragging makes the mouse moves vertical only
// Pressing SHIHT key when dragging makes the mouse moves horizontal only

BOOL filterMouse(MSG *pMsg)
{
    static long ptx=0;
    static long pty=0;

    if (pMsg->message == WM_MOUSEMOVE || pMsg->message == WM_LBUTTONDOWN
        || pMsg->message == WM_LBUTTONUP)
    {
        if ((pMsg->message == WM_LBUTTONDOWN || pMsg->message == WM_LBUTTONUP) &&
             (vMode == TRUE ||  hMode == TRUE))
        {
            pMsg->lParam = MAKELONG(ptx, pty);
            return FALSE;
        }

        if (pMsg->wParam == MK_CONTROL)
        {
            if (vMode == TRUE) // Prev Pt is set already
            {
                pMsg->lParam = MAKELONG(ptx, HIWORD(pMsg->lParam));
                pty = HIWORD(pMsg->lParam);
            } else
                ptx= LOWORD(pMsg->lParam);
            vMode = TRUE;
            hMode = FALSE;
        } else if (pMsg->wParam == MK_SHIFT)
        {
            if (hMode == TRUE) // Prev Pt is set already
            {
                pMsg->lParam = MAKELONG(LOWORD(pMsg->lParam), pty);
                ptx = LOWORD(pMsg->lParam);
            } else
                pty= HIWORD(pMsg->lParam);
            hMode = TRUE;
            vMode = FALSE;
        } else
        {
            vMode = hMode =  FALSE;
        }
    }

    return FALSE; // continue
}


///////////////////////

void autoime()
{
    if (autoimeDone == TRUE) // already has the hook??
      return;
    //acutPrintf( "autoimeing...\n" );
    if (acedRegisterFilterWinMsg(filterLC) == FALSE)
        acutPrintf("Can't register Windows Msg hook - autoime\n");
    else
      autoimeDone = TRUE;
}

void unautoime()
{
    if (autoimeDone == TRUE)
    {
        acedRemoveFilterWinMsg(filterLC);
        autoimeDone = FALSE;
    }
}

void mouse()
{
    if (mouseDone == TRUE) // already has the hook?
      return;
  
    ::vMode = FALSE;
    ::hMode = FALSE;
    acutPrintf( "mouseing...\n" );

    if (acedRegisterFilterWinMsg(filterMouse) == FALSE)
        acutPrintf("Can't register Windows Msg hook - VH - mouse\n");
    else
        mouseDone = TRUE;
}

void unmouse()
{
    if (mouseDone == TRUE)
    {
        acedRemoveFilterWinMsg(filterMouse);
        mouseDone = FALSE;
    }
}




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

使用道具 举报

发表于 2025-7-19 19:28:54 | 显示全部楼层
xg.rar 里面缺少文件。
回复

使用道具 举报

发表于 7 天前 | 显示全部楼层
这个输入法钩子函数写的合适吗?看着感觉不太对啊
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-7-27 04:21 , Processed in 0.155389 second(s), 21 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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