Here, take out
Case Sender Of
Ok : frmDesign.ModalResult:= mrOk;
Cancel : if (not(frmDesign.ModalResult = 1)) then
TerminateScript;
end;
in StartClick so that it's only Times1:= StrToInt(STamount2.text);
Then, in InitForm take out
Ok.ONCLICK := @StartClick;
Ok.ModalResult := 1;
Cancel.ONCLICK := @CancelSelected;
Cancel.ModalResult := 2;
and add back in
Ok.ModalResult := mrOk;
Cancel.ModalResult := mrCancel;
(They might be the same numbers, but the constants actually show what they mean then :))
Then redo the showing of the form modal:
function ShowFormModal: boolean;
begin
result := (frmDesign.ShowModal = mrOk);
end;
function SafeShowFormModal:boolean;
var
v: TVariantArray;
begin
setarraylength(V, 0);
Result := ThreadSafeCall('ShowFormModal', v);
end;
so that in the mainloop, you can end up with
if (not SafeShowFormModal) then
TerminateScript;
It all accomplishes the same thing in the end, but it's easier to follow.
I also have a piece of code I made awhile back that would let you move the form
procedure MoveForm(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
ox, oy, mx, my: integer;
begin
GetMousePos(ox, oy);
repeat
sleep(50);
GetMousePos(mx, my);
frmDesign.Left := frmDesign.Left + mx - ox;
frmDesign.Top := frmDesign.Top + my - oy;
ox := mx;
oy := my;
until not IsMouseButtonDown(True);
end;
frmDesign.onMouseDown := @MoveForm;
but then it paints over SCAR as if lagging really badly (because SCAR is frozen while a form is open), so you should add GetSelf.WindowState := wsMinimized; at the beginning of the mainloop and wsNormal; afterwards.
Hope it helps :)