Category: StackOverflow

How to get the values of TListView selected item in Firemonkey Delphi Rio

I have a TListView populated with data from TFDQuery using Livebindings. I would like to get the values of the selected item like the item.text, itemheader.text, etc. I already figured out the selected item through listview1.itemindex but to get the values is a struggle to me. I am new with TListView and livebindings. I've spent over a day already looking for answers in the internet but looks too complicated for a very simple task. I know there is a straight method for this. Anyone care to share some clues (codes) on how to get the values of listview selected item? MORE DETAILS: I am using the Livebindings dynamic appearance. I created items for my query fields and map them accordingly to my TListView. It so happen that I did not use the default item.text but instead map fields to my created items like item.text1, item.text2, item.item3. Hence, this is the reason why I am not getting the caption from the formula given by MartynA below.
Read More

Open custom file type with my application under android [closed]

What I want: To be able to import my custom file by mail with my application from the preview button in GMail or when opening it in a file browser. I have added the intent-filter in the AndroidManifest.template.xml file: <intent-filter android:label="%activityLabel%"> <action android:name="android.intent.action.VIEW"/> <category android:name="android.intent.category.DEFAULT"/> <category android:name="android.intent.category.BROWSABLE"/> <data android:scheme="file" android:pathPattern=".*\\.ksm" android:mimeType="application/*"/> <data android:scheme="content" android:pathPattern=".*\\.ksm" android:mimeType="application/*"/> </intent-filter> But when i click the file with extension ksm in "My Files" i reciev the message: Search the Play Store? You don't have any apps that can open this type of file. You can search for one in the Play Store.
Read More

How to move to Next Tab upon selection of an Item in TListView in Firemonkey Delphi

I have TabControl with 2 TabItems for my mobile device development. The TabItem1 has a TListView for list of items populated using LiveBindings. Here, the TabItem2 should provide the details of the selected item in TabItem1 — no issues here. My question is — How to trigger the move from TabItem1 to TabItem2, during item selection, using a set of code in the TabItem1.OnItemClick event?
Read More

TCellReturnAction::GotoNextRow on android

i am developing an application that starts under windows and android. I want In a StringGrid that is editable. that if the user press enter under windows or Done under android, the cursor jumps to the next grid line. I use in the oncreate event of Form. SGBestDetail->Model->CellReturnAction= TCellReturnAction::GotoNextRow; It runs fine under windows. It jumps to next grid row but under android it do nothing.
Read More

Delphi FMXLinux cannot find -lcurl

I cannot link an application using FMXLinux because the linker cannot find the curl library (Delphi 10.3.3): [DCC Error] E2597 C:\Program Files (x86)\Embarcadero\Studio\20.0\bin\ld-linux.exe: error: cannot find -lcurl c:\program files (x86)\embarcadero\studio\20.0\lib\Linux64\debug\Linuxapi.Curl.o:Linuxapi.Curl:function Linuxapi::Curl::curl_global_init(int): error: undefined reference to 'curl_global_init' c:\program files (x86)\embarcadero\studio\20.0\lib\Linux64\debug\Linuxapi.Curl.o:Linuxapi.Curl:function Linuxapi::Curl::curl_global_cleanup(): error: undefined reference to 'curl_global_cleanup' c:\program files (x86)\embarcadero\studio\20.0\lib\Linux64\debug\Linuxapi.Curl.o:Linuxapi.Curl:function Linuxapi::Curl::curl_slist_append(curl_slist*, char*): error: undefined reference to 'curl_slist_append' c:\program files (x86)\embarcadero\studio\20.0\lib\Linux64\debug\Linuxapi.Curl.o:Linuxapi.Curl:function Linuxapi::Curl::curl_slist_free_all(curl_slist*): error: undefined reference to 'curl_slist_free_all' c:\program files (x86)\embarcadero\studio\20.0\lib\Linux64\debug\Linuxapi.Curl.o:Linuxapi.Curl:function Linuxapi::Curl::curl_easy_strerror(CURLcode): error: undefined reference to 'curl_easy_strerror' c:\program files (x86)\embarcadero\studio\20.0\lib\Linux64\debug\Linuxapi.Curl.o:Linuxapi.Curl:function Linuxapi::Curl::curl_easy_init(): error: undefined reference to 'curl_easy_init' c:\program files (x86)\embarcadero\studio\20.0\lib\Linux64\debug\Linuxapi.Curl.o:Linuxapi.Curl:function Linuxapi::Curl::curl_easy_setopt(void*, CURLoption): error: undefined reference to 'curl_easy_setopt' c:\program files (x86)\embarcadero\studio\20.0\lib\Linux64\debug\Linuxapi.Curl.o:Linuxapi.Curl:function Linuxapi::Curl::curl_easy_perform(void*): error: undefined reference to 'curl_easy_perform' c:\program files (x86)\embarcadero\studio\20.0\lib\Linux64\debug\Linuxapi.Curl.o:Linuxapi.Curl:function Linuxapi::Curl::curl_easy_cleanup(void*): error: undefined reference to 'curl_easy_cleanup' c:\program files (x86)\embarcadero\studio\20.0\lib\Linux64\debug\Linuxapi.Curl.o:Linuxapi.Curl:function Linuxapi::Curl::curl_easy_getinfo(void*, CURLINFO): error: undefined reference to 'curl_easy_getinfo' [DCC Fatal Error] F2588 Linker error code: 1 ($00000001) But on my ubuntu 19.10 system I can find the libcurl.so.4 in the folder usr/lib/x86-64-linux-gnu and this folder is synced in my Delphi SDK folder at C:\Users\MyUser\Documents\Embarcadero\Studio\SDKs\ubuntu19.10.sdk\lib\x86_64-linux-gnu UPDATED: If I rename manually the library file libcurl.so.4 to libcurl.so in the local ubuntu-SDK folder I can build my project. Do I need to install an older version of libcurl.so when using the delphi RTL library Linuxapi.Curl (e.g. used from System.Net.HttpClient.Linux)? Thank you for any hint!
Read More

