Category: StackOverflow

Drawing to FireMonkey TControl.Canvas outputs to TForm Canvas

I've just started transitioning a huge codebase to FireMonkey but I'm having some difficulties. One thing tripping me up is a major gotcha with TControl.Canvas. If I don't call it correctly, then drawing to the TCanvas, actually draws to the form canvas (to be specific, it draws at 0,0 on the form, rather than the client origin of my custom control). For example, in a MouseMove event I need to draw a selection. Here is some example code: procedure TMyCustomControl.MouseMove(Shift: TShiftState; sX, sY: Single); begin inherited; ... Paint(); end; procedure TMyCustomControl.Paint(); begin PaintToCanvas(Canvas); end; Using this code in FireMonkey, painting is to the form (i.e. outputs at 0,0 on the form). If I change the code in MouseMove to Repaint(); then it paints correctly to my control. Clearly, with FMX, I need to trigger the control's actual painting (not just paint directly), otherwise the Canvas is not valid. What I need is an explanation as to why it functions like this. I have a lot of canvas drawing in my code, so I need to understand this so I can hunt out other incompatible code. System: Delphi 10.3 Rio, 32 or 64bit Windows apps.
Read More

Why can’t Delphi 10.3.2 find Posix.Locale.pas unit for an Android application?

I'm new to doing cross-platform development with Delphi and I thought I'd give it a go. I have a Nexus 7, up-to-date and have the USB debugging enabled on it, etc. Right now, I just want to test out an empty form and I get a compile time error Unit 'Posix.Locale' not found. The source file "C:\Program Files (x86)\Embarcadero\Studio\20.0\source\rtl\posix" is present so I'm unsure why the compiler can't find it. I don't see any obvious PATH settings under Environmental Variables. Any ideas?
Read More

Mapview delphi firemonkey exception

Can someone help me? I am developing a shopping android app ... I was using the delphi 10.3.1 community. However, you must reinstall. Reinstall this time in the version 10.3.2 community. For a surprise or map view, it has stopped working (throws a java exception). Already available for version 10.3.1 again, new api key and nothing, even the examples that come with delphi and other applications using mapview also don't work. When you install the app on your device, Play Protect says you don't know the app and install it, but when you call the map, it throws an exception. someone with the same problem?
Read More

Why tmediaplayer.CurrentTime not working for Android?

I want to make control audio with tackBar I use this code When audio is playing, my code on timer is If trackbar1.max<>mediaplayer1.duration then trackbar1.max := mediaplayer1.duration; If trackbar1.value<>mediaplayer1.currentTime then trackbar1.value :=mediaplayer1.currentTime This code works perfectly for windows, but on Android no (trackbar keep changing up down up down)
Read More

EReadError with TColor published properties in FMX

In an FMX component, I have this definition: published property BackgroundColor: TColor read fBackgroundColor write fBackgroundColor; end; If BackgroundColor is set to a const, like clRed, then I get an EReadError "Error reading BackgroundColor: Invalid property value". It works with a normal value, like $00FF8000. So why does the Object inspector let you select a const??? The workaround is to declare the property as TAlphaColor, but that means another conditional define in my combined VCL/FMX unit. Is there any other way I can keep the property as TColor? Delphi 10.3.2
Read More

How to check the status of BlueTooth adapter (ON/OFF) with Delphi 10.3 (Firemonkey) App for both Android and iOS

I am writing an IOT based (BTLE) Firemonkey app and I need to check that Bluetooth adapter is Enabled or not for both iOS and Android. I've found a source here but it is only for android (like many others), but I need a cross platform solution.
Read More

UIFileSharingEnabled key in Info.plist

I added the key UIFileSharingEnabled to my app's version info as described here so my users can save files to my apps documents folder. Works great in testing. Tried to upload to apple store with Application Loader and i'm getting an ERROR ITMS-90039: "Type Mismatch. The value for the Info.plist key UIFileSharingEnabled is not of the required type for that key.. I've googled and found where other folks had problems with it but none of their solutions helped. Here are the ways i've tried to show this key in the Info.plist: <key>UIFileSharingEnabled</key> <string>true</string> <key>UIFileSharingEnabled</key> <true/> <key>UIFileSharingEnabled</key> <string>YES</string> <key>UIFileSharingEnabled</key> <YES/> All have the same result, Application Loader barfs out the ERROR ITMS-90039. This key is a boolean key and for other boolean keys in Info.plist they just look like that top one i show. Anyone have a sample Info.plist with this key true that we can compare too? I've built my app in Rad Studio 10.3.2 (C++ Builder). They key works with test builds on the phone.
Read More

