Category: StackOverflow

UnicodeString Delete Method (different result between 32-bit Win and iOS/Android)

I'm building a simple FMX app in C++ Builder (Tokyo 10.2.3) that displays agenda data from an SQLite db. I've added a TComboBox to let the user filter what is presented. The combo box has the following items added to it at runtime (these are committee names): Show PSSC Show TD Show RRMS I'm using the combo box to add a filter to an SQL query on the database. The data set has a field committee and each row of data belongs to one of those 3 committees (PSSC, TD, RRMS). Below is my code to add the filter into a query. It works fine on 32-bit Windows but not on iOS or Android. All I'm doing is trimming off the "Show " with the .Delete to the UnicodeString mystring. mystring = Form1->cmbBoxFilters->Selected->Text; mystring = mystring.Delete(1, 5); query->SQL->Text = "SELECT * FROM mtgs WHERE weekday = '" + myday + "' AND committee = '" + mystring + "'"; Here is what is happening, in 32-bit Windows mystring is exactly as it should be. If i select "Show PSCC" from the combobox, then mystring ends up "PSCC" and the query works great. But, when I run on iOS or Android mystring ends up "SSCC". The first letter of whatever is selected becomes an S. I can't for the life of me figure out why. I'm posting because I'm just curious as to how this "S" is showing up in my original code on iOS or Android and not 32-bit Win. p.s. Just using TFDConnection, TFDQuery, and FDPhysSQLiteDriverLink on my Firemonkey form.
Read More

How to use dspack in a firemonkey project

It is simple to display video using DSPack in Project VCL: procedure TForm1.Button1Click(Sender: TObject); begin if OpenDialog1.Execute then begin if not FilterGraph1.Active then FilterGraph1.Active:= True; FilterGraph1.RenderFile(OpenDialog1.Filename); FilterGraph1.Play; end; end; Print But in firemonkey on the dspack tab there is no TVideoWindow. How to display video in firemonkey using dspack?
Read More

Scan beacons in background on iOS and Android with Delphi

I have an aplication that scans Beacons on run time, but the intention is to look for the beacons in background on iOS and Android. On android application i almost got there by using an Android service to search beacons and show notifications with TNotificationCenter. But the androuid service only starts when i open the application, i think it could be independent, is it possible to do? On iOS Platform its not possible create service like on Android, so i dont know what to do. Best regards
Read More

Firemonkey – Get clicked hyperlinks in TWebBrowser