Delphi RIO 10.3.1 FMX TListView ‘ItemClickEx’ fires 2 for single click

I'm trying to implement a 'toggle' function when clicking on a tlistview item. But when testing I notice that the click event get's fired 2 times with a single click / tap with IDENTICAL parameters.. I'm testing this for now on windows. Is this 'works as designed' ? I only added a listview to an empty form and implemented the 'ItemClickEx' event. I could not find a workaround way to my toggle..except implementing a timer that would keep track of the clicks and ignore a second click to soon... ( it seems the FMX framework also works with delayed events when looking at the stack trace ) I tested also the onitemclick event and this one DOES fire only once. .. so I could probably use it to implement simple workaround. But not nice, I need the 'ex' version as well as eventually, I need to add/delete items from my list which is recommended only from the 'ex' version, according to the documentation . Regards Dirk
Read More

Firemonkey TSpinBox height

I'm using C++ Builder 10.3 and my application is for Android, please note I'm very new to C++ Builder I'm trying to change the font size and height of a TSpinBox but i'm unable to change the height. I tried by best to port the following Delphi solution Firemonkey TEdit height but with no joy and i'm a total lose. AdjustFixedSize is declared private i dont think its being overridden, i have also tried creating a setter and calling it but yet again I was unable to get it to work. The biggest problem i have is my lack of C++ Builder knowledge. Header class TMySpinBox : public TSpinBox{ public: protected: virtual void AdjustFixedSize(const TControl Ref) ; }; CPP TMySpinBox::TMySpinBox() : TSpinBox(0){}; void TMySpinBox::AdjustFixedSize(const TControl Ref){ SetAdjustType(TAdjustType::None); Code TMySpinBox* SpinBox1 = new TMySpinBox(); SpinBox1->ControlType=TControlType::Platform; SpinBox1->Parent=Panel1->Parent; SpinBox1->Position->Y=16.0; SpinBox1->Position->X=16.0; SpinBox1->Min=2; SpinBox1->Max=99; SpinBox1->Font->Size=48; SpinBox1->Visible=true; SpinBox1->Value=2; SpinBox1->Align=TAlignLayout::None; SpinBox1->Height=100; Width=100;
Read More

What is the purpose of the ‘default’ platform marker in the list of tstylebook styles?

