Smart-Mobile-Studio – Where to perform the final processing before the application is closed?

When the form is closed or the application terminates and is unsuccessful, I have been trying to write data to the storage.

I first tried from the Form unit< /p>

procedure TForm1.FinalizeObject;
begin
inherited;
SaveData;
end;

and< /p>

procedure TForm1.FinalizeObject;
begin
SaveData;
inherited;
end;

These attempts None of them worked, so I adjusted my code and tried it from the project unit

procedure TApplication.ApplicationClosing;
begin
SaveData;
inherited;
end;

and

procedure TApplication.ApplicationClosing;
begin
inherited;
SaveData;
end;

I have a w3_showmessage as the first line of SaveData, it will never be called… So, if I can verify these 4 methods One of them is triggered, I can use one of them

What am I doing wrong? Thank you

At the time of writing, Smart will expose two new events in the application object:

> OnUnload
> OnBeforeUnload

These will make it easier to handle the close sequence. The smart javascript bootloader now also automatically calls application.terminate(), so your The code should work fine.

I have been trying to write data to storage when the form is closed or the application is terminated and unsuccessful.

I first try to start from the Form unit

procedure TForm1.FinalizeObject;
begin
inherited;
SaveData;
end ;

and

procedure TForm1.FinalizeObject;
begin
SaveData;
inherited;
end ;

None of these attempts worked, so I adjusted my code and tried it from the project unit

procedure TApplication.ApplicationClosing ;
begin
SaveData;
inherited;
end;

and

procedure TApplication.ApplicationClosing ;
begin
inherited;
SaveData;
end;

I have a w3_showmessage as the first line of SaveData, it will never be called… So, if I can verify that one of these 4 methods is triggered, I can use one of them

What am I doing wrong? Thank you

When writing, Smart will expose two new events in the application object:

> OnUnload
> OnBeforeUnload

These will make it easier to handle the closing sequence. The smart javascript bootloader now also automatically calls application.terminate(), so your code should work properly.

Leave a Comment

Your email address will not be published.