Category: StackOverflow

Push notification with Firemonkey [closed]

Everything I can read, as well as the official documentation look outdated or a mess. I manage my user with Firebase and use a Firestore database. When a user do an action (ex: sent message) in the app, I would like to send a push notification to a user (ex: new message available). I see two API : Apple Push Notification for iOS Google Cloud Messaging for Android Then, I see Firebase Cloud Messaging that can work with both even if it look more complicated to add in iOS. What do you recommanded to use ? May be a composant that don't care about platform ? I care a little when I see with new SDK : RAD Studio cannot guarantee that the interfaces remain compatible
Read More

In Firemonkey: Get a style object from another component

I'm creating a custom component and in that component i want to use certain colors from certain objects in the TGrid. I want to use style colors as much as I can so that my application will have consistent style coloring. I need for example the linefill object from the TGrid. Basically: how do I find that linefill object from like a plain button click?
Read More

How do I detect the tone of a region of a TImage in Delphi

I am adding overlays to user-submitted images and that means the images might be dark in tone or light in tone. Is there some kind of mechanism by which I can determine whether a particular region of a Timage is tonally light or dark? This will allow me to show the white or black version of my overlay depending. I am using Delphi 10.4 for MacOS so I am working with FMX. The overlay is a small piece of text and an image (in black or white). This will be overlaying a TImage found in my stylebook definition for a TListboxItem.
Read More

FMX: Modal forms not staying on top (Windows)

There are several cases where forms or dialogs that should be modal are not staying on top. I'm building for Windows using 10.4. Here's a simple example involving two forms and a TSaveDialog. To replicate the issue: Run the application in Windows Click the Show Window button (you should see Form2) Click the Show Save Dialog button (you should see the save dialog) Click another window that is not part of the application such as an Explorer window Click Form2. Form1 will now be in front If you repeat this but maximise Form1 first then it's not easy for the user to resolve without closing the program from Task Manager or using some expert windows knowledge. Form1: object Form1: TForm1 Left = 0 Top = 0 Caption = 'Form1' ClientHeight = 480 ClientWidth = 640 Position = ScreenCenter FormFactor.Width = 320 FormFactor.Height = 480 FormFactor.Devices = [Desktop] DesignerMasterStyle = 0 object Button1: TButton Position.X = 264.000000000000000000 Position.Y = 168.000000000000000000 Size.Width = 97.000000000000000000 Size.Height = 33.000000000000000000 Size.PlatformDefault = False Text = 'Show Window' OnClick = Button1Click end end Form2: object Form2: TForm2 Left = 0 Top = 0 Caption = 'Form2' ClientHeight = 333 ClientWidth = 489 Position = ScreenCenter FormFactor.Width = 320 FormFactor.Height = 480 FormFactor.Devices = [Desktop] DesignerMasterStyle = 0 object Button1: TButton Position.X = 184.000000000000000000 Position.Y = 136.000000000000000000 Size.Width = 113.000000000000000000 Size.Height = 41.000000000000000000 Size.PlatformDefault = False Text = 'Show Save Dialog' OnClick = Button1Click end object SaveDialog1: TSaveDialog Left = 80 Top = 40 end end Unit1: unit Unit1; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, Unit2, FMX.Controls.Presentation, FMX.StdCtrls; type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.fmx} procedure TForm1.Button1Click(Sender: TObject); begin Form2.Show; end; end. Unit2: unit Unit2; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Controls.Presentation, FMX.StdCtrls; type TForm2 = class(TForm) Button1: TButton; SaveDialog1: TSaveDialog; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form2: TForm2; implementation {$R *.fmx} procedure TForm2.Button1Click(Sender: TObject); begin SaveDialog1.Execute; end; end. I have not seen this behaviour in VCL applications (modal windows always stay on top). I have also seen the issue in FMX applications with forms that have been shown using ShowModal and even message windows created with ShowMessage. Using TDialogServiceSync.ShowMessage seems to help prevent this but even then some users experience the same issue. Why is this happening and is there anything I can do to fix it?
Read More

unchecking remove splash screen causes an error

In building an Android app I wanted to remove the use of the splash screen. When I "uncheck" the include splash screen checkbox (Project Options - Icons). The application no longer deploys properly when I select "run". If I turn the checkbox back on and select run, the application deploys correctly and executes on the phone. I am running the latest version (11 with the November patch). Thank you for any help
Read More

Delphi Cross Platform Socket Issue

