Category: Firemonkey

Delphi firemonkey tpath3d

I used firemonkey tpath3d on windows to show customized shapes like triangle, ellipse and complex shapes. On windows it work with no problems but on android it only shows a rectangle even I can't show a triangle ! Here is a simple ellipse code: Path3d1.path.clear; Path3d1.path.addellipse(-1,-1,1,1); Path3d1.path.closepath; It works on windows but on android it doesn't; I don't know What's the problem.
Read More

TMS WEB Core partner program launched

We’re thrilled to launch from today the TMS WEB Core partner program. The TMS WEB Core partner program is created to let everyone participate, benefit from additional TMS WEB Core components and to offer exposure to individual developers and companies to make other TMS WEB Core developers aware of the extra tools and components created for TMS WEB Core.

Explore

Visit the TMS WEB Core partner program page where we have for this launch already 5 offerings:

  • 40+ Smart HTML elements wrapper components
  • Screen capture component
  • Froala Editor wrapper component
  • Vaadin mobile friendly UI control wrapper components
  • Components for real-time video communication with Jitsi and OpenTok WebRTC services

Why a partner program?

The world of web development is vast and rapidly evolving. There is literally an abundance of interesting code available for web application development. From various exciting UI components to JavaScript libraries offering complex functionality such as AI libraries and so much more. As Delphi RAD developers we have come to expect that taking advantage of such functionality should only be a component away. And that is exactly the reason and purpose why we have created the TMS WEB Core partner program. It allows you to contribute to the TMS WEB Core ecosystem, be it with open-source component wrappers for web functionality, commercial components or any other tools that helps TMS WEB Core developer being more productive. Of course, our team also plans to regularly contribute components that will be open-source and expose specific functionality for use in TMS WEB Core web applications that we do not consider part of core framework functionality. To launch the program we already bundle several open-source components we developed for TMS WEB Core with today also an extra library of vaadin web component wrappers added especially for this launch. Extra advantage: when paying a little bit attention to how a component is designed, the same code will be usable not only from TMS WEB Core for Delphi but also from TMS WEB Core for Lazarus or soon TMS WEB Core for Visual Studio Code.

Getting started

Get ready and learn all about custom component development for TMS WEB Core. A great starting resource to explore how to do this are these interesting blog articles: https://www.tmssoftware.com/site/blog.asp?post=449 and also https://www.tmssoftware.com/site/blog.asp?post=491

When you created your first components, follow the 3 steps to be included in the TMS WEB Core partner program:

Benefits

Expose your work and knowledge about Delphi and TMS WEB Core component development to others via the TMS WEB Core partner program. If you decide to make your work commercially available, we’ll be happy to publish it on the partner page as well. Recognized contributors to the TMS WEB Core partner program get a free TMS WEB Core license.

Start developing today

Download the latest TMS WEB Core for Delphi and Lazarus v1.4.2 release and get started. The trial version is not time-limited, so you can take your time to explore the wonderful world of web development. Get in touch with the team in case you look for technical help and advice. We are eager to see what fantastic web functionality you will integrate in TMS WEB Core!

Read More

Read More

Wrapper pack for Vaadin UI Components

A while ago we created an import tool to minimize the workload of importing web components into TMS WEB Core. We wanted to extend the capabilities of this import tool and adjust it as much as possible so it can handle a wider range of web component sets. If you take a look around the countless available libraries, you’ll notice that many of the web components share the same functionality, so we wanted to pick something that stands out.

Our next target was the Vaadin UI Components. It is developed by Vaadin and the component pack is available through HTML and Java. It has free and open-source elements and apart from the different look and feel it also introduces some new components, such as Login and its overlay variant.

Another advantage is that many of the elements behave differently on smaller screens, making them a great candidate for mobile development. Below you can see the difference between the Date Picker and Tabs components on a bigger desktop and smaller mobile browser.

The online documentation is available for each component here under the “Free & open source components” section.

You can go ahead explore a selection of these components in our demo, and make sure to check it out on mobile devices too! We made this wrapper pack available for free as part of our new TMS WEB Core partner program, and you can download it from here.

To install, open, compile & install the package from the “Component Library Source” folder. This will install the design-time components.
For use at runtime, make sure that the “Core Source” folder is in your TMS WEB Core specific library path that you can set via IDE Tools, Options, TMS Web, Library path.

Read More

Read More

Freeing dynamically-created controls in Android

