Category: StackOverflow

How to detect when reopen an app sleeping in background on iOS (Firemonkey)?

I want to use TouchID to protect an application. The TouchID function,(implemented in Activate event) work corect if i start (a closed) application. But nothing happened when i reactivate same application from background (is already opened in background). Any ideea on how to detect which event i have to use to capture reactivation of an open application on iOS (firemonkey) ? Any help will be apreciated !
Read More

How do I get a second descendant of TTreeViewItem to show on the TreeView

Using Delphi 10.3 and Fmx, how do I get the second descendant of TTreeviewItem to show its text ? The first descendant works fine. The second one (T3) always shows blank. In this sample the "Parent" and "Text" are assigned correctly to the Item. But in my project the parent will not get assigned, but the text will. unit Unit1; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Layouts, FMX.TreeView; type TForm1 = class(TForm) vue: TTreeView; procedure FormCreate(Sender: TObject); private public end; var Form1: TForm1; type T1 = class (TTreeViewItem) constructor Create (AOwner : TTreeViewItem); reintroduce; virtual; end; T2 = class (TTreeViewItem) constructor Create (AOwner : TTreeViewItem); reintroduce; virtual; end; T3 = class (T1) constructor Create (AOwner : TTreeViewItem); override; end; implementation {$R *.fmx} { T1 } constructor T1.Create(AOwner: TTreeViewItem); begin inherited Create (AOwner); Parent := AOwner; Text := 'T1'; end; { T2 } constructor T2.Create(AOwner: TTreeViewItem); begin inherited Create (Aowner); Parent := AOwner; Text := 'T2'; end; { T3 } constructor T3.Create(AOwner: TTreeViewItem); begin inherited; // Parent := AOwner; Text := 'T3'; end; procedure TForm1.FormCreate(Sender: TObject); var R, I1, I2 : TTreeViewItem; T1a : T1; T2a : T2; T3a : T3; begin R := TTreeViewItem.Create (vue); R.Parent := vue; R.Text := 'Root'; { Doesnt Work } I1 := TTreeViewItem.Create (R); I1.Parent := R; I1.Text := 'First'; { Works } I2 := TTreeViewItem.Create (R); I2.Parent := R; I2.Text := 'Second'; { This works } T1a := T1.Create (I1); { This works } T2a := T2.Create (I1); { This doesnt work } T3a := T3.Create (I1); end; end. Here's the dfm object Form1: TForm1 Left = 0 Top = 0 Caption = 'Form1' ClientHeight = 480 ClientWidth = 640 FormFactor.Width = 320 FormFactor.Height = 480 FormFactor.Devices = [Desktop] OnCreate = FormCreate DesignerMasterStyle = 0 object vue: TTreeView Align = Left Size.Width = 217.000000000000000000 Size.Height = 480.000000000000000000 Size.PlatformDefault = False TabOrder = 0 Viewport.Width = 213.000000000000000000 Viewport.Height = 476.000000000000000000 end end
Read More

Delphi XE7 FMX Android FTP Connection Exception

how can i catch a connection exception on android when connection to FTP. Code At the Moment : idftp1.Host := Servidor_ftp; idftp1.Username:= Usuario_ftp; idftp1.Password:= Contraseña_ftp; Try idftp1.Port := StrToInt(Puerto_ftp); except idftp1.Port := 21; End; Try idftp1.Connect; idftp1.Passive := true; if Carpeta_ftp = '' then IdFTP1.Put( System.IOUtils.TPath.Combine(System.IOUtils.tpath.getdocumentspath,'temp.txt'), Nombre_pistola+'.txt' , False ) else IdFTP1.Put( System.IOUtils.TPath.Combine(System.IOUtils.tpath.getdocumentspath,'temp.txt'), Carpeta_ftp+Nombre_pistola+'.txt', False ); idftp1.Disconnect; except ShowMessage('Hay un error con la conexion al FTP, compruebe si tiene internet y si esta bien configurado todo.'); End; The connection works correctly when all is configured correctly (server, user, pass, port) but it could be configured incorrectly and in that case it would not connect, if i use that code with windows i get an exception after the timeout, but on android it just stays there and i get the message "Wait for app or kill app" Thank you.
Read More

How to set alignment in Fire Monkey multi device application at runtime C++ Builder?

The main problem is FMX dose not support the SomeController->Align = alClient; but that code will work in the VLC application, so after many googling I fine TAlignLayout.Client for my case and the documentation of it is here and here, I try many way to use it but it wont work! I want create Frame in the runtime as you can see in the following code: TSettings *appSettingsFrame; appSettingsFrame = new TSettings(viewSettings); appSettingsFrame->Parent = viewSettings; appSettingsFrame->Align = TAlignLayout.Client; TSettings is Fire Monkey Frame and I use the above code in FormCreate event to create it, at runtime. viewSettings is TMultiView and it's place for appSettingsFrame. If I run application for Android target, the error massage point me to 'TAlinLayout' dose not refer to a value. And if I run application for 32-bit Windows target, the error massage point me to Improper use of typedef 'TAlignLayout'.
Read More

Is there an efficient way to load png-Images into a TImage object in FMX while it’s running?

In order to show many different sized PNG-Images (with transparent background) i Need to load them out of the resources of the program. In VCL, this is easy as you are able to simply use the TPngImage to load and assign them. In Firemonkey this doesn’t exist, so I need another way to do this. Is there a function in FMX in order to do that? Thanks
Read More

FillRect Firemonkey Delphi – For IOS is working OK, for Android resolution is not like in bitmap height and width size?

I have troubles with Fillrect command on Android device. For IOS -there is everything OK. For Android - when resolution of image is 360*100, resolution in Fillrect is only circa 130*50? Does anybody know what kind of bug is this? image1.Bitmap.SetSize(360,100); Hei1:=round(image1.height); wid1:=round(image1.Width); image1.Bitmap.Canvas.BeginScene; barva:=$FF000000+random($FFFFFF); FB := TBrush.Create(TBrushKind.bkSolid,barva); image1.Bitmap.Canvas.FillRect(Rectf(0,0,130,80),0,0,[],1,FB);
Read More

Firemonkey tEdit OnPaint

I have a tEdit and I want to paint it's rect with a different set of Fill and Stroke colors. I coded as follows: procedure TForm1.FormCreate (Sender: TObject); begin Edit1.OnPaint := HandleEditPaint; end; procedure TForm1.HandleEditPaint (Sender: tObject; Canvas: tCanvas; const aRect: tRectF); begin Canvas.BeginScene; Canvas.Fill .Color := TAlphaColorRec.Aqua; Canvas.Fill .Kind := TBrushKind.bkSolid; Canvas.Stroke.Color := TAlphaColorRec.Red; Canvas.Stroke.Kind := TBrushKind.bkSolid; Canvas.FillRect (aRect, 0, 0, AllCorners, 1, TCornerType.Bevel); Canvas.DrawRect (aRect, 0, 0, AllCorners, 1, TCornerType.Bevel); Canvas.EndScene; end; It paints the control's rect properly, but it cannot be focused because when clicking on the Control, it enters in a loop that trigger's HandleEditPaint non stop. How can I avoid this to happen? I know that in painting the control's rect, I must take care of the control's text too, but I should concern about the mouse cursor either? Is there a way to achieve this behavior using styles?
Read More