I put together a demo of a Working Dialog form for Delphi XE5 Firemonkey mobile projects. I mainly built it for IOS to look like UIActivityIndicatorView but I’ve modified it so that it also works on Android. Basically it has a form called TWorkingForm that you can display any time you want to do an operation that may freeze up the app. The dialog is designed to look like the native IOS working dialog. The Transparency property is set to True and the BorderStyle is set to bsNone on the TWorkingForm. On IOS this allows you to have a transparent form that floats over your main form. The main reason why you would want to use a form like this instead of just having a TLayout on your main form is because of TWebBrowser or any other native control. TWebBrowser wraps around UIWebView which hovers over your form and above any TLayout as far as I can tell. This also applies to any of the native controls from TMS iCL. When you use the TWorkingForm dialog it will be above the TWebBrowser. For Android I couldn’t get the transparent form working so instead it takes a screenshot using MakeScreenShot and uses that as the background of TWorkingForm. You could take the WorkingPanel which is a TRectangle from the TWorkingForm and just add it to your own project if you don’t use any native controls that it has to float over. Here is the function that you can use to call TWorkingForm:
procedure TTabbedwithNavigationForm.WorkingMsg(Text: String; Working: Boolean);
begin
if Working=True then
begin
Application.ProcessMessages;
{$IFDEF ANDROID}
WorkingForm.bgImage.Bitmap.Assign(TabControl1.MakeScreenshot);
{$ENDIF}
WorkingForm.Show;
WorkingForm.AniIndicator.Enabled := True;
WorkingForm.WorkingLBL.Text := Text;
end
else
begin
WorkingForm.AniIndicator.Enabled := False;
WorkingForm.WorkingLBL.Text := Text;
WorkingForm.Close;
{$IFDEF ANDROID}
WorkingForm.bgImage.Bitmap.Assign(nil);
{$ENDIF}
TabbedwithNavigationForm.Show;
end;
end;
In the demo the example work is a TRESTClient that uses ExecuteAsync. When ExecuteAsync comes back in the OnAfterExecute event you hide the TWorkingForm. I did not use an extra thread to make this TWorkingForm happen (check out our other post for a multithreaded working dialog). You could combine this working form with the multithreaded working form to get the best of both.
2 Comments