如果不是服务类程序就可以, 首先执行这句 ,把程序的所有消息交给这个过程处理。 Application.OnMessage:=ApplicationMessage; //将程序的所有消息将给过程ApplicationMessage处理!定义过程 procedure ApplicationMessage(var Msg: TMsg; var Handled: Boolean); begin if (Msg.message = WM_MOUSEWHEEL) and (Msg.hwnd = DBGrid1.Handle) then//当接收到消息WM_MOUSEWHEEL,并且由DBGrid1激发时 begin //处理程序 end else inherited; end;如果是服务程序的话,需要用到远程消息。
//////屏蔽窗口的wm_Size消息,在Application的OnMessage事件中写屏蔽代码,示例: procedure TForm1.FormCreate(Sender: TObject); begin Application.OnMessage := AppMessage; end; procedure TForm1.AppMessage(var Msg: TMsg; var Handled: Boolean); begin if Msg.message = WM_Size then begin Msg:=0 Handled := True; end; end;
首先执行这句 ,把程序的所有消息交给这个过程处理。
Application.OnMessage:=ApplicationMessage;
//将程序的所有消息将给过程ApplicationMessage处理!定义过程
procedure ApplicationMessage(var Msg: TMsg; var Handled: Boolean);
begin
if (Msg.message = WM_MOUSEWHEEL) and (Msg.hwnd = DBGrid1.Handle) then//当接收到消息WM_MOUSEWHEEL,并且由DBGrid1激发时
begin
//处理程序
end
else
inherited;
end;如果是服务程序的话,需要用到远程消息。
procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnMessage := AppMessage;
end;
procedure TForm1.AppMessage(var Msg: TMsg; var Handled: Boolean);
begin
if Msg.message = WM_Size then
begin
Msg:=0
Handled := True;
end;
end;