5-Minute-Snack: Using a Custom Delphi Component with FmxLinux
A couple of months ago, I described the Pexels component in detail. The component allows integration of pictures from Pexels.com into your Delphi application accessing the REST API provided.
Furthermore, I described the necessary steps using inheritance and abstraction that are necessary to develop the component for two frameworks: VCL and FireMonkey.
With the arrival of Delphi Tokyo and the recent announcement of FmxLinux which will give us the ability to write GUI applications with FireMonkey for Linux, I was eager to see if the demo application will also compile.
The demo application did compile without any issues. However, the main form was not being shown when I started the application.
The reason was rather simple:
Debugging the application showed that the Midas Library was missing as I use the TClientDataset component. I never installed the Midas libraries for Linux. They do not come with Tokyo. You need to download them separately. Marco Cantu blogged about that (link).
I decided to do yet another migration as the latest migration I tried worked out so nicely. As FireDAC is the way to go when it comes to databases, I replaced TClientDataset with TFDMemTable .
I have to admit that I was not able to approach this as easily as expected. Whenever I opened a form that I created with the Pexels component referencing TClientDataset the IDE was not able to open the form designer. Furthermore, I was unable to open the text view of the form. Thus, I had to replace the references in the form files using Notepad++. On the one hand I am very much aware that a data-type change is something not to be done with existing properties, especially if the components have been deployed to customers. On the other hand the IDE should be able to handle it.
However, after the replacements were taken care of, I was able to run the app in Linux:
This is quite an achievement for FmxLinux. The component uses:
- Database Technologies: FireDAC
- Parallel Programming: Asynchronous Web Requests
- Embarcadero REST Library
- Data Binding
Finally, let me repeat: No code change was necessary.
After supporting Windows 32 and 64, MacOS, iOS and Android, I can add Linux to the list of supported platforms.
If you are interested in all the details about component development: There will be a whole day on component development at the next Delphi Code Camp! All details here.
(For the record, I do know that I named my virtual Ubunto instead of Ubuntu by mistake. It’s a typo.)