Category: Firemonkey

Mouse Leave event in Firemonkey 10.3

I have a form with a control (myControl) and a child control (myChildControl). I want to manage the mouse exit on myControl so that I can take some actions. The problem is that the On Mouse Leave event is fired even though the mouse is still physically inside myControls but getting over myChildControl, while in this case I wouldn't need the event to be fired. I cannot set the HitTest property in the child control as I need to take some actions on mouse events on it too. Conceptually the Mouse Leave event fires properly, but what's the cleanest way to manage this case?
Read More

Delphi RTL: Generic vs. Traditional Collections

Since Delphi got generic types, in the 2009 version, its runtime library (RTL) has a generic collections unit. The RTL however, still has the classic collections. Recently I got some requests about which is recommended to use, and while the discussion can go a bit deeper, I wanted to blog a high level overview. Classic Container Classes The most basic collection class in the RTL is the TList class (in the System.Classes unit), which represents a general list of pointers (or object references). The container classes (in the System.Contnrs unit) includes the following: TObjectList, which is a TList for TObject references and includes ownership support TComponentList, which adds to the ownership also the notification support all components have TClassList TOrderedList TStack and TQueue with TObjectStack and TObjectQueue Various bucket lists When you are using these containers you often need to cast from the type of the objects you are managing to the fixed type the list supports. This introduced the possibility of errors and causes some runtime delay if you continuously check the type of the objects extracted from the list with dynamic casts (like "as"): myList: TList; myList.Get(3) as TMyObject Generic Collection Classes Along with generic types in the language Delphi added a set of basic generic collections. These are defined in the System.Generics.Collections unit and offer a generic blueprint for containers tied to the specific data type you need. Generic collections include: TList, a basic generic list including support for sorting and enumerations TThreadList, a more thread-safe list with locking support TQueue and TStack TDictionary, a fairly powerful dictionary with customizable key and value types TObjectList which has ownership support for can be used only for object types, similarly to the other following containers TObjectQueue and TObjectStack TObjectDictionary TThreadedQueue Advantages of Generic Collections Generics collections offer the ability to define specific containers for given data types you need to use, and let the compiler check the data type compatibility, rather than doing the same at runtime. This results in cleaner and more readable code, more robust applications, and faster execution -- given the reduced need ot runtime checks: myList: TList ; myList.Get(3); // returns TMyObject All of the new libraries and subsystems in Delphi use the new collections, for example FireMonkey leverages them a lot rather than using the traditional coding style. Any Reason not to Use Generic Collections? There are basically two reasons for not using the new collections. One is that if you have existing working code, you might not want to change it. Even more if the code is in a library (like VCL) changing it could cause incompatibility in code that uses the library. The other reason is that generics in Delphi cause a significant code bloat, because for any data type used by the collection the class methods are replicated, even if almost identical. In very large applications, this has a negative effect on compile and link time and on executable side. Additional Generic Collections Finally, I want to mention that if you use generic collections heavily, you should consider those available in the Spring4D library, which extends what we have in the RTL. See the documentation at Again this is meant to be a short summary and I know I could have been more extensive and precise, hope it is helpful to some of the old developers not fully aware of our generic collections -- which was the goal of the blog post.
Read More

indy compressor doesn’t work, TIdCompressorZlib not found

I'm trying to decompress a gzip response, all the samples and demos and answers on the internet simply create a TIdCompressorZlib but i can't find this in Delphi 10.3 FMX, i tried manually downloading and using TIdCompressorZlib but it had many errors and other dependencies so i gave up, i can see that idhttp.compressor uses IdZLibCompressorBase but doing something like: idhttp.Compressor := IdZLibCompressorBase.TIdZLibCompressorBaseClass.Create(idhttp); Doesn't work either because in run time it throws the error: --------------------------- Debugger Exception Notification --------------------------- Project MiniDownloader.exe raised exception class EAbstractError with message 'Abstract Error'. --------------------------- Break Continue Help --------------------------- I also tried forcing the response to not be a gzip to avoid decompressing, by using: idhttp.Request.AcceptEncoding := 'identity'; But this also fails because the response remains compressed I also tried using IdZlib.DecompressStream(inputMemoryStream, outputMemoyStream); But this also throws a runtime error : --------------------------- Debugger Exception Notification --------------------------- Project MiniDownloader.exe raised exception class EDecompressionError with message 'ZLib Error (-5)'. --------------------------- Break Continue Help --------------------------- I don't understand why this is so hard~! nothing works...!, is this because i'm not in VLC ? and i'm using FMX ? any solution and suggestion is much appreciated.
Read More

Sylt App für den Urlaub (バケーションアプリ) – クールアプリセレクション

