Category: StackOverflow

Delphi Firemonkey virtual keyboard is blocking the edit box (Mobile)

Delphi Firemonkey Fullscreen Edit I develop mobile app and has several edit box in it. My problem is when i type to the edit box. the Virtual keyboard blocks the box that i cannot see what i am typing in. Is there any edit properties to change to make it full-screen editing? like Only edit box and virtual keyboard can be seen. or any suggestion.
Read More

Delphi FMX: How to create a string grid cell with multiple columns

I have a string grid, but I want to create cells that would be split into 3 "mini" columns within the cell, how would I do this, if it is possible, using FMX delphi? So essentially in the grid each cell would have 3 columns (1 row), and in each of those columns is a cell. This string grid would be to represent a calendar/diary planner etc, each of the main cells would be a day in the month, and the mini cells would represent an early/late/night time frame in the day. What I would like to have is the ability to access TStringGrid.Cells[x,y] and then set the columns within that Cell to a certain letter/number. So the cell would be shown as e.g 24 E L N, the 24 if possible could be a header to the main cell.
Read More

Resize images in TImageList with antialias

I download images, resize them and insert them with the follwing code found on StackOverFlow: Navigator.Get(Image, MImage); MImage.Position := 0; si := HeaderFooterWithNavigation.ArticlesImages.Source.Add; si.Name := 'Source' + IntToStr(A); si.MultiResBitmap.LoadItemFromStream(MImage, 1); d:=HeaderFooterWithNavigation.ArticlesImages.Destination.Add; Layer := d.Layers.Add; Layer.SourceRect.Rect := TRectF.Create(0, 0, si.MultiResBitmap.Bitmaps[1].Width, si.MultiResBitmap.Bitmaps[1].Height); Layer.Name := si.name; While this works, the images in my ListView end up being pixelated. How can they appear with antialias? I use Delphi 10.2 Rio and work with FMX.
Read More

Firemonkey iOS CFBundleExecutable error deploying application

For the last 48 hours I'm trying to deploy my application to my iPhone. I'm getting an error unable to extract application bundle executable info. Please check Info.plist CFBundleExecutable key Did anybody face the same problem? I haven’t changed the provisioning profiles or any versioninformations, the error occurred out of nowhere. My Workspace set up: Delphi Rio 10.3.1 macOS HighSierra iOS 12.1 latest XCode build Things I'v ealready tried: changing CFBundleidentifier to blank or "????", right now it is com.jilsApp.* in the version information rename the Project deploying another project to the iPhone successfull and reading the info.plist file changing the info.plist of my project by hand replacing "$ModuleName" with projectname within the version information rebooting mac and iPhone restart PAServer20.0 and finally asking Dr. Google
Read More

How to load a file into a stream on Android knowing its Jnet_Uri?

I'm writing an Android FMX app in Delphi 10.3 Rio. There I'm selecting photos from the gallery (via TJIntent.JavaClass.ACTION_OPEN_DOCUMENT) and getting back Jnet_Uri entries. I can use those to read image EXIF (with TJExifInterface). Now I also need to load these images into a stream for further processing. How do I do this? When I try to convert Jnet_Uri to a path with uri.getPath, it comes out like /document/image:26591. uri.toString gives me content://com.android.providers.media.documents/document/image%3A26674. TMemoryStream.LoadFromFile fails to load from both of these paths: Cannot open file "/document/image:26724". No such file or directory Cannot open file "/content:/com.android.providers.media.documents/document/image%3A26724". Not a directory Hence the question, how knowing a Jnet_Uri do I load files contents into a stream?
Read More

Problem on PhoneStateListener to listen to OnCellInfoChanged in delphi firemonkey

