procedure FormShow(Sender: TObject);
private
{ Private declarations }
procedure AnyMessage(var Msg: TMsg; var Handled: Boolean);
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormShow(Sender: TObject);
begin
Application.OnMessage:= AnyMessage;
end;
procedure TForm1.AnyMessage(var Msg: TMsg; var Handled: Boolean);
begin
if Msg.Message = WM_MouseWheel then
if ActiveControl is TDBgrid then
begin
if Msg.wParam > 0 then
begin
keybd_event(VK_UP, VK_UP, 0, 0);
keybd_event(VK_UP, VK_UP, KEYEVENTF_KEYUP, 0);
end
else if Msg.wParam < 0 then
begin
keybd_event(VK_DOWN, VK_DOWN, 0, 0);
keybd_event(VK_DOWN, VK_DOWN, KEYEVENTF_KEYUP, 0);
end;
ActiveControl.Invalidate;
end;
end;
type
TForm1 = class(TForm)
procedure FormShow(Sender: TObject);
private
{ Private declarations }
procedure AnyMessage(var Msg: TMsg; var Handled: Boolean);
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormShow(Sender: TObject);
begin
Application.OnMessage:= AnyMessage;
end;
procedure TForm1.AnyMessage(var Msg: TMsg; var Handled: Boolean);
begin
if Msg.Message = WM_MouseWheel then
if ActiveControl is TDBgrid then
begin
if Msg.wParam > 0 then
begin
keybd_event(VK_UP, VK_UP, 0, 0);
keybd_event(VK_UP, VK_UP, KEYEVENTF_KEYUP, 0);
end
else if Msg.wParam < 0 then
begin
keybd_event(VK_DOWN, VK_DOWN, 0, 0);
keybd_event(VK_DOWN, VK_DOWN, KEYEVENTF_KEYUP, 0);
end;
ActiveControl.Invalidate;
end;
end;
DBGrid 휠마우스 먹히게 하는 소스입니다.
참고하세요 ^^