Category: StackOverflow

What is Application icon size (83.5×83.5) for iOS?

In my Delphi Rio iOS project, when I go to Project options > Icons > Ipad I can see Application icon (83.5x83.5) but what does it mean 83.5x83.5? It's not possible to make an image of 83.5x83.5 pixels, so what is the desired pixel size? When I look the dimension of C:\Program Files (x86)\Embarcadero\Studio\20.0\bin\Artwork\iOS\iPad\FM_ApplicationIcon_83.5x83.5.png It is 83 x 83 pixels, not 83.5 x 83.5 Is there something wrong?
Read More

What’s wrong with my implementation regarding light status bar flag?

I was looking for a solution on a darker status bar foreground on a light (white) status bar background. I am using Delphi 10.3 (Rio) and an Android version 8.1.0 device. My code supposedly works based on Android samples I have looked. I have tried several Android references pertaining to the status bar. The following is my code that didn't work. I don't know what's missing. setStatusBarColor is working setSystemUiVisibility is not. procedure TfrmMain.FormCreate(Sender: TObject); var lbl: TLabel; uiOptions: Integer; begin CallInUIThread( procedure begin SharedActivity.getWindow.clearFlags(TJWindowManager_LayoutParams.JavaClass.FLAG_TRANSLUCENT_STATUS); SharedActivity.getWindow.addFlags(TJWindowManager_LayoutParams.JavaClass.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); SharedActivity.getWindow.setFlags(TJWindowManager_LayoutParams.JavaClass.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS, TJWindowManager_LayoutParams.JavaClass.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); uiOptions := SharedActivity.getWindow.getDecorView.getSystemUiVisibility(); SharedActivity.getWindow.getDecorView.setSystemUiVisibility(TJview.JavaClass.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); SharedActivity.getWindow.setStatusBarColor(TJcolor.JavaClass.BLACK); end); end;
Read More

ld: framework not found Bolts for architecture armv7

I try to compile in Delphi Rio a project that was working fine under Delphi tokyo. I can't because I always have this error : ld: framework not found Bolts for architecture armv7 But in the global delphi library path I have correctly set: C:\lib\ios\facebook\Bolts.framework that is the path where is located the Bolts framework: C:\lib\ios\facebook\Bolts.framework\Headers\... C:\lib\ios\facebook\Bolts.framework\Modules\... C:\lib\ios\facebook\Bolts.framework\Info.plist C:\lib\ios\facebook\Bolts.framework\Bolts What did I miss ? Note: If I move the C:\lib\ios\facebook\Bolts.framework\ dir inside the global PlateformSDKs dir then it works.
Read More

IdHTTP to ensure push data to Ubidots (FMX, WIN32)

I can push an encrypted piece of humidity data up to my Ubidots cloud database by simply loading the following url in a web browser: https://industrial.ubidots.com/api/v1.6/devices/MYDEVICENAME/?token=MYTOKENHERE&_method=post&humidity=15.9 When I do that, I get the success response in the browser window {"humidity": [{"status_code": 201}]} and the data shows up in my data table on Ubidots. Now, I want to do this from an FMX app (C++ on Win32) without a visible browser, and I would like to check that I get the nice "201" response code. I looked at this link and cobbled up the following line of code: Memo1->Text = IdHTTP1->Get("https://industrial.ubidots.com/api/v1.6/devices/MYDEVICENAME/?token=MYTOKENHERE&_method=post&humidity=6.9"); When I run it, I get a "Could not load SSL library" error message. How do I tell TIdHTTP to use SSL so it can handle the HTTPS? Is there a better, cleaner way to do this?
Read More

resource not found after subclassing firemonkey form

Please help. I'm working on a longstanding Delphi project with several firemonkey forms that I wanted to make resizable. I put the resizing-relevant code in a new form that descended from TForm, and changed my existing forms to descend from the new form. That seemed to work, but now it fails during compilation with errors like "resource TLessonStudent not found" Alarmingly, putting the code back the way it was before doesn't remove the error. What is happening? Is there some way to create a resource file the compiler will like? Thanks! Art I've tried adding and removing compiler directives such as {$R *.DFM} in various places. I also tried to put the code back the way it was before, with my forms once again descending directly from TForm. Still the same error. Here is how the new top level form is declared: type TFluentTutorForm = class(TForm) protected ... resizableLayout: TScaledLayout; procedure FormCreate(Sender: TObject); private ... function getScreenSize(var retWidth: integer; var retHeight: integer): boolean; public end; //TFluentTutorForm var fluentTutorForm: TFluentTutorForm; implementation {$R *.fmx} Here is one of my old forms, modified to descend from the one above type TLessonStudent = class(TFluentTutorForm) ... procedure FormCreate(Sender: TObject); private unitTester: IftUnitTester; public end; //TStudentForm var studentForm: TLessonStudent; implementation {the formCreate method shown above calls "inherited formCreate" on it's new parent, shown at top} And here is the part of the project code that creates the form: {$R *.res} begin Application.Initialize; Application.FormFactor.Orientations := [TFormOrientation.Portrait];// InvertedPortrait]; Application.CreateForm(TlessonStudent, studentForm); //<here!! Application.CreateForm(TClientModule1, ClientModule1); Application.CreateForm(TDataModule1, DataModule1); Application.CreateForm(TmemTableForm, memTableForm); Application.Run; end.
Read More

