簡體   English   中英

如何在舊版 C++ CLR:syntax 應用程序中創建 KeyUp 事件

[英]how to create a KeyUp event in a legacy C++ CLR:syntax application

我正在嘗試更改舊版 C++ CLR:oldsyntax 應用程序以設置KeyUp事件但沒有成功。
這是代碼的相關部分:

// declare delegate
__delegate void  KeyUpFuncDelegate(Object */*sender*/, System::Windows::Forms::KeyEventArgs * e);
    
// try to hook up the event
this->SuperMatricula->KeyUp+= KeyEventHandler(this,KeyUpFuncDelegate);

我收到以下錯誤:

錯誤 C2275:“GrFingerSampleCPPdotNET2005::FormSup::KeyUpFuncDelegate”:非法使用此類型作為表達式

有什么線索嗎?

提前致謝!

我認為您只需將其更改為委托並確保事件使用該委托。 一個例子從一些代碼中提取出來進行比較。

。H

private ref class StatusMgr sealed
{
public:
    delegate void StatusTextChangedEventHandler( System::Object^ sender, StatusTextChangedEventArgs^ args );

    event StatusTextChangedEventHandler^ StatusTextChanged;

.cpp

statusMgr->StatusTextChanged += 
    gcnew StatusMgr::StatusTextChangedEventHandler( this, &StatusBarTextItem::onStatusTextChanged );

暫無
暫無

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

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