Trying to compile TurboActivate into an MacOS 64 App – getting E2597 Undefined symbols for architecture x86_64:

during the linking stage of compilation - I get this error [dccosx64 Error] E2597 Undefined symbols for architecture x86_64: Error: "__TA_GetHandle", referenced from: __ZN17Turboactivateunit12TA_GetHandleEPc in TurboActivateUnit.o; Error: "__TA_CheckAndSavePKey", referenced from: __ZN17Turboactivateunit19TA_CheckAndSavePKeyEmPcm in TurboActivateUnit.o; Error: "__TA_PDetsFromPath", referenced from: __ZN17Turboactivateunit16TA_PDetsFromPathEPc in TurboActivateUnit.o; Error: "__TA_ActivateFromFile", referenced from: __ZN17Turboactivateunit19TA_ActivateFromFileEmPc in TurboActivateUnit.o; . . . . . ld: symbol(s) not found for architecture x86_64 In the code the functions are declared like this function TA_GetHandle(versionGUID: System.PAnsiChar):LongWord; cdecl; external 'libTurboActivate.dylib' name '_TA_GetHandle'; function TA_Activate(handle: LongWord; options: Pointer):LongInt; cdecl; external 'libTurboActivate.dylib' name '_TA_Activate'; function TA_ActivationRequestToFile(handle: LongWord; filename: System.PAnsiChar; options: Pointer):LongInt; cdecl; external 'libTurboActivate.dylib' name '_TA_ActivationRequestToFile'; function TA_ActivateFromFile(handle: LongWord; filename: System.PAnsiChar):LongInt; cdecl; external 'libTurboActivate.dylib' name '_TA_ActivateFromFile'; . . . . I have examined the Dylib file on the Mac using the 'nm' tool and got a list of the functions inside the dylib - unfortunately I am note sure how to determine whether the function is 32bit or 64bit as I understand a dylib can contain both version of the function. Am I correct in thinking that the dylib may only contain the 32 bit version of the functions and not the 64? I have been in touch with Wyday, the creators of the TurboActivate.dylib who very quickly responded with a 'not our problem' response. To Answer Duns Question: I am afraid not - I contacted Lime support here is there reply: It’s hard to say what exactly Delphi finds objectionable. libTurboActivate.dylib works perfectly for other programming languages. Likely bugs in Delphi and / or their support for x64 macOS target (which must be a recent addition to Delphi, because the 10.2 version of Delphi only support x86). We’ll look at this eventually and see if we can work around Delphi’s bugs. But this is not high priority for us right now. You’d be better off contacting Delphi’s parent company (still Empbarcadero?) and ask them to help you. I did contact embarcadero who came back with this Your request has been determined to be beyond scope of our incident-based support services. I recommend checking with the vendor responsible for the support library for assistance. It would appear that the two vendors are blaming each other which isn't very helpful at all. I ended up removing LimeLM from our product and went with a much cruder version of usage control for now. If it doesn't get fixed we will pursue other forms of product licensing.
Read More

Firemonkey macOS 64 bit app not recognised on osx

