簡體   English   中英

如何將 C# 代表連接到 boost::signal

[英]How can I connect a C# delegate to a boost::signal

我嘗試以這種方式連接

文本存儲

typedef boost::signals2::signal<VOID(TextStore*, RECT*)> signal_GetCompExt;
signal_GetCompExt       m_sigGetCompExt;

信號處理器

delegate VOID GetCompsitionExtDelegate(TextStore* textStore, RECT* rect);
VOID onGetCompsitionExt(TextStore* textStore, RECT* rect);

連接信號

using namespace System::Runtime::InteropServices;
    m_TextStore->m_sigGetCompExt.connect(reinterpret_cast<TextStore::signal_GetCompExt::slot_type*>(Marshal::GetFunctionPointerForDelegate(gcnew GetCompsitionExtDelegate(this, &AppWrapper::onGetCompsitionExt)).ToPointer()));

但它告訴我

C2064   term does not evaluate to a function taking 2 arguments

https://github.com/Windmill-City/libtf/blob/master/libtfWrapper/AppWrapper.cpp

在構建之前設置 Boost Root

路徑: TextServiceFramework\libtf\PropertySheet.props

BoostVersion boost_1_74_0

typedef void (*GetCompExtCallback)(TextStore* ts, RECT* rect);
m_TextStore->m_sigGetCompExt.connect(reinterpret_cast<GetCompExtCallback>(Marshal::GetFunctionPointerForDelegate(gcnew GetCompsitionExtDelegate(this, &AppWrapper::onGetCompsitionExt)).ToPointer()));

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM