No bo mam taką procedurkę:
var
aForm: TForm1;
Msg: String;
Stophandle: THandle;
begin
aForm := TForm1(UserData);
aForm.CriticalSection.Enter;
try
rich.Text := rich.Text + Output;
if aForm.Abort then
begin
if (aForm.lastStamp = 0) then
begin
if not GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT , Stophandle) then
begin
Msg := sysErrorMessage(Getlasterror);
rich.DefAttributes.Color := clRed;
rich.Lines.Append(Msg);
rich.Lines.Append('Zamykanie...');
rich.DefAttributes.Color := clBlack;
Terminate := true;
end
else
aForm.lastStamp := GetTickCount;
end
else
begin
rich.DefAttributes.Color := clRed;
rich.Lines.Append('Oczekiwanie na zamknięcie procesu...');
rich.Lines.Append('Zamykanie procesu...');
rich.DefAttributes.Color := clBlack;
terminate := (GetTickCount - aForm.lastStamp) > 2000;
end;
end;
finally
aForm.CriticalSection.Leave;
end;
Application.ProcessMessages;
end;
No i w Onclick w buttonie mam:
begin
if not Started then
begin
Abort := false;
Started := true;
lastStamp := 0;
WatchProcessUntillOver(komenda.text, '', '', nil, LoopFunc,!!!!!!!!! Cardinal(self), 0);
Started := false;
end
else
begin
Abort := true;
end;
No i czemu w przykładzie to działa a u mnie juz nie dodam ze wywala błąd:
"incompatible type: 'regular procedure and method pointer'"
i kursor staje w miejscu gdzie dałem tak dużo wykrzykników w kodziku buttonclick.