I have a browser app with TWebBrowser and a TEdit on my form. When I enter URL in TEdit it will display the content on the page. Now if I click some link the page then the app should load the new page and update the TEdit to the new URL (similar to any browser). I tried using TWebBrowser.URL property but it intercepts all the scripting calls as well i.e., for ex. if I open gmail in browser and click signin link, IE is displaying correct link(https://accounts.google.com/signin/v2/identifier?continue=https%3A%2F%2Fmail.google.com%2Fmail%2F&service=mail&sacu=1&rip=1&flowName=GlifWebSignIn&flowEntry=ServiceLogin) but firemonkey app shows some different url. Is there any way to get these URL's in Firemonkey?
Read More

Firemonkey – TPopUp memory issue

I am facing a strange issue. I have set of buttons in a panel and I want to show tooltip for each button. For that I am using TPopUp, but whenever mouse enter, I can observe that memory is increasing for the application. But if I comment the mouse enter and mouse leave events then memory doesn't increase. Did I miss something? Whenever the mouse enters the button, I can see 0.3MB increase in my task manager. TfrmEncode = class(TForm) pnlTop: TPanel; btnSaveToJSON: TButton; procedure FormCreate(Sender: TObject); procedure btnSaveToJSONMouseEnter(Sender: TObject); procedure btnSaveToJSONMouseLeave(Sender: TObject); private { Private declarations } pop : TPopup; cb : TColorBox; labelText: TLabel; public { Public declarations } end; implementation {$R *.fmx} procedure TfrmEncode.btnSaveToJSONMouseEnter(Sender: TObject); begin Pop.IsOpen := True; end; procedure TfrmEncode.btnSaveToJSONMouseLeave(Sender: TObject); begin Pop.IsOpen := False; end; procedure TfrmEncode.FormCreate(Sender: TObject); begin try pop := TPopup.Create(self); pop.Parent:= self; pop.Width:=200; cb := TColorBox.Create(pop); cb.Align := TAlignLayout.Client; cb.Color := TAlphaColors.White; pop.AddObject(cb); labelText := TLabel.Create(pop); labelText.Align :=TAlignLayout.alClient; labelText.Parent := pop; labelText.Text := 'This is the hint This is the hint This is the hint This is the hint This is the hint This is the hint This is the hint This is the hint This is the hint This is the hint'; pop.AddObject(labelText); pop.PlacementTarget := btnSaveToJSON; pop.Placement:=TPlacement.BottomCenter; finally end; end; procedure TfrmEncode.FormDestroy(Sender: TObject); begin FreeAndNil(pop); end;
Read More

Correct movement of a rotating figure with the mouse

The following example, places a Timage in a form; it creates a drawing inside it and then through 2 mouse events (MouseDown and MouseMove) on the image, we move the drawing correctly on screen with the mouse; Now, if we remove the comment { MyImage.RotationAngle := 120;} from the code and activate the rotation of the figure previously plus 90 degrees, the movement is incorrect. I don't see what the problem is. [It is necessary to be able to rotate the figure in screen several times while we can move the result in screen through the mouse.] Video example: https://1drv.ms/v/s!AqdWVn6k-HLbgqRvDhSeWACUsf4okQ unit UMoveShape; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Objects, FMX.StdCtrls, FMX.Controls.Presentation, FireDAC.UI.Intf, FireDAC.FMXUI.Async, FireDAC.Stan.Intf, FMX.DialogService.Async,System.UIConsts,System.Math.Vectors, FireDAC.Comp.UI; type TForm16 = class(TForm) MyImage: TImage; procedure FormCreate(Sender: TObject); procedure MyImageMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Single); procedure MyImageMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Single); private { Private declarations } public Xdiff,Ydiff: single; { Public declarations } end; var Form16: TForm16; implementation {$R *.fmx} procedure TForm16.FormCreate(Sender: TObject); Var MyRect1, MyRect2: TRectF; Path: TPathData; begin MyImage.Width := 500; MyImage.Height := 500; MyImage.Bitmap.SetSize(Round(MyImage.Width), Round(MyImage.Height)); MyRect1 := TRectF.Create(98, 100, 200, 200); MyRect2 := TRectF.Create(70, 90, 225, 210); Path := TPathData.Create; Path.AddEllipse(MyRect1); Path.AddRectangle(MyRect2, 0, 0, AllCorners); MyImage.Bitmap.Canvas.BeginScene; MyImage.Bitmap.Canvas.DrawPath(path, 200); MyImage.Bitmap.Canvas.EndScene; {If we rotate the image more than 90 degrees for example, the movement of the image with the cursor is erratic using the mouseDown and MouseMove routines. On the other way, if we don't rotate the movement is perfect.} // MyImage.RotationAngle := 120; end; procedure TForm16.MyImageMouseDown (Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Single); begin if (ssleft in shift) then begin Xdiff := X; Ydiff := y; end; end; procedure TForm16.MyImageMouseMove (Sender: TObject; Shift: TShiftState; X, Y: Single); begin if (ssleft in shift) then begin MyImage.Position.X := MyImage.Position.X + X - Xdiff; MyImage.Position.y := MyImage.Position.Y + Y - YDiff; end; end; end.
Read More

Debugging Delphi 7 DLL through Delphi 10 Seattle host application

I have written a FireMonkey application in Delphi 10.0 Seattle that dynamically loads a DLL written in Delphi 7. That DLL has a VCL Form. When I run the application, it works fine. When I try to debug the DLL in Delphi 7 (with the Host application pointing to the FireMonkey application), the problem starts. The VCL Form is created and shown, but it keeps changing focus with Delphi 7. When I click on the Form's icon in the Windows Taskbar, it stops changing focus, but the keyboard and mouse actions don't work properly. I can't type in Edit controls, or click on a ComboBox and keep it dropped down. Should I configure something different to debug in this scenario, or this won't work at all? UPDATE The only way I managed to debug was to first start the application without debug, then in Delphi 7, Run > Attach to Process... and select the application, but this does not work all the time, acttually, I have to try a lot of times to get this to work.. most of the times it just won't activate the debug.
Read More

Delphi AddImageToSavedPhotosAlbum IOS App Crash