First of all I am trying to make a Client/Server: Server is an app in a PC (VCL). Client is an android App. When the server is online, once i open the client its connects normally, When the server is offline, I need to auto re-connect to the server but in this case the client is stuck at this procedure and doesn't get out of it: FClientSocket.Connect(string.Empty, '192.168.1.155'+#0, string.Empty, 4851); trying to free the socket gives an error.. trying to free the thread doesn't get freed.. i did everything but nothing worked .. My code so far (stripped): uses ..System.Net.Socket.. .. var Form1: TForm1; FClientSocket: TSocket; FThread, RThread: TThread; Connected : Boolean = False; Procedure Connect; begin FClientSocket := TSocket.Create(TSocketType.TCP); FClientSocket.Connect(string.Empty, '192.168.1.155'+#0, string.Empty, 4851); Connected := True; end; Procedure Disconnect(); Begin Connected := False; if FClientSocket <> nil then FClientSocket.Free; end; Procedure TForm1.SocketConnect; begin Connected := False; //Connect to VCL server RThread := TThread.CreateAnonymousThread(procedure begin Connect; end); RThread.FreeOnTerminate := True; RThread.Start; Sleep(500); While Connected do begin // Receive the message from the VCL server // .. end; end; procedure TForm1.FormCreate(Sender: TObject); begin FThread := TThread.CreateAnonymousThread(procedure begin SocketConnect; end); FThread.FreeOnTerminate := True; FThread.Start; end; procedure TForm1.FormDestroy(Sender: TObject); begin if FClientSocket <> nil then Begin FClientSocket.Free; end; if FThread <> nil then Begin FThread.OnTerminate := nil; FThread.FreeOnTerminate := False; FThread.Terminate; FThread.WaitFor; FreeAndnil(FThread); end; end;
Read More

Rounded Button Corners in Firemonkey

I'm developing an application in Firemonkey for Windows and OSX. With the new Windows 11, I can see, by default in my application, that the form corners are rounded. I've found code to call a Windows API for rounding corners but it requires passing an HWND parameter. Since I don't believe Firemonkey supports Windows handles, how do I go about rounding the corners on button and other controls to match the new Windows 11 look when the application is being built for Windows? (I'm using the Alexandria build of Delphi and I know enough to wrap the code with compile directives for Windows vs OSX.)
Read More

What’s the proper way to modify an existing FMX control?

I need to modify the behavior of the built-in FMX TMemo control. I never done this before and want to know what's the proper way to do it. Under C:\Program Files (x86)\Embarcadero\Studio\21.0\source\fmx I found there are several related files: C:\Program Files (x86)\Embarcadero\Studio\21.0\source\fmx\FMX.Memo.iOS.pas C:\Program Files (x86)\Embarcadero\Studio\21.0\source\fmx\FMX.Memo.Android.pas C:\Program Files (x86)\Embarcadero\Studio\21.0\source\fmx\FMX.Memo.Win.pas C:\Program Files (x86)\Embarcadero\Studio\21.0\source\fmx\FMX.Memo.Types.pas C:\Program Files (x86)\Embarcadero\Studio\21.0\source\fmx\FMX.Memo.Style.pas C:\Program Files (x86)\Embarcadero\Studio\21.0\source\fmx\FMX.Memo.Style.New.pas C:\Program Files (x86)\Embarcadero\Studio\21.0\source\fmx\FMX.Memo.pas Should I copy them to the root of my current project folder and start editing them? Should I rename TMemo in these files to some other name, or can I just use TMemo? What else should I do to let my application code recognize them instead of the built-in TMemo? Btw, I'm using Delphi 10.4.2 on Windows.
Read More

Firemonkey ignores the Font.Size indicated when creating labels at runtime

I'm trying Firemonkey for the first time, and I'm finding problems creating labels at runtime. I'm drawing rectangles at runtime with description labels inside, but those labels are always drawn at the default font, ignoring the font size I set on its properties. You can see the problem on Windows itself creating a new Blank multidevice project, and putting this code at OnCreate : procedure TForm2.FormCreate(Sender: TObject); var Shape: TRectangle; Etiqueta: TLabel; begin Shape := TRectangle.Create(Self); Shape.Align := Shape.Align.alClient; Shape.Parent := Self; Etiqueta := TLabel.Create(Shape); Etiqueta.Position.X := 20; Etiqueta.Position.Y := 50; Etiqueta.Width := 200; Etiqueta.TextSettings.Font.Size := 10; Etiqueta.Text := 'Small Font'; Etiqueta.Parent := Shape; Etiqueta := TLabel.Create(Shape); Etiqueta.Position.X := 20; Etiqueta.Position.Y := 100; Etiqueta.Width := 200; Etiqueta.TextSettings.Font.Size := 20; Etiqueta.Text := 'Large Font'; Etiqueta.Parent := Shape; end; One label should have a font larger than the order, but both texts are drawn using the same size. What could be the problem ?. If I put two labels at design time, with those same properties, they are shown with the correct font size.
Read More

IOS deployment error [PAClient Error] E0776 when packaging ipa file. What is wrong? Whero log?

The project is empty and contains one button! I try do .ipa file for App Store. And i got this errror: paclient command line for "MacBookPro" c:\program files (x86)\embarcadero\studio\21.0\bin\paclient.exe -u8 -- ipa="XX.XXClient.app,XX.XXClient.ipa,'iPhone Distribution: XXXXX XX (G123456789)','/Users/adminz/Library/MobileDevice/Provisioning Profiles/70000afa-6a83- 4d6a-903b-4af38795909d.mobileprovision',2" MacBookPro [PAClient Error] Error: E0776 2021-11-04 17:01:08.529 xcodebuild[1262:43522] [MT] IDEDistribution: -[IDEDistributionLogging _createLoggingBundleAtPath:]: Created bundle at path '/var/folders/hj/f9ghw_0517zbkpp54l0fzk6w0000gn/T/XX.XXClient_2021-11-04_17-01- 08.529.xcdistributionlogs'. [PAClient Error] Error: E0776 Exported XX.XXClient to: /Users/adminz/PAServer/scratch-dir/master-MacBookPro/XX.XXClient.archive/temp [PAClient Error] Error: E0776 ** EXPORT SUCCEEDED ** Failed I can't figure out where the error is. Where can I find the .xcdistributionlogs file? No exist folder: /Users/adminz/PAServer/scratch-dir/master-MacBookPro/XX.XXClient.archive If I do the same with Xcode, I got a .ipa file.
Read More