DBGrid添加鼠标的滚动事件(100)

  • 主题发起人 主题发起人 engineer_me
  • 开始时间 开始时间
E

engineer_me

Unregistered / Unconfirmed
GUEST, unregistred user!
添加鼠标的滚动事件,有很多窗体,每个窗体上有很多个的DBGrid,只有一个窗体会响应滚动事件,我想让打开每个窗体的时候,就能调用这个窗体的滚动事件。
 
Procedure OnMouseWheel(Var Msg :TMsg;var Handled:Boolean); // DBGrid鼠标滚动Application.OnMessage:=OnMouseWheel; // 截获鼠标滚动事件 放在主窗体的Create事件Procedure TFrmMain.OnMouseWheel(Var Msg :TMsg;var Handled:Boolean);var AMsg :TMsg;begin if Msg.message = WM_MouseWheel then begin if (Screen.ActiveForm.ActiveControl is TDBGRID) or (Screen.ActiveForm.ActiveControl is TStringGRID) then begin if Msg.wParam > 0 then begin postmessage(Screen.ActiveForm.ActiveControl.Handle,wm_keydown,vk_up,0); postmessage(Screen.ActiveForm.ActiveControl.Handle,wm_keyup,vk_up,0); end else begin postmessage(Screen.ActiveForm.ActiveControl.Handle,wm_keydown,vk_down,0); postmessage(Screen.ActiveForm.ActiveControl.Handle,wm_keyup,vk_down,0); end; Handled:= True; end else begin AMsg:=Msg; end; end else begin AMsg:=Msg; end;end;
 
后退
顶部