Category: StackOverflow

FMX Bitmap Image Loading Fail from Socket Stream

I got some problems with the TImage component of loading bitmap from stream. When i call that my image loading like that. Normal Window Fullscreen Window Okay, but when i build my codes on VCL Application mode its working good. procedure SaveToStream(Stream: TStream; Bitm: TBitmap); var Surface: TBitmapSurface; begin Surface:= TBitmapSurface.Create; try Surface.Assign(Bitm); TBitmapCodecManager.SaveToStream(Stream, Surface, '.bmp'); finally Surface.Free; end; end; Calling like that, B := TBitmap.Create; BS:= TMemoryStream.Create; try B := ParseData((FData)); // my image data is converting from TByteArray to Bitmap now. Its working no problem. SaveToStream(BS, B); FrmScreenViewer.ImgScreen.Bitmap.LoadFromStream(BS); //FrmScreenViewer.ImgScreen.Bitmap:= B; //I tryed without SaveToStream method but same result. finally B.Free; BS.Free; end; Are there some limitations on the FMX side? Why isn't working? ParseData Function (I used RTC Framework and some variables are customizable like RTCByteArray) function ParseData(Data: RtcByteArray): TBitmap; var B: TBitmap; M: TRtcByteArrayStream; begin B := TBitmap.Create; M := TRtcByteArrayStream.Create(Data); try B.LoadFromStream(M); Result := B; finally M.Free; end; end;
Read More

Firemonkey TNotificationCenter did not work C++Builder 10.4

I am new to Firemonkey. I am using C++Builder 10.4 Sydney. The target platform is Android. My code is: ... unsigned short y, m, d, h, n, s, ms; StrToDate(date).DecodeDate(&y, &m, &d); // might be: 2020, 7, 9 StrToTime(time).DecodeTime(&h, &n, &s, &ms); // might be: 13, 01, 00, 000 TNotification *myNotification=NotificationCenter1->CreateNotification(); try{ myNotification->Number=1; myNotification->AlertBody="something"; myNotification->EnableSound = true; myNotification->Title = "alert"; myNotification->AlertAction = "GO"; myNotification->SoundName = my_soundname; myNotification->FireDate = System::Dateutils::EncodeDateTime(y, m, d, h, n, s, ms); myNotification->RepeatInterval=TRepeatInterval::Minute; NotificationCenter1->ScheduleNotification(myNotification); } __finally { myNotification->DisposeOf(); } When time is up, nothing happens. I tried adding Android Service to my project, but no dialog pops up (did 10.4 fixed dialog or is this a bug?). And I added the Android Service manually with linker libandroidService.a and System.Android.service.hpp, and put this code in the Form's OnCreate event: TLocalServiceConnection::StartService("MyProject"); But still, nothing happens. I tried PresentNotification(), just notified right now. Can anyone help me with this problem?
Read More

Delphi Firemonkey FMX Display double byte strings from MySQL

I'm trying to display double-byte characters in my firemonkey app - windows & android. Query1.SQL.Text:= 'SELECT ITEM_NAME_KR FROM items WHERE ItemID=1'; Query1.Open; showmessage( Query1.fieldbyname('ITEM_NAME_KR').AsString ); Edit1.Text := Query1.fieldbyname('ITEM_NAME_KR').AsString; The MySQL field is set to utf8 with utf8_unicode_ci encoding. I know this is correct because when I update it in MySQL Bench, it displays the double byte correctly in Bench. I've even tried adding a persistent field for WideString field for ITEM_NAME_KR but it gives me an error : "FDQuery1: Type mismatch for field 'ITEM_NAME_KR', expecting: wideString actual: String". I've searched quite a few articles but I can't see any special mention of how to display double-byte characters in firemonkey apps - both Windows / Android. Any ideas what I'm missing?
Read More

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

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