Deutet für mich darauf hin, dass du die Arbeit, die im MouseMove passiert, in einen Thread auslagern solltest. So passiert die aufwendige Aktualisierung so oft wie es geht, aber ohne die
GUI zu blockieren.
Delphi-Quellcode:
uses
syncobjs;
type
TProcessingThread = class(TThread)
protected
FEvent: TEvent;
FMutex: TCriticalSection;
FSavedX, FSavedY: Integer;
procedure Execute; override;
procedure DoTerminate; override;
procedure DoMouseMove(X, Y: Integer);
procedure UpdateUI;
public
constructor Create;
destructor Destroy; override;
procedure MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
end;
implementation
procedure TProcessingThread.Execute;
var
X, Y: Integer;
begin
while FEvent.WaitFor() and not Terminated do
begin
FMutex.Acquire;
X := FSavedX;
Y := FSavedY;
FMutex.Release;
DoMouseMove(X, Y);
end;
end;
procedure TProcessingThread.DoTerminate;
begin
inherited DoTerminate;
FEvent.Set;
end;
procedure TProcessingThread.DoMouseMove(X, Y: Integer);
begin
{ ... actual work ... }
Synchronize(UpdateUI);
end;
procedure TProcessingThread.UpdateUI;
begin
{ ... }
end;
constructor TProcessingThread.Create;
begin
inherited Create(False);
FEvent := TEvent.Create(nil, False, False, '');
FMutex := TCriticalSection.Create;
end;
destructor TProcessingThread.Destroy;
begin
FEvent.Free;
FMutex.Free;
end;
procedure TProcessingThread.MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
FMutex.Acquire;
FSavedX := X;
FSavedY := Y;
FMutex.Release;
FEvent.Set;
end;
Delphi-Quellcode:
procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
FProcessingThread.MouseMove(Sender, Shift, X, Y);
end;
Code ist ungetestet, nur eben im Beitragseditor hier geschrieben.