Event Handler for Dynamically Created TText array in FMX

I am creating an array of 81 (9x9) TText boxes in an android app. I need to find which box was touched to change the text. I followed the example at Event Handler for Dynamically Created CheckBox (Thanks Remy Lebeau) but I get the following two error msgs in C++ Builder 10.3. The messages are: "MouseUp is a protected member of Fmx::Controls::TControl" and a very long msg [bccaarm Error] MainFm.cpp(106): assigning to 'void (closure *)(System::Uitypes::TMouseButton, System::Classes::TShiftState, float, float) __attribute((pcs("aapcs-vfp")))' from incompatible type 'void (closure *)(__borland_class *System::TObject __strong, System::Uitypes::TMouseButton, TShiftState, float, float) __attribute((pcs("aapcs-vfp")))' Is there something I should do different in the creation of the TText to insure that it is a FMX control vs a ... ? The form is a multi-device form, not VCL. UPDATE: I had a head slap moment. I finally realized that I used the wrong event name. "MouseUp" as used in TextBoxMouseUp is NOT the event handler name; "OnMouseUp" is the correct one. That is, BAD: TextBox[i][j]->MouseUp = FmMain->TextBoxMouseUp; GOOD: TextBox[i][j]->OnMouseUp = FmMain->TextBoxMouseUp; Hope this helps someone else in the future. As always, Remy, your instructions are dead on. We all just have to read every single word.
Read More

SaveState exception: Cannot Create file, Operation not permitted

I test SaveState on my iPad, I follow exactly the same logic on the embarcadero SaveState example, but it throws an exception after saving data. However, the same logic tested on iOS Simulator is working fine. I am using Delphi 10.3.1 with an iPad iOS12.2 When I click the home button after the FormSaveState logic executed, the below exception occurred: Cannot create file ....... Operation not permitted The same logic tested on iOS Simulator is working fine. Any idea why this occurred and how to resolve? Thanks for any help!
Read More

ComboEdit – how refresh items on Popup event?

I've got a problem with ComboEdit on Android. I need add item to ComboEdit.Items in OnPopup event, but my item is visible after second shows popup. How refresh Items in OnPopup event? procedure TForm1.ComboEditPopup(Sender: TObject); begin ComboEdit1.Items.Add('MyItem'); // this item will by visible at next popup end; What I want achieve: Items: 'Aaa', 'Bla', 'Ble', 'Dee'. User writes 'Bl'. When he pushes Popup, ComboEdit will show him items: 'Bla', 'Ble' . My currently code: ComboEdit : TComboEdit; Items : TStringList; // around 1000 strings procedure TForm1.ComboEdit1Typing(Sender: TObject); var i : integer; begin ComboEdit.BeginUpdate; ComboEdit.Items.Clear; for i := 0 to Items.Count-1 do if AnsiStartsText(ComboEdit.Text,Items[i]) then ComboEdit.Items.Add(Items[i]); Items.EndUpdate; end;
Read More

How to obtain CFStringRef value from iOS API function in Delphi 10.3 Rio