It will be appreciated if help me. i am writing a program with delphi firemonkey that show mobile cell informations. i need to listen on cell info changes with JPhoneStateListener class. At First i write a class for implement main class as below : type TPL = class(TJavaGenericImport<JPhoneStateListenerClass, JPhoneStateListener>) public constructor create; Destructor Destroy; Override; procedure onCallForwardingIndicatorChanged(cfi: Boolean); cdecl; procedure onCallStateChanged(state: Integer; incomingNumber: JString); cdecl; ......... (and other procedures of main class) end; Implementation Constructor TPL.Create; Begin End; Destructor TPL.Destroy; Begin Inherited Destroy; End; procedure TPL.onCallForwardingIndicatorChanged(cfi: Boolean); Begin End; ......... and in main code : procedure TForm1.Button1Click(Sender: TObject); var obj: JObject; TelephonyManager: JTelephonyManager; Tj:TPL; begin obj := TAndroidHelper.Context.getSystemService(TJContext.JavaClass.TELEPHONY_SERVICE); if (obj<>nil) then begin TelephonyManager := TJTelephonyManager.Wrap((obj as ILocalObject).GetObjectID); if (TelephonyManager<>nil) then begin Tj := TPL.create; TelephonyManager.listen(Tj, TJPhoneStateListener.JavaClass.LISTEN_CELL_INFO or TJPhoneStateListener.JavaClass.LISTEN_CELL_LOCATION); <------ Error is here end; end; end; at compile i face with this error: [DCC Error] main.pas(61): E2010 Incompatible types: 'JPhoneStateListener' and 'TPL' thanks to @nolaspeaker i edit my code as below : unit main; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls, FMX.Controls.Presentation, FMX.ScrollBox, FMX.Memo, FMX.ExtCtrls, FMX.Helpers.Android, RTL.Controls, Androidapi.JNI.Os, Androidapi.Helpers, Androidapi.JNI.Telephony, Androidapi.JNI.GraphicsContentViewText, Androidapi.JNI.JavaTypes, Androidapi.JNIBridge, Androidapi.JNI.App; type TPhoneStateListener = class; TForm1 = class(TForm) Button1: TButton; RTLFixer1: TRTLFixer; Memo1: TMemo; Timer1: TTimer; Button2: TButton; procedure Button1Click(Sender: TObject); procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); procedure Timer1Timer(Sender: TObject); procedure Button2Click(Sender: TObject); procedure InitPSListener(Start: Boolean); private PhoneStateListener: TPhoneStateListener; FSignal: Integer; { Private declarations } public { Public declarations } end; //type TPhoneStateListener = class(TJavaLocal, JICustomPhoneStateListener) private [weak] FParent : TForm1; public constructor Create(AParent : TForm1); procedure onCallForwardingIndicatorChanged(cfi: Boolean); cdecl; procedure onCallStateChanged(state: Integer; incomingNumber: JString); cdecl; procedure onCellInfoChanged(cellInfo: JList); cdecl; procedure onCellLocationChanged(location: JCellLocation); cdecl; procedure onDataActivity(direction: Integer); cdecl; procedure onDataConnectionStateChanged(state: Integer); overload; cdecl; procedure onDataConnectionStateChanged(state: Integer; networkType: Integer); overload; cdecl; procedure onMessageWaitingIndicatorChanged(mwi: Boolean); cdecl; procedure onServiceStateChanged(serviceState: JServiceState); cdecl; procedure onSignalStrengthChanged(asu: Integer); cdecl; procedure onSignalStrengthsChanged(signalStrength: JSignalStrength); cdecl; end; var Form1: TForm1; implementation {$R *.fmx} {$R *.NmXhdpiPh.fmx ANDROID} {$R *.LgXhdpiPh.fmx ANDROID} procedure TForm1.Button1Click(Sender: TObject); begin InitPSListener(True); end; procedure TForm1.Button2Click(Sender: TObject); begin InitPSListener(False); end; procedure TForm1.InitPSListener(Start: Boolean); var obj: JObject; begin if PhoneStateListener = nil then PhoneStateListener := TPhoneStateListener.Create(Self); obj := TAndroidHelper.Context.getSystemService(TJContext.JavaClass.TELEPHONY_SERVICE); if obj <> nil then begin CallinUIThread(procedure var TelephonyManager: JTelephonyManager; PSL: JCustomPhoneStateListener; begin TelephonyManager := TJTelephonyManager.Wrap(obj); PSL := TJCustomPhoneStateListener.JavaClass.init(PhoneStateListener); if Start then TelephonyManager.listen(PSL, TJPhoneStateListener.JavaClass.LISTEN_SIGNAL_STRENGTHS) // or TJPhoneStateListener.JavaClass.LISTEN_SIGNAL_STRENGTH // or TJPhoneStateListener.JavaClass.LISTEN_DATA_ACTIVITY else TelephonyManager.listen(PSL, TJPhoneStateListener.JavaClass.LISTEN_NONE) end ); end; end; { TPhoneStateListener } constructor TPhoneStateListener.Create(AParent: TForm1); begin inherited Create; FParent := AParent; end; procedure TPhoneStateListener.onCallForwardingIndicatorChanged(cfi: Boolean); begin end; procedure TPhoneStateListener.onCallStateChanged(state: Integer; incomingNumber: JString); begin end; procedure TPhoneStateListener.onCellInfoChanged(cellInfo: JList); begin end; procedure TPhoneStateListener.onCellLocationChanged(location: JCellLocation); begin end; procedure TPhoneStateListener.onDataActivity(direction: Integer); begin end; procedure TPhoneStateListener.onDataConnectionStateChanged(state: Integer); begin end; procedure TPhoneStateListener.onDataConnectionStateChanged(state, networkType: Integer); begin end; procedure TPhoneStateListener.onMessageWaitingIndicatorChanged(mwi: Boolean); begin end; procedure TPhoneStateListener.onServiceStateChanged( serviceState: JServiceState); begin end; procedure TPhoneStateListener.onSignalStrengthChanged(asu: Integer); begin end; procedure TPhoneStateListener.onSignalStrengthsChanged( signalStrength: JSignalStrength); begin FParent.onSignalStrengthsChanged(signalStrength); <---- error is here end; procedure TForm1.OnSignalStrengthsChanged(signalStrength: JSignalStrength); begin FSignal := signalStrength.getLevel; // 0 - 4 <----- and is here end; end. but still ai have error : [DCC Error] main.pas(249): E2003 Undeclared identifier: 'onSignalStrengthsChanged'
Read More

