解决DBGrid的鼠标滚动的方法
1. Add in .h file:
private: // 添加声明
void __fastcall (__closure *OldProc)(Messages::TMessage &Message);
void __fastcall NewProc(TMessage &Message);
2. Add in .cpp file:
// 添加以下语句到OnFormCreate事件中
OldProc = DBGrid1->WindowProc;
DBGrid1->WindowProc = NewProc;
void __fastcall TForm1::NewProc(TMessage& Message)
{
if (Message.Msg == WM_MOUSEWHEEL)
{
int z = GET_WHEEL_DELTA_WPARAM(Message.WParam);
Message.Msg = WM_VSCROLL;
if (z > 0)
Message.WParam = SB_LINEUP;
else
Message.WParam = SB_LINEDOWN;
}
OldProc(Message);
}
本文地址:http://com.8s8s.com/it/it28681.htm