有点儿不明白你的意图的!
你可以在dbgrid的控件那儿判断它的onmousedown事件中的button
是不是mbmiddle来判断中键是否按下,
或者拦截它的消息:
procedure doscroll(var msg:tmessage);message wm_mousewheel;
.......
procedure tform1.doscroll;
begin
if msg.WParamHi >120 then
begin
repeat
dbgrid1.DataSource.DataSet.Next ;
until dbgrid1.datasource.dataset.Eof ;
end;
if msg.WParamHi< 120 then
begin
repeat
dbgrid1.DataSource.DataSet.Prior ;
until dbgrid1.DataSource.DataSet.Bof ;
end;
end;
向下滚!
sendmessage(dbgrid1.handle,wm_vscroll,sb_linedown,0);
向上滚!
sendmessage(dbgrid1.handle,wm_vscroll,sb_lineup,0);
写成:
procedure tform1.doscroll;
begin
if msg.WParamHi >120 then
begin
sendmessage(dbgrid1.handle,wm_vscroll,sb_linedown,0);
end;
if msg.WParamHi< 120 then
begin
sendmessage(dbgrid1.handle,wm_vscroll,sb_lineup,0);
end;
end;
老兄,我知道你说什么了,程序没有出错了,但是鼠标的第三键还是没有反映呀!写不写
语句是一样的呀!是哪里错了呀! 请大哥指教,我是FORM6里面的DBGRID1
procedure tform6.doscroll;
begin
if msg.WParamHi >120 then
begin
repeat
dbgrid1.DataSource.DataSet.Next ;
until dbgrid1.datasource.dataset.Eof ;
end;
if msg.WParamHi< 120 then
begin
repeat
dbgrid1.DataSource.DataSet.Prior ;
until dbgrid1.DataSource.DataSet.Bof ;
end;
end;
type
TDBGridx = class(TDBGrid)
private
{ Private declarations }
protected
{ Protected declarations }
procedure scrolldo(var Msg: Tmessage); message WM_mousewheel;
public
{ Public declarations }
published
{ Published declarations }
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Data Controls', [TDBGridx]);
end;
{ TDBGridx }
procedure TDBGridx.scrolldo(var Msg: Tmessage);
begin
if msg.WParamHi >120 then
begin
if not self.DataSource.DataSet.Eof then
self.DataSource.DataSet.Next ;
end;
if msg.WParamhi<=120then
begin
if not self.DataSource.DataSet.bof then
self.DataSource.DataSet.Prior ;
end;
end;
end.
写完之后,保存,然后再安装这个控件!
方法如下:
component->install component
出现install component对话框,点击unit file name旁边的browse
找到刚才所写的dbgridx.pas这个文件,点击 OK。出现package
dclusr50.dpk,再点compile。
就可以在data controls上找到一个tdbgridx的控件,这个控件
就可以达到滚动的要求!
楼上的兄台,还是不行呀,当进行编辑的时候,第一句就出错了!
unit DBGridx;
他的提示是[Error] DBGrid1.pas(1): Unit identifier 'DBGridx' does not match file name
这是怎么回事呀!我是把原来里面写的全都删掉,把你的完完整的写进去的,就出错呀!
急,希望你能帮我解决掉,谢谢你了!不知道能不能把你的QQ号码告诉我呢!请写上你的QQ
号码吧!可以吗?