本日のクールアプリセレクションは、Rolf Eschenbach氏の「Sylt App für den Urlaub(バケーションアプリ)」です。このアプリセットは、バケーション情報のワンストップ・リソースで、役に立つツールや情報がいっぱい詰められています。FireDACとFMXコンポーネントを使ってDelphiによって構築されており、AndroidとiOSプラットフォームで利用できます。(read more)
Read More

Delphi: 2 things to check when FMX/VCL units are inserted when you use VCL/FMX components

On G+, Tom Field bumped in the [WayBack] issue that the IDE would add VCL units to the uses list when putting FMX controls on a form. I’ve observed it the other way around as well, and there are two things you need to check: the FrameworkType element in your .dproj file Nowadays either VCL or FMX values are allowed, but in the past more values were used, see Delphi .dproj files: FrameworkType and FormType. the types of form files your unit embeds as resources which is either {$R *.dfm} for VCL or {$R *.fmx} for FMX. References: David Nottage: It has to do with whether there’s {$R *.fmx} or {$R *.dfm} in the unit. You may be able to get away with renaming the .dfm file to .fmx, and changing the directive in the unit. Jeroen Wiert Pluimers:  Your .dproj file tells you what kind of application it is (FMX or VCL) in the FrameworkType element and the IDE should respond to that correctly. –jeroen Source: In the Berlin Update 2 IDE. I’m working on a multi-device app I’m creating. …
Read More

Delphi FMX function to open a local file fails on Android platform

I require a cross-platform function to open a file using any app on the device registered to be able to open the file type concerned, along the lines of the WinAPI function ShellExecute in Windows. Using various code examples that I found on Stack-overflow I finally came up with the following code which compiles with Delphi 10.3. uses {$ifdef Android} FMX.Helpers.Android, AndroidAPI.Helpers, AndroidApi.JNI.GraphicsContentViewText, AndroidApi.JNI.Net, AndroidApi.JNI.JavaTypes; {$endif Android} {$ifDef MSWindows} Winapi.ShellAPI, Winapi.Windows; {$endif MSWindows} procedure OpenFile(FilePathname: string; DisplayError: Boolean); const COption= 0; var Extension: string; {$ifdef Android} Intent: JIntent; URI: Jnet_Uri; {$endif Android} Result: integer; begin Extension:= LowerCase(ExtractFileExt(FilePathname)); {$ifdef Android} URI := TJnet_Uri.JavaClass.parse(StringToJString('file:///' + FilePathname)); Intent:= TJIntent.Create; Intent.setFlags(TJIntent.JavaClass.FLAG_GRANT_READ_URI_PERMISSION); Intent.setAction(TJIntent.JavaClass.ACTION_VIEW); case COption of 0: Intent.setData(URI); 1: if Extension= '.pdf' then Intent.setDataAndType(URI,StringToJString('application/pdf')) else if Extension= '.txt' then Intent.setDataAndType(URI,StringToJString('text/*')); end; try SharedActivity.startActivity(Intent); except on E: Exception do begin if DisplayError then ShowMessage('Error: ' + E.Message); end; end; {$endif Android} {$ifdef MSWindows} Result:= ShellExecute(0, 'Open', PChar(FilePathname), '', '', SW_SHOWNORMAL); {$endif MSWindows} end; Applying this function to a local .PDF file on an SD card on an Android 9 device, the following exception is thrown: android.os.FileUriExposedException: file:////SDCard/test.pdf exposed beyond app through Intent.getData() I have found on StackOverflow the following thread which addresses this problem: android.os.FileUriExposedException: file:///storage/emulated/0/test.txt exposed beyond app through Intent.getData() However the idea of having to declare and use a class inheriting from the Java class File-provider in order to give access to a particular file or folder and make it accessible to other apps, and then document this in the AndroidManifest.xml seems greatly over-complicated, particularly considering that all the files in the SD card are public by definition. My questions, therefore, are: Is there a simpler way of dealing with this issue in Delphi FMX 10.3+? If not, how does one go about creating a Object Pascal class in Delphi inheriting from a Java class? A code example would be appreciated. Addendum: From a link to this post I have found the following code by Dave Nottage: procedure OpenPDFA(const AFileName: string); var LIntent: JIntent; LAuthority: JString; LUri: Jnet_Uri; begin LAuthority := StringToJString(JStringToString(TAndroidHelper.Context.getApplicationContext.getPackageName) + '.fileprovider'); LUri := TJFileProvider.JavaClass.getUriForFile(TAndroidHelper.Context, LAuthority, TJFile.JavaClass.init(StringToJString(AFileName))); LIntent := TJIntent.JavaClass.init(TJIntent.JavaClass.ACTION_VIEW); LIntent.setDataAndType(LUri, StringToJString('application/pdf')); LIntent.setFlags(TJIntent.JavaClass.FLAG_GRANT_READ_URI_PERMISSION); TAndroidHelper.Activity.startActivity(LIntent); end; However the class TJFileProvider is flagged up in the Delphi compiler as an undeclared identifier. The uses list in my code seems to be the same as in Dave Nottage's code. So where is TJFileProvider declared?
Read More