UPDATE : I made a new test project from scratch and this one DID apply the style inside the default platform marker on my mainform on windows and android, so the behaviour seen below might have something todo with rest of my project..I will do some more testing.( I have 1 style 'backgroundstyle' with rectangle brush fill color set to red ) UPDATE 2 : As soon as I added 1 specific style for e.g. android platform, none of the 'default' platform styles are considered anymore. Mainform suddenly not red anymore. In an heroic attempt to make a good styling design for my proof of concept multi-platform application, I'm was investigating the stylebook more closely. In general, separating the styling from the application logic is of course, very welcome. Although I'm more unsure if the fmx implementation of this principle is, sofar, optimal ( I'm losing myself in finding out which property of which styleresource I need to change to get what I want for anything beyond simple text or rectangles....but that might be up to me. ). I also understand that each target platform has it's own habits , and it's good practice to stick to them ( at least, if you want to be part of the hurd :-) . But I would say that , e.g. my main application colors is something that I decide, and should be consistent across platforms. It seems that in order to achieve that, I need to change that, possibly , on all the multiple individual style --resources-- ( everywhere a fill color is / might be specified in each of the 190 styles in the list and also in all the bitmaps in the bitmap map, and this for each scale and each sourcelinkname.. ) and , again, this for every target platform...The result is usually that I stick to the 'premium' out of the box styles :-) I had hoped that the 'default' platform marker would come to the rescue, and have this platform for all of the styles, and BY EXCEPTION, have only some platform specific styles repeated and changed, if really required on that platform. The documentation says : Note: There is also the "Default" platform marker. FireMonkey application loads > the Default style when the application cannot find the matching styles for the > current platform. But it doesn't seem to work this way. e.g. on android these default styles ( in runtime ) are always ignored and revert to the embedded platform specific style but in windows the styles are indeed used... ( in the IDE at design time, the same default style is shown as I expect for every platform that I choose -- ) In my example, I simply use the mainform background color ( = backgroundstyle brush fill color ) as an easy test setup : change the brush fill color on the 'backgroundstyle' for the default platform and run it on windows / android ). So what is the purpose of the default platform in the stylebook ? Is there something I do not understand ? Or is it a bug ? Is there a way to use one set of styles across platform via the stylebook ? If not, could you create and deploy a single style file and load at runtime and have it used on all platforms ? ( should there be a platform marker in this style file ? Would the styles be ignored if not 'really' the correct target platform ...) As a result, I find myself doing a lot of runtime styling in code afterall because I'm really sure it will be platform consistent, but that's not really the purpose I guess....
Read More

Delphi Debugger Error on Android 32-bit Platform

I am experiencing the same error when running with debugging on Android 32-bit platform while on 64-bit has no issue. The debugger just stopped and exited but the app was able to open on my device. Here's the error: Can't open socket: Permission denied. Exiting. I thought this was within my app codes error but when I tried a new blank multi-device form, I was getting the same error. So, I suspect this issue is not from my code but a Delphi debugger glitch. Has anyone here experienced the same issue and was able to resolve this. Otherwise, I will take my chances with Embarcadero support.
Read More

Error running Multi Device App on Android platform using TFDLocalSQL of Delphi Community Version

