无论我如何尝试使用它,我都无法动态创建 aTScrollBox
并为其分配OnMouseWheelEvent
处理程序。我收到以下编译器错误:
E2034 无法将 'void (_fastcall * (_closure )(TObject *,TShiftState,int,TPoint &,bool &))(TObject *,TShiftState,int,TPoint &,bool &)' 转换为 'TMouseWheelEvent'
我对OnMouseWheelEvent
处理程序的声明是正确的(据我所知):
....
TScrollBox *sb = new TScrollBox(funnelCharts);
sb->Top = 5000;
sb->Parent = funnelCharts;
sb->Align = alClient;
sb->Height = funnelCharts->ClientHeight;
sb->OnMouseWheel = scrollEvent;
....
// --------------------------------------------------------------
void __fastcall TForm1::scrollEvent(TObject *Sender, TShiftState Shift, int WheelDelta, TPoint &MousePos, bool &Handled)
{
TScrollBox *scrollbox = dynamic_cast<TScrollBox*>(Sender);
if (scrollbox)
{
for (int i = 1; i < Mouse->WheelScrollLines; i++)
{
if (WheelDelta > 0)
{
scrollbox->Perform(WM_VSCROLL, SB_LINEUP, 0);
}
else
{
scrollbox->Perform(WM_VSCROLL, SB_LINEDOWN, 0);
}
}
scrollbox->Perform(WM_VSCROLL, SB_ENDSCROLL, 0);
Handled = true;
}
}