简体   繁体   English

如何在旧版 C++ CLR:syntax 应用程序中创建 KeyUp 事件

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

I am trying to change a legacy C++ CLR:oldsyntax application to set up an KeyUp event without success.我正在尝试更改旧版 C++ CLR:oldsyntax 应用程序以设置KeyUp事件但没有成功。
This is the relevant part of the code:这是代码的相关部分:

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

I get the following error:我收到以下错误:

error C2275: 'GrFingerSampleCPPdotNET2005::FormSup::KeyUpFuncDelegate': illegal use of this type as an expression错误 C2275:“GrFingerSampleCPPdotNET2005::FormSup::KeyUpFuncDelegate”:非法使用此类型作为表达式

Any clue?有什么线索吗?

Thanks in advance!提前致谢!

I think you just need to change it to delegate and make sure the event uses that delegate.我认为您只需将其更改为委托并确保事件使用该委托。 An example ripped out of some of code for comparison.一个例子从一些代码中提取出来进行比较。

.h 。H

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

    event StatusTextChangedEventHandler^ StatusTextChanged;

.cpp .cpp

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM