天气与日历 切换到窄版

 找回密码
 立即注册
中国膜结构网
十大进口膜材评选 十大国产膜材评选 十大膜结构设计评选 十大膜结构公司评选
查看: 69|回复: 0

从 AutoCAD 外部发送WM_COPYDATA消息

[复制链接]

该用户从未签到

主题

0

回帖

2912

积分

管理员

积分
2912
发表于 2024-6-22 09:46:18 | 显示全部楼层 |阅读模式
//-----------------------------------------------------------------------------
//----- acrxEntryPoint.cpp
//-----------------------------------------------------------------------------
#include "StdAfx.h"
#include "resource.h"

//-----------------------------------------------------------------------------
#define szRDS _RXST("")

//globals
WNDPROC gWndProc;

//new window procedure
LRESULT CALLBACK myWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
  if (uMsg == WM_COPYDATA) {
    ::MessageBox(NULL, L"WM_COPYDATA received!!!", L"Alert", MB_OK);
  }
  return ::CallWindowProc(gWndProc, hwnd, uMsg, wParam, lParam);
}


//-----------------------------------------------------------------------------
//----- ObjectARX EntryPoint
class CSend_WM_COPYDATAApp : public AcRxArxApp {

public:
  CSend_WM_COPYDATAApp() : AcRxArxApp() {}

  virtual AcRx::AppRetCode On_kInitAppMsg(void* pkt) {
    AcRx::AppRetCode retCode = AcRxArxApp::On_kInitAppMsg(pkt);
    AddWinHook();
    return (retCode);
  }

  virtual AcRx::AppRetCode On_kUnloadAppMsg(void* pkt) {
    RemoveWinHook();
    AcRx::AppRetCode retCode = AcRxArxApp::On_kUnloadAppMsg(pkt);
    return (retCode);
  }
  //subclassing the AutoCAD Main frame
  void AddWinHook()
  {
    gWndProc = (WNDPROC)::SetWindowLongPtr(adsw_acadMainWnd(), GWLP_WNDPROC, (LONG_PTR)myWndProc);
  }
  //unload windows hook
  void RemoveWinHook()
  {
    //restore the old winproc address
    gWndProc = (WNDPROC)::SetWindowLongPtr(adsw_acadMainWnd(), GWLP_WNDPROC, (LONG_PTR)gWndProc);
  }

  virtual void RegisterServerComponents() { }

  static void MyGroupMyTest() {
   ACHAR *s = L"(alert \"Hello from WM_COPYDATA\")\n";
   SendCmdToAcad(s);
  }
  static void SendCmdToAcad(const ACHAR* cmd)
  {
    COPYDATASTRUCT cmdMsg;
    cmdMsg.dwData = (DWORD)1;
    cmdMsg.cbData = (DWORD)(_tcslen(cmd) + 1) * sizeof(ACHAR);
    cmdMsg.lpData = (void *)cmd;
    SendMessage(adsw_acadMainWnd(), WM_COPYDATA, NULL, (LPARAM)&cmdMsg);
  }
};

//-----------------------------------------------------------------------------
IMPLEMENT_ARX_ENTRYPOINT(CSend_WM_COPYDATAApp)

ACED_ARXCOMMAND_ENTRY_AUTO(CSend_WM_COPYDATAApp, MyGroup, MyTest, MyTest, ACRX_CMD_MODAL, NULL)[code]https://forums.autodesk.com/t5/objectarx/sending-wm-copydata-message-from-outside-autocad/m-p/9806250[/code]

 

 

 

 

从 AutoCAD 外部发送WM_COPYDATA消息
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|中国膜结构网|中国膜结构协会|进口膜材|国产膜材|ETFE|PVDF|PTFE|设计|施工|安装|车棚|看台|污水池|中国膜结构网_中国空间膜结构协会

GMT+8, 2024-11-1 12:38 , Processed in 0.128779 second(s), 26 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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