E2034 Cannot convert void (_fastcall * (_closure ) (TCustomGridEh *, TGridEhCellMouseEvent

本文介绍了一种Delphi中常见的编译错误:无法将自定义的单元格点击事件处理函数转换为TGridEhCellMouseEvent类型的问题及解决方案。问题在于事件处理函数参数中的TGridCoord缺少const限定符,通过增加const限定符即可解决编译错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >



 void __fastcall TForm3::FormCreate(TObject *Sender)
{

 this->DBGridEh1->OnCellMouseClick = myDBGridEh1CellMouseClick;
}

void __fastcall TForm3::myDBGridEh1CellMouseClick(TCustomGridEh *Grid,  Gridseh::TGridCoord &Cell,
    TMouseButton Button, TShiftState Shift, int X, int Y, bool &Processed)

{
;
}



[bcc32 Error] Unit3.cpp(72): E2034 Cannot convert 'void (_fastcall * (_closure )(TCustomGridEh *,TGridCoord &,TMouseButton,TShiftState,int,int,bool &))(TCustomGridEh *,TGridCoord &,TMouseButton,TShiftState,int,int,bool &)' to 'TGridEhCellMouseEvent'
  Full parser context
    Unit3.cpp(70): parsing: void _fastcall TForm3::FormCreate(TObject *)


查看定义

C:\Users\Public\Documents\RAD Studio\12.0\hpp\GridsEh.hpp

 __property OnCellMouseClick;

 __property Gridseh::TGridEhCellMouseEvent OnCellMouseClick = {read=FOnCellMouseClick, write=FOnCellMouseClick};


typedef void __fastcall (__closure *TGridEhCellMouseEvent)(TCustomGridEh* Grid, const TGridCoord &Cell, System::Uitypes::TMouseButton Button, System::Classes::TShiftState Shift, int X, int Y, bool &Processed);


看出区别在与头文件里的原始定义有const 修饰符,但是新的定义里没有加上就可以了

void __fastcall TForm3::myDBGridEh1CellMouseClick(TCustomGridEh *Grid, const Gridseh::TGridCoord &Cell,
 TMouseButton Button, TShiftState Shift, int X, int Y, bool &Processed)

{
 ;
}


__int64 __fastcall Sn3DAlgorithm::LaserPlane::LaserPlane(__int64 a1, __int64 a2) { __int64 result; // rax *(_QWORD *)a1 = 0i64; *(_QWORD *)(a1 + 8) = 0i64; *(_QWORD *)(a1 + 16) = 0i64; *(_QWORD *)a1 = *(_QWORD *)a2; *(_QWORD *)(a1 + 8) = *(_QWORD *)(a2 + 8); *(_QWORD *)(a1 + 16) = *(_QWORD *)(a2 + 16); *(_QWORD *)a2 = 0i64; *(_QWORD *)(a2 + 8) = 0i64; *(_QWORD *)(a2 + 16) = 0i64; *(_QWORD *)(a1 + 24) = 0i64; *(_QWORD *)(a1 + 32) = 0i64; *(_QWORD *)(a1 + 40) = 0i64; *(_QWORD *)(a1 + 24) = *(_QWORD *)(a2 + 24); *(_QWORD *)(a1 + 32) = *(_QWORD *)(a2 + 32); *(_QWORD *)(a1 + 40) = *(_QWORD *)(a2 + 40); *(_QWORD *)(a2 + 24) = 0i64; *(_QWORD *)(a2 + 32) = 0i64; *(_QWORD *)(a2 + 40) = 0i64; *(_QWORD *)(a1 + 48) = 0i64; *(_QWORD *)(a1 + 56) = 0i64; *(_QWORD *)(a1 + 64) = 0i64; *(_QWORD *)(a1 + 48) = *(_QWORD *)(a2 + 48); *(_QWORD *)(a1 + 56) = *(_QWORD *)(a2 + 56); *(_QWORD *)(a1 + 64) = *(_QWORD *)(a2 + 64); *(_QWORD *)(a2 + 48) = 0i64; *(_QWORD *)(a2 + 56) = 0i64; *(_QWORD *)(a2 + 64) = 0i64; *(_QWORD *)(a1 + 72) = 0i64; *(_QWORD *)(a1 + 80) = 0i64; *(_QWORD *)(a1 + 88) = 0i64; *(_QWORD *)(a1 + 72) = *(_QWORD *)(a2 + 72); *(_QWORD *)(a1 + 80) = *(_QWORD *)(a2 + 80); *(_QWORD *)(a1 + 88) = *(_QWORD *)(a2 + 88); *(_QWORD *)(a2 + 72) = 0i64; *(_QWORD *)(a2 + 80) = 0i64; *(_QWORD *)(a2 + 88) = 0i64; *(_QWORD *)(a1 + 96) = 0i64; *(_QWORD *)(a1 + 104) = 0i64; *(_QWORD *)(a1 + 112) = 0i64; *(_QWORD *)(a1 + 96) = *(_QWORD *)(a2 + 96); *(_QWORD *)(a1 + 104) = *(_QWORD *)(a2 + 104); *(_QWORD *)(a1 + 112) = *(_QWORD *)(a2 + 112); *(_QWORD *)(a2 + 96) = 0i64; *(_QWORD *)(a2 + 104) = 0i64; *(_QWORD *)(a2 + 112) = 0i64; *(_QWORD *)(a1 + 120) = 0i64; *(_QWORD *)(a1 + 128) = 0i64; *(_QWORD *)(a1 + 136) = 0i64; *(_QWORD *)(a1 + 120) = *(_QWORD *)(a2 + 120); *(_QWORD *)(a1 + 128) = *(_QWORD *)(a2 + 128); *(_QWORD *)(a1 + 136) = *(_QWORD *)(a2 + 136); *(_QWORD *)(a2 + 120) = 0i64; *(_QWORD *)(a2 + 128) = 0i64; *(_QWORD *)(a2 + 136) = 0i64; *(_QWORD *)(a1 + 144) = 0i64; *(_QWORD *)(a1 + 152) = 0i64; *(_QWORD *)(a1 + 160) = 0i64; *(_QWORD *)(a1 + 144) = *(_QWORD *)(a2 + 144); *(_QWORD *)(a1 + 152) = *(_QWORD *)(a2 + 152); *(_QWORD *)(a1 + 160) = *(_QWORD *)(a2 + 160); result = a1; *(_QWORD *)(a2 + 144) = 0i64; *(_QWORD *)(a2 + 152) = 0i64; *(_QWORD *)(a2 + 160) = 0i64; *(_OWORD *)(a1 + 176) = *(_OWORD *)(a2 + 176); *(_OWORD *)(a1 + 192) = *(_OWORD *)(a2 + 192); *(_OWORD *)(a1 + 208) = *(_OWORD *)(a2 + 208); *(_OWORD *)(a1 + 224) = *(_OWORD *)(a2 + 224); *(_OWORD *)(a1 + 240) = *(_OWORD *)(a2 + 240); *(_OWORD *)(a1 + 176) = *(_OWORD *)(a2 + 176); *(_OWORD *)(a1 + 192) = *(_OWORD *)(a2 + 192); *(_OWORD *)(a1 + 208) = *(_OWORD *)(a2 + 208); *(_OWORD *)(a1 + 224) = *(_OWORD *)(a2 + 224); *(_OWORD *)(a1 + 240) = *(_OWORD *)(a2 + 240); *(_OWORD *)(a1 + 256) = *(_OWORD *)(a2 + 256); *(_OWORD *)(a1 + 272) = *(_OWORD *)(a2 + 272); *(_OWORD *)(a1 + 256) = *(_OWORD *)(a2 + 256); *(_OWORD *)(a1 + 272) = *(_OWORD *)(a2 + 272); return result; }这段代码转换为C++
03-08
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值