I have successfully compiled and deployed an app using 'macOS 64-bit' as the target platform using Delphi Rio 10.3.2. The app appears to run fine on macOS Mojave, however when I use the 'System Report' on the Mac, the app has the '64-bit (intel)' flag set to 'No' so I am guessing this app will still be rejected on Catalina when it comes along in October. What do I need to check/change to get the app to be recognised correctly by the 'System Report' To answer Dave, here is the start of the compiler output *Building AAG.dproj (Debug, OSX64) brcc32 command line for "AAG.vrc" c:\program files (x86)\embarcadero\studio\20.0\bin\cgrc.exe -c65001 "AAG.vrc" -foAAG.res dccosx64 command line for "AAG.dpr" c:\program files (x86)\embarcadero\studio\20.0\bin\dccosx64.exe -$O- --no-config -B -Q -AGenerics.Collections=System.Generics.Collections; Generics.Defaults=System.Generics.Defaults;WinTypes=Winapi.Windows;WinProcs=Winapi.Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE -DDEBUG -E.\OSX64\Debug -I"c:\program files (x86)\embarcadero\studio\20.0\lib\OSX64\debug";"c:\program files (x86)\embarcadero\studio\20.0\lib\OSX64\release"; E:\MyFiles\MyDocuments\Embarcadero\Studio\20.0\Imports;"c:\program files (x86)\embarcadero\studio\20.0\Imports"; C:\Users\Public\Documents\Embarcadero\Studio\20.0\Dcp\OSX64;"c:\program files (x86)\embarcadero\studio\20.0\include";"c:\program files (x86)\embarcadero\studio\20.0\redist\OSX64";C:\Users\Public\Documents\Embarcadero\Studio\20.0\Bpl\OSX64;"C:\Program Files (x86)\FastReport FMX 2 Professional\Source";"C:\Program Files (x86)\FastReport FMX 2 Professional\FastScript";"E:\MyFiles\MyDocuments\tmssoftware\TMS FMX UI Pack"; "E:\MyFiles\MyDocuments\tmssoftware\TMS FMX UI Pack\Delphi103Rio\OSX32";"E:\MyFiles\MyDocuments\tmssoftware\TMS FMX UI Pack\XlsAdapter";"C:\Program Files (x86)\FastReport FMX 2 Professional\LibD26OSX64";"C:\Source Files\Rio\AAG\Resource Files\Misc" -LEC:\Users\Public\Documents\Embarcadero\Studio\20.0\Bpl\OSX64 -LNC:\Users\Public\Documents\Embarcadero\Studio\20.0\Dcp\OSX64 -NU.\OSX64\Debug -NSSystem;Xml;Data;Datasnap;Web;Soap; -O"c:\program files (x86)\embarcadero\studio\20.0\lib\OSX64\release"; E:\MyFiles\MyDocuments\Embarcadero\Studio\20.0\Imports;"c:\program files (x86)\embarcadero\studio\20.0\Imports"; C:\Users\Public\Documents\Embarcadero\Studio\20.0\Dcp\OSX64;"c:\program files (x86)\embarcadero\studio\20.0\include";"c:\program files (x86)\embarcadero\studio\20.0\redist\OSX64";C:\Users\Public\Documents\Embarcadero\Studio\20.0\Bpl\OSX64;"C:\Program Files (x86)\FastReport FMX 2 Professional\Source";"C:\Program Files (x86)\FastReport FMX 2 Professional\FastScript";"E:\MyFiles\MyDocuments\tmssoftware\TMS FMX UI Pack"; "E:\MyFiles\MyDocuments\tmssoftware\TMS FMX UI Pack\Delphi103Rio\OSX32";"E:\MyFiles\MyDocuments\tmssoftware\TMS FMX UI Pack\XlsAdapter";"C:\Program Files (x86)\FastReport FMX 2 Professional\LibD26OSX64";"C:\Source Files\Rio\AAG\Resource Files\Misc" -R"c:\program files (x86)\embarcadero\studio\20.0\lib\OSX64\release";E:\MyFiles\MyDocuments\Embarcadero\Studio\20.0\Imports;"c:\program files (x86)\embarcadero\studio\20.0\Imports";C:\Users\Public\Documents\Embarcadero\Studio\20.0\Dcp\OSX64;"c:\program files (x86)\embarcadero\studio\20.0\include";"c:\program files (x86)\embarcadero\studio\20.0\redist\OSX64"; C:\Users\Public\Documents\Embarcadero\Studio\20.0\Bpl\OSX64;"C:\Program Files (x86)\FastReport FMX 2 Professional\Source";"C:\Program Files (x86)\FastReport FMX 2 Professional\FastScript";"E:\MyFiles\MyDocuments\tmssoftware\TMS FMX UI Pack";"E:\MyFiles\MyDocuments\tmssoftware\TMS FMX UI Pack\Delphi103Rio\OSX32";"E:\MyFiles\MyDocuments\tmssoftware\TMS FMX UI Pack\XlsAdapter";"C:\Program Files (x86)\FastReport FMX 2 Professional\LibD26OSX64";"C:\Source Files\Rio\AAG\Resource Files\Misc" -U"c:\program files (x86)\embarcadero\studio\20.0\lib\OSX64\debug"; "c:\program files (x86)\embarcadero\studio\20.0\lib\OSX64\release";E:\MyFiles\MyDocuments\Embarcadero\Studio\20.0\Imports;"c:\program files (x86)\embarcadero\studio\20.0\Imports";C:\Users\Public\Documents\Embarcadero\Studio\20.0\Dcp\OSX64;"c:\program files (x86)\embarcadero\studio\20.0\include";"c:\program files (x86)\embarcadero\studio\20.0\redist\OSX64"; C:\Users\Public\Documents\Embarcadero\Studio\20.0\Bpl\OSX64;"C:\Program Files (x86)\FastReport FMX 2 Professional\Source";"C:\Program Files (x86)\FastReport FMX 2 Professional\FastScript";"E:\MyFiles\MyDocuments\tmssoftware\TMS FMX UI Pack";"E:\MyFiles\MyDocuments\tmssoftware\TMS FMX UI Pack\Delphi103Rio\OSX32";"E:\MyFiles\MyDocuments\tmssoftware\TMS FMX UI Pack\XlsAdapter";"C:\Program Files (x86)\FastReport FMX 2 Professional\LibD26OSX64";"C:\Source Files\Rio\AAG\Resource Files\Misc" --syslibroot:E:\MyFiles\MyDocuments\Embarcadero\Studio\SDKs\MacOSX10.14.sdk --frameworkpath:E:\MyFiles\MyDocuments\Embarcadero\Studio\SDKs\MacOSX10.14.sdk\System\Library\Frameworks; E:\MyFiles\MyDocuments\Embarcadero\Studio\SDKs\MacOSX10.14.sdk\System\Library\PrivateFrameworks -V -VN -NHC:\Users\Public\Documents\Embarcadero\Studio\20.0\hpp\OSX64 -NO.\OSX64\Debug AAG.dpr [dccosx64 Warning] FMX.TMSCalendar.pas(1923): W1000 Symbol 'Release' is deprecated: 'Support for this method will be removed' [dccosx64 Warning] FMX.TMSCalendar.pas(2220): W1000 Symbol 'Release' is deprecated: 'Support for this method will be removed'* The first line is obviously referring to a 32 bit compiler, but it is definitely using [dccosx64] which is supposed to be the 64 bit compiler.
Read More

