Category: StackOverflow

How to make a tab invisible, but not the sheet that would show when the tab is selected? – Delphi FireMonkey

I want to be able to open tabA from a button on tabB. But I don't want the user to be able to open tabA, apart from using that button. However if you set the TabA.Visible := False it sets the tab and the tab sheet as not visible. Is there any way around this? My idea would be to cover tabB with a blank white image when I need tabA showing, and when I need tabB showing just hide all the tabA controls. Would this be the best thing to do for this issue?
Read More

Why does accessing a fmx controls "height" in "DoRealign" crash the Delphi designer?

Writing my own slider control in Firemonkey that works fine at runtime but will often crash the designer. I have tracked the crash down to accessing the controls Height called from my overridden "DoRealign". It does not crash all of the time and often pressing "OK" will allow me to continue designing the form but it never crashes at runtime. My only work around is to simply exit this routine on the condition "csDesigning in ComponentState". I am curious to know where I am going wrong with my component design. procedure TLFFader.DoRealign; var vI, T: TFmxObject; NewSize: Single; begin inherited; if not FDisableAlign then begin FDisableAlign := True; try T := FindStyleResource('vtrack'); if Assigned(T) and (T is TControl) then TControl(T).Visible := True; if Assigned(T) and (T is TControl) and (Max > Min) then begin vI := FindStyleResource('vindicator'); if Assigned(vI) and (vI is TControl) then begin NewSize := (TControl(T).Height - TControl(T).Padding.top - TControl(T).Padding.bottom - TControl(vI).Margins.top - TControl(vI).Margins.bottom) * FValueRange.RelativeValue; TControl(vI).Height := Round(NewSize); TControl(vI).Visible := TControl(vI).Height > 2; end; end; if assigned(FThumb) then begin FThumb.Width := Width; FThumb.Height := FThumbHeight; FThumb.Position.X := 0; FThumb.Position.Y := (Height - FThumbHeight) * (1-FValueRange.RelativeValue); FThumbText.Text := FPercentPrefix + IntToStr(Round(FValueRange.RelativeValue * 100))+'%'; end; finally FDisableAlign := False; end; end; end;
Read More

Cannot assign TBitmapOfItem to TClipBoard?