In my Firemonkey multi-platform app, I dynamically create some controls. After using them, I destroy them. In Windows, there is no issue with this dynamically created and destroyed process. However, it seems that in Android, the code below does not destroy the controls as an error will popup to say that the Control already exists (and I do see the old controls are still there when I try to re-create the controls). How do I ensure the controls are destroyed properly in Android (and/or iOS - I assume it's similar for iOS)? for i := oParentRect.ControlsCount-1 downto 0 do begin oControl := oParentRect.Controls[i]; if (oControl is TText) or (oControl is TEdit) then begin FreeAndNil( oControl ); // I have also tried oControl.Free; end; end;
Read More

Printing in Firemonkey

TPrinter* prn = Printer::Printer(); TCanvas* Canvas = prn->Canvas; String text = "Long live the king"; TFillTextFlags fTextFlag = TFillTextFlags(); prn->BeginDoc(); TRectF rect{100, 100, 800, 800}; Canvas->FillText(rect, text, false, 1, fTextFlag, TTextAlign::Leading, TTextAlign::Leading); prn->EndDoc(); ShowMessage("Done Printing!"); The Text coming out is very tiny (as if no scaling was done with respect to DPI... like it was printing to a Screen, not a printer)... I tried the above (similar) codes in VCL, and it comes out fine...
Read More

Firemonkey does not show Hebrew text in iOS

When I fill in a FMX control (like TLabel, TText or TMemo) with a Hebrew text - it's not being shown in iOS (in Android and Win it works fine), only punctuation appears and non-Hebrew symbols. Even in a blank project with just one label on a clean form. Is not it supported or did I forget to configure my project with some encoding/codepage etc.? Delphi 10.3 Version 26.0.36039.7899; iPhone 7 Plus, iOS 13.5.1; Mac OS Catalina 10.15.4
Read More

Prevent rearrangement of my visual controls during runtime with dynamic RESIZING of TLayout Control in Delphi Firemonkey [duplicate]

Is there a way that I can prevent re-arrangement of my visual controls during runtime with dynamic RESIZING of some of the controls like TLayout/TVertScrollBox in my case? Here's the controls contained in my form: Form TabControl TabItem1 // select and filter a meta to be to shown in TabItem2 TVertScrollBox1 TabItem2 // select and filter an item to be shown in TabItem3 TVertScrollBox2 TabItem3 // provide the details of the selecte item from TabItem2 TVertScrollBox3 TLayout1 TImage TLabel1 TLabel2 TLayout2 // get its height from TListView item(record) count TLabel3 TListView // dynamically based on item(record) count provide the height TLayout2 Based on the above setup, the size of TLayout1 is dependent on the record count (fdquery.recordcount) to be shown in TListView. Upon running the program, the controls changed its position like the TLabel2 will move to the bottom and all others arbitrarily. I was given the answers here and another one here but it discussed about TPanel created at runtime. I am not really sure if these are relevant to my questions. Because I don't use TPanel controls and its being created at runtime. Mine is create at design time except that some controls are dynamically resizing at runtime. I found another solution from youtube of Alister Christie to create a procedure below: procedure TformMain.OrderControls; begin TImage.Align.alBottom := 0; //Alister sample is Button1.Left := 0; TLabel1.Align.alBottom := 0; TLabel2.Align.alBottom := 0; TLayout2.Align.alBottom := 0; TLabel3.Align.alBottom := 0; TListView.Align.alBottom := 0; end; procedure TfromMain.TVertScrollBox1ItemClick(const Sender: TObject; const AItem: TListViewItem); begin OrderControls; end; But, I am getting the error on alBottom as it is already deprecated. I tried Align.Bottom and this time it is not recognized. My issue is getting deeper here. Going back, all I want is how to make my controls fix to its assigned location even if my other controls are dynamically resizing at runtime.
Read More

Delphi FMX (Android) – How read text file inside zip stream without extract?

Is it possible to read a file from the zip file without extract it? I want to read a text file from a compressed file(as an android assets) in a Memo lines. ZipFile := TZipFile.Create; //Zipfile: TZipFile try ZipFile.Open('C:\Path\to\file.zip', zmRead); for I := 0 to ZipFile.FileCount - 1 do begin if ZipFile.FileNames[I]='A1.txt' then //S: string //My problem is here ? How load A1.txt to memo lines? Memo1.Lines.Add(S); end; ZipFile.Close; finally ZipFile.Free; end;
Read More

Delphi Exception handling code review reminders

I bumped into [WayBack]When an exception is nil in the exception handler – twm’s blog for some legacy code a while ago. Some code review reminders: raise Exception( is always wrong: no exception instance is created Exception.Create( without a raise is wrong most of the times except end is almost always wrong except and finally in encompassing blocks often is a code smell I need to check which ones are caught by [WayBack] Code Analysis Tool | FixInsight for Delphi (which is not at [WayBack] TMS Software | VCL, FMX, ASP.NET, .NET controls & components for Delphi, C++Builder & Visual Studio | TMS FixInsight Pro.) –jeroen
Read More

Upload file using IdHTTP to specified host based on curl call

I am trying to create an FMX Android application that needs to upload a file to given host. The host owner provided me with a following curl statement to upload a file: curl -T http://<ip-address>:<port> file.txt And when called from Windows Command Prompt it produces the following output (IP and port redacted): * Trying <ip-address>... * TCP_NODELAY set * Connected to <ip-address> (<ip-address>) port <port> (#0) > PUT /file.txt HTTP/1.1 > Host: <ip-address>:<port> > User-Agent: curl/7.55.1 > Accept: */* > Content-Length: 682 > Expect: 100-continue > * Done waiting for 100-continue * We are completely uploaded and fine < HTTP/1.1 200 OK < content-length: 0 < date: Tue, 16 Jun 2020 19:24:18 GMT < connection: close < * Closing connection 0 and file is visible in the expected directory on the host machine. Now I'm trying to have the same behavior using Indy, but either there is some black-box magic occurring on the server-side, or there is an issue with my code - with some solutions the request seems to finalize, but there is no file in the specified directory (and status code 200 is returned). I have also tried using Fiddler to reproduce the curl call, and in the response of a composed query also received 200 status code, but still - no file was properly uploaded. When inspecting Wireshark packets for these solutions they all seemed similar to the curl call - however, I am not an expert in using this tool, so maybe there are issues not visible to my newbie eye. I tried using following solutions: - How do I upload a file using http post? Delphi 2009 - but using PUT instead of POST - Single file upload example - Post a file through https using indy / delphi components And in my case they do not work - so my guess is that the server is somehow not accepting these. I know it's very hard to say what I'm doing wrong without me actually putting some code, but right now it's a total mess - but maybe it's not hard to somehow show me how to convert this curl call to work with TIdHttp? If not, I will try to modify my question soon with more information. EDIT: As requested, I'm adding some sample code: var FHTTP: TIdHTTP; file2send: string; sr: TStringStream; FPutData : TFileStream; begin sr := TStringStream.Create; if OpenDialog1.Execute then file2send := OpenDialog1.FileName; FHTTP := TIdHTTP.Create(self); FPutData := TFileStream.Create(file2send, fmOpenRead or fmShareDenyWrite); FHTTP.Put(PutURL.text, FPutData, sr); end;
Read More

FNC Styles are here!

Intro

After the first announcement a week ago, and a lot more tweaks and improvements we are proud to announce the first release of FNC Styles! FNC Styles is currently available for the TMS FNC UI Pack (v3.1) only. The core styling mechanism is implemented in TMS FNC Core (v2.3) and will be further pushed through other FNC components such as the TMS FNC Dashboard Pack in the future. FNC Styles targets 6 styles.

  • Default
  • Dark
  • Light
  • Office 2019 White
  • Office 2019 Black
  • Office 2019 Gray

Getting Started

Designtime

To start styling the FNC components, drop a TMS FNC UI Pack component on the form, right-click the
component and select the Style->Manager option from the context-menu.

This will prompt you with a dialog that initially shows the built-in styles. Built-in styles are stored in
the TMSFNCStylesResources.res file, separately available.

Click on a style to select it and click on the “Apply” button to apply the style to each component on
the form. You can also load your own style file by clicking on the “Open” button. The built-in styles
are combined style files containing styles from multiple components. The corresponding style files for the built-in styles are included in the Styles subfolder in TMS FNC Core. When right-clicking on the component, you can save your own style to a style file. This separate component style can be loaded and
managed via the style manager. Please note that individual component styles for the built-in styles are not available separately.

Runtime

To start with runtime loading, add {$R ‘TMSFNCStylesResources.res’} to your application first, so
built-in styles are available.
To load a style at runtime there are several options. When you have a style file, you can either load
it via [Component].LoadSettingsFromFile, or via the TTMSFNCStylesManager. The
TTMSFNCStylesManager instance also allows you to load files from a resource (via the StyleResource
property), from a file (LoadStyleFromFile), a stream (LoadStyleFromStream), or plain text
(LoadStyleFromText). The format for loading the resource through LoadFromResource or the
StyleResource property can be found in the manager.
The built-in style has the format TTMSFNCStyle_[StyleName].style, with [StyleName] being the
actual style name of the file and can be loaded by using the code below:

implementation

{$R 'TMSFNCStylesResources.res'}
TMSFNCStylesManager1.LoadStyleFromResource(‘TTMSFNCStyle_FNC_Dark’);

Or

TMSFNCStylesManager.StyleResource := ‘FNC_Dark’;

JSON Formatting

The style mechanism is based on the persistence interfaces that already exist in FNC. It will
generate JSON that only contains the necessary information based on the components
appearance properties. The detection happens automatically, but finetuning can be done with
the IsAppearanceProperty virtual. Some components need to save more information than
others. Even custom components that you have designed will be styleable through the
ITMSFNCPersistence interface, when inheriting from TTMSFNCCustomControl.

{
"$type":"TTMSFNCCalendar",
"Color":"#484848",
"DateAppearance":{
"$type":"TTMSFNCCalendarDateAppearance",
"BadgeFill":{
"$type":"TTMSFNCGraphicsFill",
"Color":"#FF0000",
"ColorMirror":"gcNull",
"ColorMirrorTo":"gcNull",
"ColorTo":"#808080",
"Kind":1,
"OnChanged":null,
"Opacity":1,
"Orientation":1,
"Texture":"",
"TextureMode":2
},
"BadgeFont":{
"$type":"TTMSFNCGraphicsFont",
"Color":"#FFFFFF",
"Family":"Segoe UI",
"Name":"Segoe UI",
"OnChanged":null,
"Size":10,
"IsFMX":true,
"Style":0
},
"BadgeStroke":{
"$type":"TTMSFNCGraphicsStroke",
"Color":"#FF0000",
"Kind":1,
"OnChanged":null,
"Opacity":1,
"Width":1
},
"DateAfterFill":{
"$type":"TTMSFNCGraphicsFill",
"Color":"#484848",
...

WEB Support

In WEB, styles are also supported. At designtime, the same methods can be used as you would apply in
VCL or FMX. At runtime, there is no LoadStyleFromResource available as TMS WEB Core does not
support resources, but there is a LoadStyleFromURL available in the TTMSFNCStylesManager that
allows you to load the styles from an URL. You can copy the style files that are necessary for your
application from the Styles sub folder in the source folder, available after installation.
Alternatively, you can also use the WebFilePicker component to select a file and load it as a style.
Below is a sample that demonstrates both techniques.

procedure TForm1.WebButton1Click(Sender: TObject);
begin
WebFilePicker1.Files[0].GetFileAsText;
end;
procedure TForm1.WebButton2Click(Sender: TObject);
begin
TMSFNCStylesManager1.LoadStyleFromURL('http://localhost:8888/Project1/TTMSFNCStyle_FNC_Dar
k.style');
end;
procedure TForm1.WebFilePicker1GetFileAsText(Sender: TObject;
AFileIndex: Integer; AText: string);
begin
TMSFNCStylesManager1.LoadStyleFromText(AText);
end;

Create your own style!

When inheriting from TTMSFNCCustomControl, the SaveSettingsToFile (coming from the ITMSFNCPersistence interface) is available to allow you to save the appearance properties to a style file. The base implementation is automatically detecting appearance properties, but additional properties can be added by overriding the IsAppearanceProperty function when you are applying FNC Styles to your own component. Through the TTMSFNCStylesManager, styles can be combined to a single style file that can then be loaded again. Create your own style and don’t be afraid to share. It might end up as a built-in style in the future!

Read More

Read More

TIdTCPClient Android not connecting to TIdTCPServer on local PC

Using Rad Studio (Delphi) 10.3.2, I have a TCPServer app on my local PC and created an app running on an Android phone to connect using the local IP address, but I get "Connect timed out". Both are connected to the same local network via 192.168.1.x range addresses. I can ping the phone device from my PC. I can connect to the TCPServer from another Windows PC on the network, so that's working. I don't understand what could be getting in the way. Is there something in Android preventing connections to a local IP address? I have the Android Manifest for my app allowing INTERNET access but not sure if there is another one for accessing the local network. I also tried connecting from the phones Chrome browser but nothing arrives at all at the TCP Server.
Read More