Sending Multiple Attachments firemonkey

I'm trying send a email with multiple attachments, but, in Android SDK most recent, was changed the method to send files, and most existing tutorials is about the older SDK version ... I obtained send the email with only one attachment, but not with multiple... I try using the same method of 1 attachment but using it twice. Not works, the delphi catch only the last Intent.putExtra. What I'm making wrong ? (Utilizing only the Android Plataform) procedure TF_inicio.Rec_exportClick(Sender: TObject); var sfilename: string; AttachmentFile1: JFile; AttachmentFile2: JFile; AttachmentFile3: JFile; Intent: JIntent; AddressesTo, Anexos: TJavaObjectArray<JString>; LList: TStringDynArray; I: Integer; LSearchOption: TSearchOption; // AddressesCC, AddressesBCC: TJavaObjectArray<JString>; begin LSearchOption := TSearchOption.soTopDirectoryOnly; LList := TDirectory.GetFiles(path, '*.csv', LSearchOption); Intent := TJIntent.Create; Intent.setAction(TJIntent.JavaClass.ACTION_SENDTO); Intent.setData(TJnet_Uri.JavaClass.parse(StringToJString('mailto:'))); AddressesTo := TJavaObjectArray<JString>.Create(1); // Enviar para: AddressesTo.Items[0] := StringToJString('MyEmail@gmail.com'); Intent.putExtra(TJIntent.JavaClass.EXTRA_EMAIL, AddressesTo); Intent.putExtra(TJIntent.JavaClass.EXTRA_SUBJECT, StringToJString(F_inicio.placa_veiculo + ' - ' + FormatDateTime('dd/mm/yyyy hh:MM', NOW))); Intent.putExtra(TJIntent.JavaClass.EXTRA_TEXT, StringToJString('Email automático' + sLineBreak + '')); if Length(LList) = 1 then AttachmentFile1 := TJFile.JavaClass.init(StringToJString(LList[1])); if Length(LList) = 2 then AttachmentFile2 := TJFile.JavaClass.init(StringToJString(LList[2])); if Length(LList) = 3 then AttachmentFile3 := TJFile.JavaClass.init(StringToJString(LList[3])); if Length(LList) >= 1 then begin AttachmentFile1 := TJFile.JavaClass.init(StringToJString(LList[1])); Intent.putExtra(TJIntent.JavaClass.EXTRA_STREAM, TJParcelable.Wrap((TJnet_Uri.JavaClass.fromFile(AttachmentFile1) as ILocalObject).GetObjectID)); end; if Length(LList) >= 2 then begin AttachmentFile2 := TJFile.JavaClass.init(StringToJString(LList[2])); Intent.putExtra(TJIntent.JavaClass.EXTRA_STREAM, TJParcelable.Wrap((TJnet_Uri.JavaClass.fromFile(AttachmentFile2) as ILocalObject).GetObjectID)); end; if Length(LList) >= 3 then begin AttachmentFile3 := TJFile.JavaClass.init(StringToJString(LList[3])); Intent.putExtra(TJIntent.JavaClass.EXTRA_STREAM, TJParcelable.Wrap((TJnet_Uri.JavaClass.fromFile(AttachmentFile3) as ILocalObject).GetObjectID)); end; SharedActivity.startActivity(Intent); end;
Read More