Throwing an exception on Android causes Segmentation Fault 11 error before catch handler is called

I am developing my first multi-platform application with C++Builder 10.3.3. My first two targets will be Android and Windows. I have run into an issue with even the most simplest Android apps when I try to use any exception handling. The following code in ANY function causes a "Segmentation fault (11)" error. I have tried it on a Huawei Mate 8 Pro running Android 7, and on a Samsung Note 9 running Android 9. void __fastcall Function(void) { try { throw Exception(_D("This is a test exception!")); } catch (const Exception & objException) { if (objException.Message.IsEmpty() == false) { } } } The exception gets created and thrown, but the Segmentation Fault gets raised and my catch handler is never reached. How do I fix this?
Read More

How to break ITask in Delphi/Firemonkey

I use the following block: TTask.Run(procedure begin TThread.Synchronize(nil, procedure begin loader.Visible := true; end); ... SQL SELECT TThread.Synchronize(nil, procedure begin loader.Visible := false; end); end); In general, everything is OK. The problem occurs when I close the Form while executing the SELECT procedure. When I reopen this Form, the loader is active, but the SQL function no longer performs. How can I complete all Tasks before closing the forms?
Read More

KisKis – クールアプリセレクション

今日のクールアプリセレクションは、KisKis Ltd.のアプリKisKisです。このアプリは、ソーシャルネットワークとデートアプリの最高の機能を組み合わせ、新しいソーシャルメディアエクスペリエンスを提供するものです。KisKisは、そのすべてがDelphiとFireMonkeyによって開発されています。(read more)
Read More

Delphi FMX 10.3: Issues with obtaining file properties in for multi-platform applications

