Category: StackOverflow

Is there a way to select/highlight a Date Range/series using Delphi 10.3 FMX TCalendar (Or a similar component)?

I am looking for a way to highlight a range of dates between a given start date and end date using a TCalendar in a Delphi 10.3 FMX application. It is for visual purposes as the client selects a start and end date in seperate TDateEdit components. I have looked it up, but I can't seem to find anything that explains what I want to achieve. Does the TCalendar perhaps have a method that achieves this, or is there a possible work-around? I hope that my question was clear. Thank you in advance!
Read More

How to Repaint FMX Android components in Form in C++Builder 10.4?

I wrote a very simple FMX Adroid App, the function is: Show Form 2 then write something to record(include title and detail text), close Form 2 to Main Form, then make a checkbox in Main Form with the title we just recorded in Form 2. if user check the checkbox, then press "del" buttn then delete the record file and checkbox. the problem is: when closed Form 2 and in MainForm::OnActivate we can add a new checkbox for the record. if we checked checkbox then clicked delete, free the pointer of checked checkbox, the checkbox still in main form until I reopen the APP. I tried: Invalidate(); Application->ProcessMessages(); BeginUpdate(); EndUpdate(); Still can't work does anyone know what's going on ? why FMX TForm member has no "Repaint()" or "Update()" "Refresh()" ? just like VCL has.
Read More

TGrid not Working with iOS simulator — it just run briefly and gone after installation

Why all datagrid like as follows are failing in iOS Simulator without any error message. It just run and gone after installation. I could not find any documentation related to this failures. TGrid TMSFMXGrid TeeGrid But its running perfectly fine in windows. Not sure with Android. Haven't tried yet. My only concern now is with iOS. All the type of grids not working. I did some basic RME TGrid sample in multi-device application for reference: PROCEDURE unit Unit9; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, System.Rtti, FMX.Grid.Style, 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.SQLite, FireDAC.Phys.SQLiteDef, FireDAC.Stan.ExprFuncs, FireDAC.FMXUI.Wait, FireDAC.Stan.Param, FireDAC.DatS, FireDAC.DApt.Intf, FireDAC.DApt, Data.Bind.EngExt, Fmx.Bind.DBEngExt, Fmx.Bind.Grid, System.Bindings.Outputs, Fmx.Bind.Editors, Data.Bind.Components, Data.Bind.Grid, Data.Bind.DBScope, Data.DB, FireDAC.Comp.DataSet, FireDAC.Comp.Client, FMX.Controls.Presentation, FMX.ScrollBox, FMX.Grid; type TForm9 = class(TForm) grd1: TGrid; conSqlite_demoConnection: TFDConnection; qryCustomersTable: TFDQuery; bdr1: TBindSourceDB; bdl1: TBindingsList; lnkgrdtdtsrcBindSourceDB: TLinkGridToDataSource; private { Private declarations } public { Public declarations } end; var Form9: TForm9; implementation {$R *.fmx} end. FMX FILE object Form9: TForm9 Left = 0 Top = 0 Caption = 'Form9' ClientHeight = 480 ClientWidth = 289 FormFactor.Width = 320 FormFactor.Height = 480 FormFactor.Devices = [Desktop] DesignerMasterStyle = 0 object grd1: TGrid Align = Client CanFocus = True ClipChildren = True Size.Width = 289.000000000000000000 Size.Height = 480.000000000000000000 Size.PlatformDefault = False TabOrder = 0 RowCount = 91 Viewport.Width = 269.000000000000000000 Viewport.Height = 439.000000000000000000 end object conSqlite_demoConnection: TFDConnection Params.Strings = ( 'ConnectionDef=SQLite_Demo') Connected = True LoginPrompt = False Left = 118 Top = 206 end object qryCustomersTable: TFDQuery Active = True Connection = conSqlite_demoConnection SQL.Strings = ( 'SELECT * FROM Customers') Left = 118 Top = 254 end object bdr1: TBindSourceDB DataSet = qryCustomersTable ScopeMappings = <> Left = 128 Top = 224 end object bdl1: TBindingsList Methods = <> OutputConverters = <> Left = 20 Top = 5 object lnkgrdtdtsrcBindSourceDB: TLinkGridToDataSource Category = 'Quick Bindings' DataSource = bdr1 GridControl = grd1 Columns = <> end end end UPDATE 1 I my case above I used the LiveBindings but this error is true also if used through Datasource all of the 3 types of grid components. UPDATE 2 If I set to false both fdconnection and fdquery, it works. And, if I set to true only the fdconnection, again its not working. I suspect the issue emanates from the connection itself and I also want to believe its coming from the dataset also.
Read More

