Recent

Author Topic: Android:call one form from another  (Read 877 times)

mirce.vladimirov

  • Sr. Member
  • ****
  • Posts: 266
Android:call one form from another
« on: August 19, 2025, 03:49:29 pm »
Please what is the proper way that one form can be called and shown on certain user action,  do something in the called form and then go back to the form that called it ?
One more: Is there a way that only a procedure or function on form2 can be called from form1 without showing form2 ?

God knows I was messing for two days with DeepSeek and ChatGPT but so far i am getting more and more bullshit. My best result was showing called form over the one that called it, so nothing can be read.

I work under win10, i use Lazarus 3.4 + LAMW, I do application programing with Lazarus for use under Linux and Windows  since 2009 but never for Android so far.
« Last Edit: August 19, 2025, 03:52:06 pm by mirce.vladimirov »

dseligo

  • Hero Member
  • *****
  • Posts: 1601
Re: Android:call one form from another
« Reply #1 on: August 19, 2025, 08:32:16 pm »
My best result was showing called form over the one that called it, so nothing can be read.

You are probably on a good way. Set BackgroundColor property of the form(s).

Lazarinr

  • New member
  • *
  • Posts: 9
Re: Android:call one form from another
« Reply #2 on: September 01, 2025, 02:01:46 am »
1. Add the name of unit2 in Uses:

Code: Pascal  [Select][+][-]
  1. uses
  2.   {$IFDEF UNIX}{$IFDEF UseCThreads}
  3.   cthreads,
  4.   {$ENDIF}{$ENDIF}
  5.   Classes, SysUtils, AndroidWidget, Laz_And_Controls, framelayout, stablayout,
  6.   tablelayout, linearlayout, unit2;

2. To call the form when the user clicks the button:

Code: Pascal  [Select][+][-]
  1. procedure TAndroidModule1.Button1Click(Sender: TObject);
  2. begin
  3.    // created the form if not exist
  4.    if AndroidModule2 = nil then gApp.CreateForm(TAndroidModule2,AndroidModule2);
  5.    // Show the form
  6.    AndroidModule2.InitShowing;
  7. end;

3. Executes a procedure that is in form2 without having to open it:

Code: Pascal  [Select][+][-]
  1. procedure TAndroidModule1.Button2Click(Sender: TObject);
  2. begin
  3.    // created the form if not exist
  4.    if AndroidModule2 = nil then gApp.CreateForm(TAndroidModule2,AndroidModule2);
  5.    // Excute procedure
  6.    AndroidModule2.ProcedureOfForm2;
  7. end;

 

TinyPortal © 2005-2018