I am seeking to convert some Delphi code to extract file properties from the operating system from a time-honoured implementation for the Windows platform to a new implementation for the Android platform. I have found that whereas the implementation for the Delphi platform uses the functions FindFirst() and FindNext() without problem and allows the file properties to be obtained from the TSearchRec parameter, this approach doesn’t appear to work for the Android platform. So I need to find cross-platform functions to obtain file and directory properties. Several properties may be obtained using methods of the System.IOUtils record types TDirectory and TFile. But for some reason, these does not appear to include a method to obtain the size in bytes of a file. Therefore, I have tried to obtain the file size by creating a TFileStream object for the file given its pathname, and then getting the size from the TFileStream.Size property. This method works when the file is not already open. However if the file is open, then an exception is thrown. The next question, then, is how to find out whether a file is open before calling TFileStream.Create(). This ought to be straightforward, but I cannot remember how to do it. So I have tried the following global procedure: procedure FXGetFileSize(FilePathname: string; var FileInUse: Boolean; var Size: int64); var FileStream: TFileStream; begin try FileStream:= TFileStream.Create(FilePathname, fmOpenRead); try FileInUse:= False; Size:= FileStream.Size; finally FileStream.Free; end; except on E: Exception do begin FileInUse:= True; Size:= 0; FileStream.Free; end; end; end; I call this procedure from within the following method: procedure TFolder.ReadFX (Pathname: string; Recurse: Boolean); {Reads details of folder file components in a folder into a TFolder data structure – cross-platform version} var Separator: char; FolderPaths: TStringDynArray; FilePathNames: TStringDynArray; i: integer; FolderPathI: string; FilePathnameI: string; SubFolder: TFolder; SubFileCpt: TFileCpt; SubFileCptIndex: integer; FolderCptName: string; Datetime: TDatetime; FileInUse: Boolean; FileSize: int64; begin Separator:= TPath.DirectorySeparatorChar; FCount:= 0; FCumSize:= 0; FCumFileCount:= 0; FCumFolderCount:= 1; {Extract list of subfolders in directory:} FolderPaths:= TDirectory.GetDirectories(Pathname); {Create a TFolder object for each subfolder:} for i:= 0 to High(FolderPaths) do begin FolderPathI:= FolderPaths[i]; if TDirectory.Exists(FolderPathI) then begin try {Create TFolder object for subfolder i:} SubFolder:= TFolder.Create; AddFolderCpt(SubFolder, SubFileCptIndex); {Assign TFolder properties:} FolderCptName:= StringReplace(FolderPathI, (Pathname + Separator), '', [rfIgnoreCase]); Subfolder.Name:= FolderCptName; {Subfolder.Name:= Path; } Subfolder.FDateTime:= TDirectory.GetLastWriteTime(FolderPathI); {Recursively process subfolder:} if Recurse then Subfolder.Read(FolderPathI, Recurse); {Compute aggregate properties:} FCumSize:= FCumSize + SubFolder.FCumSize; FCumFileCount:= FCumFileCount + SubFolder.FCumFileCount; FCumFolderCount:= FCumFolderCount + SubFolder.FCumFolderCount; except on E: Exception do begin E.Message:= 'Error in TFolder.ReadFX processing folder "' + FolderPathI + '"' + #13#10 + '(' + E.Message + ')'; end; end; end; end; {Get list of files in directory:} FilePathNames:= TDirectory.GetFiles(Pathname); {Create TFileCpt objects for each child file:} for i:= 0 to High(FilePathnames) do begin FilePathnameI:= FilePathnames[i]; if (FilePathnameI<> '.') and (FilePathnameI<>'..') then begin try {$ifdef MSWINDOWS} if not ([TFileAttribute.faHidden, TFileAttribute.faSystem] <= TFile.GetAttributes(FilePathnameI)) then {$endif} begin FXGetFileSize(FilePathnameI, FileInUse, FileSize); {***} {Create a TFileCpt object corresponding to FilePathnameI:} SubFileCpt:= TFileCpt.Create; AddFolderCpt(SubFileCpt, SubFileCptIndex); {Assign TFileCpt properties:} SubFileCpt.FName:= TPath.GetFileName(FilePathnameI); SubFileCpt.FSize:= FileSize; SubFileCpt.FDateTime:= TFile.GetLastWriteTime(FilePathnameI); FCumSize:= FCumSize + FileSize; FCumFileCount:= FCumFileCount + 1; end; except on E: Exception do begin E.Message:= 'Error in TFolder.ReadFX processing file "' + FilePathnameI + '"' + #13#10 + '(' + E.Message + ')'; end; end; end; end; end; Unfortunately, when I call TFolder.ReadFX() for Pathanme= ‘C:\\Users\User XXX' on Windows 7, a runtime exception is always thrown when an open file presumably opened by the Windows OS is encountered. In conclusion, can any one help with the following questions: How to obtain the size of a file without having to open the file stream How to determine whether or not the file is already/in use In the case of a folder, how to extract the name of lowest level folder from the folder path, without manually parsing the path.
Read More

TMS FNC Blox for the WEB!


A while back, we brought FNC to the WEB, except TMS FNC Blox was missing due to some deep technical limitations. We can now proudly announce that TMS FNC Blox supports TMS WEB Core!


Below is a list of features that are supported in TMS FNC Blox.

  • High-quality (anti-aliasing) drawing of blocks and lines
  • Open architecture for building custom blocks and lines inherited from base classes
  • Ready-to-use flowchart, arrow and electric blocks
  • Linking system allow customizable link points and information retrieval of connected blocks
  • Block gradient, shadow and bitmap
  • Full block customization: pen, brush, color, selection color, minimum width and height
  • Block text customization: horizontal and vertical alignment, font, word wrap, clipping
  • Customizable link points in blocks
  • Full line (link) customization: pen, source arrow shape, target arrow shape
  • Arc & bezier lines, polygon objects
  • Block rotation supported (including text, bitmap and gradient)
  • Separate TTMSFNCBloxToolBar component for easy diagram editing with no line of code (needs TMS FNC UI Pack)
  • Diagram snap grid
  • Diagram rulers
  • Saving/Loading diagram to/from file and stream
  • Diagram zoom in/out
  • Panning
  • Helper classes TTMSFNCBloxBlockDrawer for easy custom drawing on custom blocks
  • Object deletion and inserting, zooming, and more.


With FNC we aim for reusable code and when bringing TMS FNC Blox to the WEB we wanted to maintain compatibility with FMX, LCL and VCL as much as possible. By rewriting the persistence part of TMS FNC Blox and integrating it into TMS FNC Core it is possible to load blox files that have been saved in a VCL, LCL or FMX application into a TMS WEB Core client application. The code for creating and registering custom blocks in VCL, LCL or FMX is also compatible with TMS WEB Core.

Getting Started

Install the latest version of TMS WEB Core, TMS FNC Core and TMS FNC Blox
The demo (also included in the TMS WEB Core demonstrates the uses of the TTMSFNCBloxToolBar, TTMSFNCBloxSelector and how to add, configure and manipulate blox elements.

Read More

Read More