App hangs by calling same Form 5 times. First 4 times work very nice, fifth time app hangs

I just started developing a mobile app which has two forms, FRM_Main (Main Form) and FRM_Party (Party Form). We can open FRM_Party from FRM_Main by clicking on an Image. Code on Image is: procedure TFRM_Main.IMAGE_PartyClick(Sender: TObject); begin FRM_Party := TFRM_Party.Create(Application); FRM_Party.Show; end; Now, when FRM_Party calls the OnActivate event, I am loading some data in a TMSFMXTableView. That code is: procedure TFRM_Party.FormActivate(Sender: TObject); var TableView : TTMSFMXTableViewItem; I : Integer; begin if Class_My_Pro_and_func.Func_DataBaseConnection then // Checks wethere database connection is active or not if not then it connect with database and returns bool value. Begin UniQuery.Close; UniQuery.SQL.Clear; UniQuery.SQL.Text := 'select * from db_stock.tbl_party where Reg_ID = :Reg_ID and Party_Delete <> :Party_Delete order by Party_Name '; UniQuery.ParamByName('Reg_ID').AsInteger := d_Glob_Reg_ID; UniQuery.ParamByName('Party_Delete').AsString := 'F'; UniQuery.Open; TABLEVIEW_Party.BeginUpdate; if UniQuery.RecordCount > 0 then begin for I := 1 to UniQuery.RecordCount do begin TableView := TABLEVIEW_Party.Items.Add; TableView.Caption := UniQuery.Fields[1].AsString; TableView.Description := UniQuery.Fields[2].AsString + ' = ' + UniQuery.Fields[3].AsString; TABLEVIEW_Party.EndUpdate; UniQuery.Next; end; end else ShowMessage('No recored Found.'); End end; On FRM_Party is a Back button which takes the user to FRM_Main. This button code is: procedure TFRM_Party.BTN_Party_BackClick(Sender: TObject); begin try UniQuery.Connection.Close; // Closing Query connection DB_Connection.Disconnect; // Disconnecting database FreeAndNil(FRM_Party); Close; except on E: Exception do ShowMessage(E.Message); end; end; Apart from the above code, nothing else is written on FRM_Party. Now, the thing is that when I am running the application on mobile and opening/closing FRM_Party again and again, the first 4 times FRM_Party works very nice, but on the fifth time FRM_Party opens properly, but when closed the app hangs. I tried so many times by closing and opening the app. Every time the result is the same. Can anyone help me?
Read More

How can Android BLE read more than 20 bytes in Delphi FMX 10.3 API is(API 29)

in Delphi FMX 10.3 now i can scan BLE deveice and can connect it ,also can receive data ,but when senddata more than 20 bytes ,the app cannot receive data. i know Modify the MTU >20 ,it will work ok in Android studio it Easy to implement, but in Delphi fmx can not find any supports Android studio sample private void setMtu(int setMtu) { BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE); BluetoothAdapter bluetoothAdapter = bluetoothManager.getAdapter(); bluetoothAdapter.startLeScan(new BluetoothAdapter.LeScanCallback() { @Override public void onLeScan(BluetoothDevice device, int rssi, byte[] scanRecord) { device.connectGatt(DemoActivity.this, true, new BluetoothGattCallback() { @Override public void onServicesDiscovered(BluetoothGatt gatt, int status) { super.onServicesDiscovered(gatt, status); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (setMtu > 23 && setMtu < 512) { gatt.requestMtu(setMtu); } } } @Override public void onMtuChanged(BluetoothGatt gatt, int mtu, int status) { super.onMtuChanged(gatt, mtu, status); mMtu = mtu; if (BluetoothGatt.GATT_SUCCESS == status && setMtu == mtu) { LogUtils.d("MTU change success = " + mtu); } else { LogUtils.d("MTU change fail!"); } } }); } }); } but in Delphi How to implement?
Read More

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

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