Category: StackOverflow

How to refresh data in StringGrid when sorting DB using ADOTable.Sort

I have a TStringGrid in a Firemonkey app for Windows which I have used LiveBindings to connect to a DataSource. The DataSource is linked to an ADOTable. When I use ADOTable.sort the data in the Grid seems to only sort the first row and not the entire table/grid. Does anyone know how to refresh the entire grid, or ensure all the data is sorted. ADOTable.filter refreshes the entire grid, so why doesn't sort work?
Read More

iOS delayed notification only fires if app closed (FMX)

Based on this Embarcadero example I have the following code in a TButton click in FMX app for iOS. Supposed to pop up a notification after 10 seconds. void __fastcall TForm1::ScheduleNotificationButtonClick(TObject *Sender) { if (NotificationCenter1->Supported()) { TNotification *myNotification = NotificationCenter1->CreateNotification(); __try { myNotification->Name = "MyNotification"; myNotification->AlertBody = "C++ for your mobile device is here!"; // Fire in 10 seconds myNotification->FireDate = Now() + EncodeTime(0, 0, 10, 0); // Send notification to the notification center NotificationCenter1->ScheduleNotification(myNotification); } __finally { myNotification->DisposeOf(); } } } When i click the button nothing happens. But, I accidentally figured out that i can make it fire by closing the app AFTER clicking the button. If i click the button and then close the app, sure enough, at 10 seconds the notification pops up. What could possibly be suppressing the notification from firing while the app is running? p.s. This is related to my earlier post but this is unique enough i thought clearer to make separate post.
Read More

GPS file properties (FMX)

I can find basic properties of a file with System.IOUtils.TFile like size, date etc. But, i can't figure how to get the GPS coordinates from a JPEG (latitude and longitude) in my C++ Builder FMX app for WIN32. I can do it with a console application based on this GDI+ example from Microsoft. I just can't figure out how to do this up at System.IOUtils.TFile level. I don't want to run a console app to get the GPS data if don't have to.
Read More

FMX.Graphics.TCanvas.DrawEllipse doesn’t work on Android

I'm making simple drawing application with FireMonkey and Delphi. All it really does is drawing lines and ellipses. This is the code: Image1.Bitmap.Canvas.BeginScene; with Form1 do begin for i := 0 to 360 do if (i mod 15)=0 then begin p1 := TPointF.Create(PX, PY); p2 := TPointF.Create(Round(PX+200*sin(i*pi/180)), Round(PY+200*cos(i*pi/180))); Image1.Bitmap.Canvas.DrawLine(p1, p2, 100); end; for i := 0 to 200 do if (i mod 20)=0 then begin prst1 := TRectF.Create(PX+i,PY+i,PX-i,PY-i); Image1.Bitmap.Canvas.DrawEllipse(prst1, 100); end; Image1.Bitmap.Canvas.EndScene; end; This code works perfectly when I compile it under Win32 or Win64. But when I try to compile it and run on an Android device, only lines show up, and ellipses are just missing. Does anyone have an idea why is that happening? Thank you in advance for your help!
Read More

Installing unit into RAD Studio

I'm pretty new to programming, and I'm learning how to use RAD Studio. I want to use this unit in my project: https://github.com/OneChen/FMXNativeDraw I've downloaded whole folder called "FMXNativeDraw-master". But the only way I know to actually use it in my project is to extract it in the same folder as project files. I'd like to install it permanently into my RAD Studio so I can include it in new projects without copying the files every single time. How do I do that? Thank you in advance for your help!
Read More

Get path and GPS from a gallery picture

How can I select an image from Android gallery and get the path + GPS data (lat & long)? With the code below I don‘t get the path from the original image with GPS data. It returns a path to a cache file without GPS data. “/data/user/0/com.embarcadero.Project1/cache/IMG_20190319_[...].jpg” The original image is in “/DCIM/Camera/” and has another name. How do I get the path from the original image? procedure TForm2.FormCreate(Sender: TObject); begin TMessageManager.DefaultManager.SubscribeToMessage(TMessageReceivedImagePath, DidReceiveBitmap); end; procedure TForm2.TakePhotoFromLibraryAction1DidCancelTaking; begin // end; procedure TForm2.TakePhotoFromLibraryAction1DidFinishTaking(Image: TBitmap); begin Image1.Bitmap := Image; end; procedure TForm2.DidReceiveBitmap(const Sender: TObject; const M: TMessage); var LMessage: TMessageResultNotification; LImagePath: String; begin if M is TMessageReceivedImagePath then begin LMessage := TMessageResultNotification(M); LImagePath := (M as TMessageReceivedImagePath).Value; // <--- '/data/user/0/com.embarcadero.Project1/cache/IMG_20190319_[...].jpg' if LMessage.RequestCode = TJFMXMediaLibrary.JavaClass.ACTION_TAKE_IMAGE_FROM_LIBRARY then begin GetEXIF(LImagePath); Image2.Bitmap.LoadFromFile(LImagePath); end; end; end; procedure TForm2.GetEXIF(const AFileName: String); var LEXIF: JExifInterface; LLatLong: TJavaArray<Single>; begin LEXIF := TJExifInterface.JavaClass.init(StringToJString(AFileName)); Memo1.Lines.Add('File: ' + AFileName); LLatLong := TJavaArray<Single>.Create(2); if LEXIF.getLatLong(LLatLong) then begin Memo1.Lines.Add('Latitude: ' + LLatLong.Items[0].ToString); Memo1.Lines.Add('Longitude: ' + LLatLong.Items[1].ToString); end; LLatLong.Free; end;
Read More

How to correctly keep TAniIndi and a ListView responsive with a thread while Querying a Database on iOS?

The following code is causing my Applicatrion to crash, if I use Synchronize(GetResult); the AniIndi becomes irresponsive. I think that the problem rallies on the way the Thread is being destroyed. Can anyone please help? Type TSearchRxT = class(TThread) public Token: string; Token1, Token2, Token3: String; SearchByPat: Boolean; constructor Create(const Patient: boolean); reintroduce; protected procedure GetResult; procedure Execute; override; end; constructor TSearchRxT.Create(const Patient: boolean); begin inherited Create(True); end; Function TCommonRoutines.SearchRx(Token: String):Boolean; Var TThread; Token1, Token2, Token3: String; begin FrmMain.AniIndi.Visible := True; FrmMain.AniIndi.Enabled := True; FrmMain.OpenOTC := False; CommonRoutine.MultiToken(Token, Token1, Token2, Token3); //defragment string //================================ SearchRxT := TSearchRxT.Create(True); SearchRxT.Token1 := Token1; SearchRxT.Token2 := Token2; SearchRxT.Token3 := Token3; SearchRxT.Token := Token; //Host SearchRxT.OnTerminate := SearchPatThreadTerminated; SearchRxT.Start; end; procedure TSearchRxT.Execute; Var i: Extended; begin while not Terminated do begin TThread.Sleep(200); //Synchronize(GetResult); With ClientModuleSignature do begin //Query Database (select * from myTable); end; end; end; procedure TCommonRoutines.SearchPatThreadTerminated(Sender: TObject); begin SearchRxT := nil; FrmMain.OpenOTC := True; FrmMain.AniIndi.Enabled := False; FrmMain.AniIndi.Visible := False; FrmMain.lvPacientes.Repaint; end; I've added the Thread definition.
Read More

Delphi RAD Studio 10.3.1 App crashes at start-up on Mojave 10.14 and IOS 12.1. SDK 10.1 (10B61)

I have some app running normally also at the above configuration. But since some days this app is crashing on startup with the following message in PAServer: /BuildRoot/Library/Caches/com.apple.xbs/Sources/AppleFSCompression/AppleFSCompression-96.200.3/Common/ChunkCompression.cpp:49: Error: unsupported compressor 8 /BuildRoot/Library/Caches/com.apple.xbs/Sources/AppleFSCompression/AppleFSCompression-96.200.3/Libraries/CompressData/CompressData.c:353: Error: Unknown compression scheme encountered for file '/System/Library/CoreServices/CoreTypes.bundle/Contents/Library/AppExceptions.bundle/Exceptions.plist' The crash seems to happen inside Application.Run and it seems that all unit initialization is done. Is there any idea for some reason and how to overcome it? Thank You.
Read More

Delphi FMX – Change cell background colour without covering text TStringGrid [duplicate]

This question already has an answer here: How to change color of a cell in a Delphi TGrid Firemonkey component? 1 answer Coloring cell background on firemonkey stringgrid according to value from data 2 answers I am creating a diary calendar, I want to be able to change the colour of the cell based on a certain string inside the cell. E.g if TStringGrid.Cells[x,y] = '1' Change the background colour to blue, if TStringGrid.Cells[x,y] = '2' Change the background colour to red, is there a way to do this? And how would I stop the background colour from covering the text in the cell?
Read More