C++Builder DBGrid鼠标滚轮

C++Builder DBGrid鼠标滚轮  



如何在dbgrid中实现鼠标滚轮浏览的功能,即鼠标滚轮控制滚动条的功能。

在头文件中
TWndMethod OldWndProc;
void __fastcall NewWndProc(TMessage &Message);

cpp中
__fastcall TfrmMain::TfrmMain(TComponent* Owner)
: TForm(Owner)
{
OldWndProc = DBGrid1->WindowProc;
DBGrid1->WindowProc = NewWndProc;
}

//---------------------------------------------------------------------------
void __fastcall TfrmMain::NewWndProc(TMessage &Message)
{
//writen by CSDN::JSP //lvjack add this line :-)
if (Message.Msg==WM_MOUSEWHEEL && DBGrid1
->DataSource && DBGrid1->DataSource->
DataSet && Query->Active)
{
DBGrid1->DataSource->DataSet->MoveBy(
(short)Message.WParamHi<0 ? 1 : -1);
//ShowNo();
}
else
OldWndProc(Message);
}


文章来自:http://blog.sina.com.cn/s/blog_4dd73ca8010009ud.html

你可能感兴趣的:(C++Builder,DBGrid鼠标滚)