怎样才能拖动窗体的时候主线程内正在运行的程序不停止响应.
假如有这样一段代码:
procedure TForm1.Button1Click(Sender: TObject);var i: integer ;begin i := 0 ; while True do begin i := i + 1 ; Text := IntToStr(i) ; Application.ProcessMessages ; end;end;
procedure TForm1.Timer1Timer(Sender: TObject);begin Tag := Tag + 1; Text := IntToStr(Tag);end;
[解决办法]
用拦截消息的方法是不行的,因为在窗口拖动的过程中是返回不到Application.ProcessMessages的。
可以在mousedown的时候setcapture然后在mousemove消息里模拟窗口拖动。