//首先在窗体定义加一个过程<br>public<br> procedure myMessage(var Msg: tagMSG;var Handled: Boolean);<br><br>.....<br>//消息处理函数<br>procedure TForm1.myMessage(var Msg: tagMSG;var Handled: Boolean);<br>begin<br> if (Msg.message<=WM_MOUSEFIRST) and (msg.message<=WM_MOUSELAST) or //鼠标<br> (Msg.message<=WM_KEYFIRST) and (msg.message<=WM_KEYLAST) then //键盘<br> begin //重新开始<br> Form1.Timer1.Enabled:=false;<br> Form1.Timer1.Enabled:=true;<br> end;<br> handled:=false; //表示没有处理过,否则程序将不在处理,会出错的<br>end;<br>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br> Application.OnMessage:=myMessage; //连接消息处理函数<br>end;<br>//上面代码在我机子上测试通过