I need to crop pdf and create word document of that cropped png image by pasting that in word document. I am using Firemonkey Platform this is code : procedure TForm2.Button1Click(Sender: TObject); begin ShellExecute(FormToHWND(Self),'open',PChar(GetCurrentDir+'\cairo.exe') ,PWideChar('-opw '+Edit1.Text+ ' -cropbox -png -x 64 -y 215 -W 144 -H 375 -r 167 '+ PdfFile+' tools/card'),'',SW_Hide); Sleep(500); Image1.Bitmap.LoadFromFile(Output); end; procedure TForm2.Button2Click(Sender: TObject); begin ClipBoard.Assign(Image1.Bitmap); end; procedure TForm2.FormCreate(Sender: TObject); begin Output:= GetCurrentDir+'\tools\card-1.png'; end; Clicking on button2 pops the error Cannot assign TBitmapOfItem to TClipBoard. How to copy the image to clipboard and create word document (don't know much about it) ?
Read More

Rad Studio 10.3.1 GetExceptionSeverity error

My application worked fine with RAD Studio 10.3, but after I upgraded to the 10.3.1 update, I receive the error message `GetExceptionSeverity - not found` I have searched for information about that message in RAD Studio & Firemonkey Help System and also in the Web, but found nothing on this issue. My machine configuration: AMD Athlon II X2 Processor 8 GB installed memory 64 bits OS Windows 10 Pro Does anybody know what causes this kind of error and how to fix it?
Read More

how to know if one of my childs get some mouse events?

If I m a custom Tcontrol and I want to know if one of my childs (or childs of my childs, etc..) get some mouse events (like mouseDown, MouseUp, MouseMove, etc..) How I can do under Firemonkey? I think it's impossible (except playing with CMGesture but this is different "flow" than the one used by mouseDown, MouseUp, MouseMove, etc) In a nutshell is there any mechanism to propagate mouse events in firemonkey ?
Read More

Delphi 10.3 RIO ImageList causes crash on Android 5.1.1

I recently moved from Delphi Berlin to Delphi Rio since I need the new Android stuff. Trough trial and error I figured out that the ImageList I have in my DataModule is causing a problem - It starts and stays at the Splash Screen. I've created a new Multi-Device application without anything, put a SpeedButton (SB_BTN1) and a ImageList on the main form. Loaded a small BMP image to the ImageList and attached it to the SpeedButton (SB_BTN1) - which causes for it to stay on the splash screen and not load. BUT if I add another SpeedButton (SB_BTN2) - and set (SB_BTN1) invisible, and on the (SB_BTN2) - code I add that it makes the (SB_BTN1) visible, the form gets past the loading screen and everything works. I aswell have attached it to Logcat to see what it says - to no success, it doesn't show any error. My Andrid SDK API Level is 26 and NDK Level is 14 -- If this helps in any way EDIT: Forgot to mention, that the sample: "ImageListDemo" also does this. EDIT-2: So I aswell tried to do a fresh install - I reseted my whole pc, and I upgraded from 10.3 to 10.3.1 - still the same problem.
Read More

GetAccounts for Android (target 26) using Delphi 10.3 [on hold]

I'm using Delphi 10.3 for developing android application. I need to get the available account details in the mobile. I have provided the permission for GetAccounts and how can I get the available account details? Previously I have tried out the following code: function GetAccountEmails: TStringList; var jAm: JAccountManager; accounts: TJavaObjectArray<JAccount>; jAcc: JAccount; begin Result := TStringList.Create; jAM := TJAccountManager.JavaClass.get(SharedActivityContext); if jAM <> nil then begin accounts := TJavaObjectArray<JAccount>.Wrap(jAM.getAccountsByType(StringToJString('com.google'))); if accounts <> nil then begin //CommonFuncsProcs.DisplayThreadedMessage(IntToStr(accounts.Length)); //mmLog.Lines.Add('Length Accounts: ' + IntToStr(accounts.Length)); //SetLength(Result, accounts.Length); if accounts.Length > 0 then begin jAcc := accounts.Items[0]; //mmLog.Lines.Add(JStringtoString(jAcc._Getname)); Result.Add( JStringtoString(jAcc._Getname) ); end else begin //mmLog.Lines.Add('no accounts available'); end; end; end else begin //mmLog.Lines.Add('no accounts found'); end; end; But this code does not work for the Android targeting 26. Is there any code to implement Delphi 10.3 for targeting Android 26?
Read More

Splash Screen with message in FireMonkey

I want a splash screen with a tLabel on it. This tLabel will be used to show the progress of the initialization tasks for the application, such as: "Starting up databases", "Setting up forms", etc. I have tried the following code, in the project file: Application.Initialize; FormSplash := TFormSplash.Create( Application ); FormSplash.OpenSplash; FormSplash.ShowProgress; Application.Run; It shows the splash-screen properly. However, the tLabel that should show each text posted to it in sequence when the splash-screen appears, shows only the last text posted. This happens even if I put a Sleep command after each text posted. I tried to post the texts on the FormCreate, FormShow and FormActivate events with the same result. The application is for Windows 32.
Read More

Delphi FMX TIntegerColumn SetValue: Invalid Typecast

I have an FMX TGrid with a checkbox column, a string column and an integer column. I've managed to make the string column and checkbox columns work. But when I change the integer column, the TValue passed to the SetValue command does not seem to be passing an integer. I've set up a string column (StrNumber) to do what I want, but if I try to handle the value from the IntegerColumn I get a ClassCastException. I've tried the various number types as well Value.AsBoolean, Value.AsString, etc. but I always get Invalid Typecast. procedure MyApp.SuppGridSetValue(Sender: TObject; const ACol, ARow: Integer; const Value: TValue); begin if SuppGrid.Columns[ACol] = StrNumber then Caption := IntToStr(StrToIntDef(Value.AsString,1)); else if SuppGrid.Columns[ACol] = Number then Value.AsInteger; //see note end; NOTE: In the code above "Value.AsInteger" wouldn't get used even if it did work but this demonstrates clearly that the issue isn't some other call creating the ClassCastException. When debugging the inspection window doesn't offer much either. It does appear that the value is coming in as all 0s or nils, no matter what I try to set it as. (FData:(FTypeInfo:$4012BC; FValueData:TValueDataImpl($B7D78E8) as IValueData; FAsUByte:0; FAsUWord:0; FAsULong:0; FAsObject:nil; FAsClass:nil; FAsSByte:0; FAsSWord:0; FAsSLong:0; FAsSingle:0; FAsDouble:0; FAsExtended:0; FAsComp:0; FAsCurr:0; FAsUInt64:0; FAsSInt64:0; FAsMethod:(Code:nil; Data:nil); FAsPointer:nil)) That is, I've tried (in the GetValue) setting a direct simple value: Value := 42; Also using a From call: Value := TValue.From<Integer>(42); //doesn't work for an integer column In these cases the value "42" shows up in the right column, but the value passed to the SetValue routine does not seem to have either the original value of 42, or the user's data.
Read More

When the application is closed, the Android Local service was stopped

I'm using Delphi 10.3 for developing android application and I have implemented Service to retrieve the data from Server. The thread was running properly but it closes when the app is closed. I have used the following code to run the service: DMService.StartCommand(); begin AddLog; //Log SampleThread := TThread.Create; Result := TJService.JavaClass.START_REDELIVER_INTENT; end; The same code worked fine in Delphi 10.1 (without mentioning the Android 26 as target version). Also I have tried using TTask but still the problem does not resolves. Also I have tried Result := TJService.JavaClass.START_STICKY;, but still the service closes. And after several analysis, I have analyzed after closing the host application the service, the Service starts again and the thread/Task initiated and the service was destroyed. Should I need to enable any special permission or while creating should I need to add more code. Currently, I'm using the following code for initiating the service from the host application: FLocalServiceConnection := TLocalServiceConnection.Create; FLocalServiceConnection.StartService('SCommuteSupervisorNotificationService'); Please help me to resolve this issue to run the service after the host app closes.
Read More

TChart not visible on Android

I'm using RAD Studio 10.2 With TeeChart components. I've made a simple TChart component with code shown below. Everything works fine when I compile and run my program on Windows, but when I try to run Android version, TChart component is not visible. No error, nothing, just not showing up. I've tried looking for answer (as I persume, there is some specific thing I should do to make the TChart show up on android) but I just can't find any relevant question. Thank you in advance for your help. Chart1.LeftAxis.Title.Caption:='A1 [-] , A2 [-]'; Chart1.BottomAxis.Title.Caption:='t [s]'; Series1.Title:='A1'; Series2.Title:='A2'; Chart1.Legend.Visible:=True; Chart1.Series[0].Clear; Chart1.Series[1].Clear; for i := 1 to num do Chart1.Series[0].AddXY(Tablica[0][i],Tablica[6][i]); for i := 1 to num do Chart1.Series[1].AddXY(Tablica[0][i],Tablica[7][i]);
Read More

Problem displaying hints in FMX Win32 application

I have an application where menu buttons are enabled or disabled depending on the active tab in a tab control. When the tab switches, the appropriate button(s) are enabled but when you first hover over a menu button the hint does not appear. However, after moving off the button and then back over it, the hint appears. The expected use of this form is to switch tabs and then selected a menu button, so this behavior will be very confusing to the user. This does not happen with the VCL but with FMX on Win32. I have tried several different workarounds (resetting the ShowHint property, trying to do something on OnMouseEnter). Currently running Delphi Rio on a Windows 10 PC. procedure TForm1.CheckBox1Change(Sender: TObject); begin Button1.Enabled := CheckBox1.IsChecked; end; procedure TForm1.FormCreate(Sender: TObject); begin Button1.Hint := 'Hint for button1'; Button1.ShowHint := true; end; Start a new application and drop a TButton and TCheckbox onto the form. Set the checkbox's onchange event. Run the program, hover to see the hint then click the checkbox to disabled and then enabled the button. Then hover over the button to see the effect - the hint will not appear on the first hover, only on subsequent hovers. Any idea of a workaround aside from developing my own hint code? Thanks, Pat
Read More