Cannot obtain CFStringRef value from iOS API function (framework) in Delphi 10.3 Rio // external call bridge function to iOS: function MIDIObjectGetStringProperty(obj: MIDIObjectRef; propertyID: CFStringRef; out str: CFStringRef):OSStatus; cdecl; external libCoreMidi name _PU + 'MIDIObjectGetStringProperty'; Function MIDIObjectGetStringProperty (iOS CoreMIDI function) return in str:CFStringRef name of MIDI ports ... How can I obtain value of CFString variable in Delphi? In this example str:CFStringRef value? I try it in my func.: function getDisplayName(obj: MIDIEndpointRef):string; var EndPointName: CFStringRef; i:integer; begin //EndPointName:= nil; // when I assign nil value, function return i=-50 otherwise raise Access Violation error ... i := MIDIObjectGetStringProperty(obj, kMIDIPropertyDisplayName , EndPointName); --> AV error !!! //in EndPointName should be returned CFStringRef value from iOS getDisplayName := CFToDelphiString(EndPointName); // convert to string end; Probably EndPointName need to be allocated ... else I give AV error. Please got someone solution how obtain ANY CFStringRef value from iOS framework and convert to string? Thanx. Adds: I build crossplatform (iOS, Android, W64) app in Delphi Rio via FireMonkey frameforks api - for CoreMIDI I use this interface https://github.com/FMXExpress/ios-object-pascal-wrapper/blob/master/iOSapi.CoreMIDI.pas So the externall call and constants are defined in iOSapi.CoreMIDI there: function MIDIObjectGetStringProperty (obj: MIDIObjectRef; propertyID: CFStringRef; str: CFStringRef) : OSStatus; cdecl; external libCoreMIDI name _PU + 'MIDIObjectGetStringProperty'; and iOS pointer const: function kMIDIPropertyDisplayName: Pointer; begin Result := CocoaPointerConst(libCoreMIDI, 'kMIDIPropertyDisplayName'); end; Otherwies compiled app work on real iOS (iPad) very well (reading MIDI message from connected MIDI keyboard) based on this solution https://pjstrnad.com/reading-data-midi-keyboard-ios-probably-also-mac/ obj: MIDIObjectRef is source pointer from source:= MIDIGetSource(ci); Problem is calling API function MIDIObjectGetStringProperty. In pointer str: CFStringRef (EndPointName) should be VALUE of MIDIportNAME. I cannot obtain this value and parse to delphi string ... I tried declared this poiter CFStringRef as: var EndPointName: pointer; EndPointName1: array of Byte; EndPointName2: TBytes; EndPointName3: TPtrWrapper; M: TMarshaller; and construction as: SetLength(EndPointName1, 255); GetMem(EndPointName2,255); EndPointName3 := M.AllocMem(255); i := MIDIObjectGetStringProperty(obj, kMIDIPropertyDisplayName , @EndPointNameX); --> nothing works, AV error !!! I thing it must be solution how to obtain CFStringRef and convert to delphi string ...
Read More

Firemonkey: Soft Keyboard pops up when VKAutoShowMode is Never

I have a large firemonkey android application which is designed for use primarily on barcode scanner devices, but must also be usable on e.g. an android phone (for testing). When used on a barcode scanner device, which typically has a physical keyboard, we suppress the virtual keyboard by setting VKAutoShowMode to TVKAutoShowMode.Never. This works just fine for most of the Tedit components. However, for 1 or 2 of these - which are to all intents and purposes "the same" as the others - the virtual keyboard pops up when the key press is received from the physical keyboard. And furthermore, it is not easily dismissed by using the return key with KillFocusByReturn set on the relevant Tedit. I can work around the problem using the Android Language & input settings to effectively disable the virtual keyboard completely, but this is less than ideal as in some fields we do want the soft keyboard for simpler alpha input. I can also achieve a partial workaround by calling up our "HideVirtualKeyboard" routine within an onkeyup event for the problem Tedit(s), but this looks silly as the keyboard flashes up and then disappears. Also, if one then moves to another TTabItem within the application after giving focus to the problem Tedit, a key press on the physical keyboard will pop the virtual keyboard up and special action has to be taken to get rid of it. I would appreciate any suggestions.
Read More

How to fix, images loaded in multi thread sometimes don’t show up on the form

In my manga viewer i try to load a large number of images (around 200), i try loading these images inside an anonymous thread and when the loading finishes i call a Thread.synchronize, this works fine, but in some cases i keep seeing some images not drawn on the form (I think they are loaded because i can see the information about the image), how can i solve this? This issue only happens in multi thread so i decided to set the image visible to false and then at the end of the loading inside a Thread.synchronize turn the visible to true, i had hoped this would force some kind of refresh or redraw, but the problem i mentioned consists TThread.CreateAnonymousThread(procedure begin for imageIndex := 0 to fileList.count - 1 do begin filePath := fileList[imageIndex] //Please note that mImageList is an array of FMX.Objects.TImage //which was filled when the Form is created (I create 300 TImage //at Form create and later i load the images to the bitmap when //the user clicks on a new directory(Chapter) mImageList[imageIndex].beginUpdate(); try mImageList[imageIndex].loadFromFile(filePath); mImageList[imageIndex].tagString := filePath; mImageList[imageIndex].Scale := mImageScale; mImageList[imageIndex].Visible := false; except mImageList[imageIndex].EmptyBitmaps; end; mImageList[imageIndex].endUpdate(); end; TThread.Synchronize(nil, procedure var I: Integer; begin for I := Low(mImageList) to High(mImageList) do begin mImageList[I].Visible := true; end; end); end).Start; I expect that when i scroll down through the images loaded on the form, i can see them all and they all get drawn on the form properly.
Read More