I am setting up a TLocalSQL for my multi device app. I understand this component is using SQLite as backend while having my MySQL database sitting on server remotely. On my datamodule I have setup the following: TFDGUIxWaitCursor TFDConnection — for MySQL server connection TFDPhysMySQLDriverLink — MySQL driver TFDQuery — MySQL table query TFDConnection — for my LocalSQL (SQLite backend) TFDPhysMySQLDriverLink — SQLite driver TFDLocalSQL — my LocalSQL to handle embedded database of my app with dataset TFDQuery above TFDQuery — my LocalSQL query My data module RME: unit Unit10; interface uses System.SysUtils, System.Classes, FireDAC.Stan.Intf, FireDAC.Stan.Option, FireDAC.Stan.Error, FireDAC.UI.Intf, FireDAC.Phys.Intf, FireDAC.Stan.Def, FireDAC.Stan.Pool, FireDAC.Stan.Async, FireDAC.Phys, FireDAC.Phys.MySQL, FireDAC.Phys.MySQLDef, FireDAC.FMXUI.Wait, FireDAC.Stan.Param, FireDAC.DatS, FireDAC.DApt.Intf, FireDAC.DApt, Data.DB, FireDAC.Stan.ExprFuncs, FireDAC.Phys.SQLiteDef, FireDAC.Phys.SQLite, Datasnap.DBClient, Datasnap.Provider, FireDAC.Comp.Client, FireDAC.Phys.SQLiteVDataSet, FireDAC.Comp.DataSet, FireDAC.Comp.UI; type TDataModule10 = class(TDataModule) con1: TFDConnection; dvr1: TFDPhysMySQLDriverLink; cur1: TFDGUIxWaitCursor; qry1: TFDQuery; loc1: TFDLocalSQL; dvr2: TFDPhysSQLiteDriverLink; con2: TFDConnection; qry2: TFDQuery; dsp1: TDataSetProvider; cds1: TClientDataSet; private { Private declarations } public { Public declarations } end; var DataModule10: TDataModule10; implementation {%CLASSGROUP 'FMX.Controls.TControl'} {$R *.dfm} end. Now, on my main form (below RME) where my TListView is sitting connects the TFDQuery of my TFDLocalSQL. unit Unit9; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.ListView.Types, FMX.ListView.Appearances, FMX.ListView.Adapters.Base, System.Rtti, System.Bindings.Outputs, Fmx.Bind.Editors, Data.Bind.EngExt, Fmx.Bind.DBEngExt, Data.Bind.Components, Data.Bind.DBScope, FMX.ListView; type TForm9 = class(TForm) lsv1: TListView; bdr1: TBindSourceDB; bdl1: TBindingsList; lcf1: TLinkListControlToField; private { Private declarations } public { Public declarations } end; var Form9: TForm9; implementation uses Unit10; {$R *.fmx} end. I ran it in Windows 64-bit platform without any issue. But when I tried it on my Android device platform, I am getting the following error: [DCC Fatal Error] dm_u.pas(10): F2613 Unit 'FireDAC.Phys.MySQL' not found. I am a bit confused because this is the purpose of TFDLocalSQL. It should handle different sources of data, be it coming from different servers, xml, etc and embed it in your application using the SQLite database. I hope my level of understanding got it right. Now, I am stuck on how to get around with the error. I cannot change the driver because my source data is actually from MySQL. Can anybody enlighten me more about TFDLocalSQL. It is my first time to use it and it serves well with my purpose. Am I missing something?
Read More

Deleting Buttons from TPanel, Firemonkey Edition

Using Delphi 10.2 (under Windows 10 "19H2"), I can create a new app, drop a single panel on it, and an action list with two items. Both items call the same routine whose purpose is to remove any buttons on the panel, and then add the new ones in: procedure TForm1.CreateNavPanelButtons(Action: TAction); begin NavPanel.RemoveObject(Btn); Btn.DisposeOf; //problem line Btn := MakeButton(Action); NavPanel.AddObject(Btn); end; (I've simplified to just use one button here.) Remove the existing button, add the new button in. If I call DisposeOf (to free up the button's memory), the Window object becomes unresponsive (can't resize, move, close) until I shift focus away from the app. I've included the entire code below: unit Unit1; 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, System.Actions, FMX.ActnList; type TForm1 = class(TForm) NavPanel: TPanel; ActionList: TActionList; acNextMenu: TAction; acBackToMainMenu: TAction; procedure FormCreate(Sender: TObject); procedure acNextMenuExecute(Sender: TObject); private { Private declarations } public Btn: TButton; procedure CreateNavPanelButtons(Action: TAction); end; var Form1: TForm1; implementation {$R *.fmx} function MakeButton(A: TAction): TButton; begin Result := TButton.Create(nil); Result.Action := A; Result.Text := (A as TAction).Text; end; procedure TForm1.acNextMenuExecute(Sender: TObject); begin CreateNavPanelButtons(acBackToMainMenu); end; procedure TForm1.CreateNavPanelButtons(Action: TAction); begin NavPanel.RemoveObject(Btn); Btn.DisposeOf; Btn := MakeButton(Action); NavPanel.AddObject(Btn); end; procedure TForm1.FormCreate(Sender: TObject); begin CreateNavPanelButtons(acNextMenu); end; end. Here's the form: object Form1: TForm1 Left = 0 Top = 0 Caption = 'Form1' ClientHeight = 480 ClientWidth = 640 FormFactor.Width = 320 FormFactor.Height = 480 FormFactor.Devices = [Desktop] OnCreate = FormCreate DesignerMasterStyle = 0 object NavPanel: TPanel Align = Top Size.Width = 640.000000000000000000 Size.Height = 73.000000000000000000 Size.PlatformDefault = False TabOrder = 0 end object ActionList: TActionList Left = 392 Top = 192 object acNextMenu: TAction Category = 'Navigation' Text = 'NextMenu' OnExecute = acNextMenuExecute end object acBackToMainMenu: TAction Category = 'Navigation' Text = 'Back To &Main Menu' OnExecute = FormCreate end end end
Read More