使用 RAD Studio 10.4.2:
我TScrollBox
在运行时创建:
TScrollBox* sb = new TScrollBox(this);
sb->Parent = this;
sb->Align = alClient;
sb->AlignWithMargins = true;
sb->Margins->SetBounds(3,3,3,3);
sb->BorderStyle = bsNone;
sb->VertScrollBar->Smooth = true;
sb->VertScrollBar->Tracking = true;
sb->ParentBackground = true;
sb->OnMouseWheel = ScrollBox1MouseWheel; // Error here
我想给它分配OnMouseWheel
事件:
void __fastcall TForm1::ScrollBox1MouseWheel(TObject *Sender, TShiftState Shift, int WheelDelta,
TPoint &MousePos, bool &Handled)
{
// Some code here
}
鼠标滚轮事件就是我把它放在窗体上双击生成上述事件代码时得到的。
错误是:
[bcc32c Error] assigning to 'Vcl::Controls::TMouseWheelEvent' (aka 'void ((__closure *))(System::TObject *, System::Classes::TShiftState, int, const System::Types::TPoint &, bool &) __attribute__((fastcall))') from incompatible type 'void (__closure *)(System::TObject *, System::Classes::TShiftState, int, System::Types::TPoint &, bool &) __attribute__((fastcall))'
那么我该如何分配事件,我是否需要以某种方式投射它?