I have the same problem to develop the iOS application with Delphi XE 10.2. update 3 My application will crash when I click save image (save to camera roll) using IFMXPhotoLibrary. It happened with iPhone 8 iOS 12. I am using: Delphi Tokyo 10.2 update 3, Hotfix: Delphi Tokyo 10.2.3 (HotFix 05.2018), PAServer: Version 10.3.1.10, Xcode: 10.0, Xcode command line tools: 9.4.1 Below is source code: if TPlatformServices.Current.SupportsPlatformService(IFMXPhotoLibrary, Service) then Service.AddImageToSavedPhotosAlbum(imageMain.Bitmap); I have already added a new key, NSPhotoLibraryUsageDescription, to the Version Information section of the project options. The value is be any text that will be displayed when the application requests permission to use the camera roll.
Read More

Delphi mobile menu

I'm trying to make a scrollable menu of text items on mobile (iOS and Android) with Delphi 10.2.3. I've added a TListView and put labels on it. They won't scroll at runtime. I've added a TVertScrollBox and put labels on it. They won't scroll at runtime. Am I missing something about scrolling components?
Read More

Delphi/FMX + iOS: UNUserNotificationCenter don’t raises the delegate events (local notifications)

I'm trying to reproduce the UNUserNotificationCenter (iOS10+) with Delphi/Firemonkey. The app successfully authorizes for receiving notifications and show all local notifications as expected, nowever UNUserNotificationCenter doesn't trigger the delegate events (e.g. when user taps on the notification item). type UNUserNotificationCenterDelegate = interface(IObjectiveC) ['{817A2C54-2F1E-4322-8BDB-2E77F8FAB1AE}'] procedure willPresentNotification(center: UNUserNotificationCenter; notification: UNNotification; completionHandler: TUserNotificationsWithCompletionHandler1); cdecl; procedure didReceiveNotificationResponse(center: UNUserNotificationCenter; response: UNNotificationResponse; completionHandler: TUserNotificationsWithCompletionHandler2); cdecl; end; My delegate object: type TUserNotificationCenterDelegate = class(TOCLocal, UNUserNotificationCenterDelegate) public procedure willPresentNotification(center: UNUserNotificationCenter; notification: UNNotification; completionHandler: TUserNotificationsWithCompletionHandler1); cdecl; procedure didReceiveNotificationResponse(center: UNUserNotificationCenter; response: UNNotificationResponse; completionHandler: TUserNotificationsWithCompletionHandler2); cdecl; end; var NotificationCenterDelegate: TUserNotificationCenterDelegate; implementation [...] function TfrmApplication.AppEventHandler(AAppEvent: TApplicationEvent; AContext: TObject): Boolean; begin Result := true; case AAppEvent of TApplicationEvent.FinishedLaunching: begin UserNotificationCenterDelegate := TUserNotificationCenterDelegate.Create; TUNUserNotificationCenter.OCClass.currentNotificationCenter.setDelegate((UserNotificationCenterDelegate as ILocalObject).GetObjectID); TUNUserNotificationCenter.OCClass.currentNotificationCenter.requestAuthorizationWithOptions(UNAuthorizationOptionAlert + UNAuthorizationOptionSound, nil); end; TApplicationEvent.EnteredBackground: begin DEF_APPLICATION_IN_BACKGROUND := true; end; TApplicationEvent.BecameActive: begin DEF_APPLICATION_IN_BACKGROUND := false; TUNUserNotificationCenter.OCClass.currentNotificationCenter.removeAllDeliveredNotifications; end; else Result := false; end; end; The events below should to be raised every time by when notification presents and the app is in foreground or when user taps the notification, respectively. But nothing happens. procedure TUserNotificationCenterDelegate.willPresentNotification(center: UNUserNotificationCenter; notification: UNNotification; completionHandler: TUserNotificationsWithCompletionHandler1); cdecl; var aImp: procedure(options: NSUInteger); cdecl; aOptions: UNNotificationPresentationOptions; begin WriteLog(AP_LOG_HEADER + 'Will present notification'); //completionHandler @aImp := imp_implementationWithBlock(completionHandler); aOptions := UNNotificationPresentationOptionAlert; aImp(aOptions); imp_removeBlock(@aImp); end; procedure TUserNotificationCenterDelegate.didReceiveNotificationResponse(center: UNUserNotificationCenter; response: UNNotificationResponse; completionHandler: TUserNotificationsWithCompletionHandler2); cdecl; var aImp: procedure(); cdecl; begin WriteLog(AP_LOG_HEADER + 'Receive notification response'); //completionHandler @aImp := imp_implementationWithBlock(completionHandler); aImp(); imp_removeBlock(@aImp); end; What am I doing wrong? Thanks!
Read More