Getting blank screenshots in WebBrowser under Mac

Below is the piece of code on Firemonkey to capture WebBrowser canvas. It perfectly works in Windows, however in Mac OS I'm getting a blank screenshot. TBitmap* TForm1::getScreenshotWebBrowser() { TBitmap *BitmapBuffer; TBitmap *bmp_Scrhot = new TBitmap; TRectF SourceRect(0, 0, WebBrowser1->Width, WebBrowser1->Height); TRect Rect_bmp(0, 0, WebBrowser1->Width, WebBrowser1->Height); BitmapBuffer = new TBitmap(SourceRect.Width(), SourceRect.Height()); try { if (BitmapBuffer->Canvas->BeginScene()) try { WebBrowser1->PaintTo(BitmapBuffer->Canvas, SourceRect); } __finally { BitmapBuffer->Canvas->EndScene(); } BitmapBuffer->SaveToFile(GetHomePath() +"/screenshot1.png"); bmp_Scrhot->Width = Rect_bmp.Width(); bmp_Scrhot->Height = Rect_bmp.Height(); bmp_Scrhot->CopyFromBitmap(BitmapBuffer, Rect_bmp, 0, 0); bmp_Scrhot->SaveToFile(GetHomePath() +"/screenshot2.png"); } __finally { delete BitmapBuffer; } return bmp_Scrhot; P.S. Experimenting I found out that If I capture the whole form containing WebBrowser canvas, then the screenshot is not entirely blank. It has form controls like buttons, separators, etc. But the browser canvas among them is still blank.
Read More

How do I change the transparency of an bitmap by percent in Delphi/FMX?

For a Firemokey project i'm working on a Bitmap, which should make a Bitmap on a TImage Component to get more transparent with the time. In order to do so, i want to use a procedure like the following, but it seems as if there is no way to create a change of the transparency as the following: procedure changeBitmapTransperency(TransparencyInPercent : Integer); begin {Set transparency of the bitmap to (TransparencyInPercent) percent} end; So, my question is, if there is a way to do so. Thanks for your time and effort, Max
Read More

Using TCameraComponent crashes program

I'm trying to use TCameraComponent, but when I try to use CameraComponent1->Active = true; it crashes my program. To use the camera, I added the following to AndroidManifest.xml, but it did not help. <uses-permission android:name="android.permission.CAMERA" /> <uses-feature android:name="android.hardware.camera" android:required="false" /> <uses-feature android:name="android.hardware.camera.autofocus" android:required="false" /> Do I need to add another permission?
Read More

error: Cannot begin rendering scene for ‘TContextIOS’

I develop an application in FireMonkey who load some image on a VertScrollBox. On iOS, from time to time i got an error: "Cannot begin rendering scene for 'TContextIOS'" Most of time it happened when rotate form, but not necessarily, sometimes it happens out of the blue... Maybe someone have an idea of what might happen? Any help will be appreciated.
Read More

How can I change the Delay before triggering the OnKeyDown-Event after it was triggered once in Delphi/FMX?

I'm sorry, but it seems like I have a beginner problem again, but i didn't found a solution to it online or in the help section: I want to use the OnKeyDown Event to do something (Different things, so i need a general solution), as Example to increase a number in a label. My code for this would look the following: Var i : Integer = 0; ... procedure TExampleForm.FormKeyDown(Sender: TObject; var Key: Word; var KeyChar: Char; Shift: TShiftState); begin Inc(i); ExampleLabel.Text:=IntToStr(i); end; If i press and hold a Key in the actual program, it will trigger the event just once immediately, and then it will trigger the event after a short delay many times, exactly how it should: The problem is, that i dont want this delay after the first trigger of the event and these, which are caused by the holding of the button. Is there any way to stop Delphi (Or probablly the Keyboard) from behaving like this? I would really appreciate a solution, thanks for your time and effort!
Read More