Recent

Author Topic: How I open form2  (Read 8468 times)

ilpo

  • Guest
How I open form2
« on: April 04, 2005, 07:15:42 pm »
Hi,

I am trying learn Lazarus (also pascal)
How I can open Form2 ?

I tried  
Form2.Show;
 and
Form2.ShowModal

Didn't work

How it happens ?

Is it any Lazarus training book for beginner or can I find somewhere else information regarding lazarus.

BR,
ilpo

Anonymous

  • Guest
How I open form2
« Reply #1 on: April 05, 2005, 05:49:22 pm »
I found solution
Next you can read what i did (for other beginers)

I added following things to Unit1:
-  Unit2 -> Uses section
-  Form2: TForm2; -> Var section
 

in Form1 I have TButton. When you click it following program start in unit1 and Form2 will open (you have to  make program to unit1)

procedure TForm1.TButtonClick(Sender: TObject);
begin
   Form2 := TForm2.Create(Application);
   Form2.Show;
end;


I hope that this help other beginers (sorry my english)

BR,
ilpo

marmin

  • Jr. Member
  • **
  • Posts: 86
    • http://www.naton.org
How I open form2
« Reply #2 on: April 05, 2005, 07:07:36 pm »
Of course one can type this in the Project Source (yourproject.lpr)
-----------------------------------------
program Project1;

{$mode objfpc}{$H+}

uses
  Interfaces, // this includes the LCL widgetset
  Forms
  { add your units here }, Unit1, Unit2;

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.CreateForm(TForm2, Form2);
  form2.visible:=true; // <------------ add this.
  Application.Run;

end.
-------------------------------------
Marmin^.Style
Location: Pointer Land!

matthijs

  • Hero Member
  • *****
  • Posts: 537
How I open form2
« Reply #3 on: April 06, 2005, 07:49:28 pm »
Marmin, unless you're more experienced, editing your lpr-file is not advisable. The way to call form2 from form1 is approximatly as ilpo said:
Code: [Select]

implementation
 
uses
  Unit2;
 
// More code
procedure TForm1.Button1Click(Sender: TObject);
begin
  Form2 := TForm2.Create(nil); // nil can be self aswell
  try
    Form2.ShowModal
  finally
    Form2.Free;
  end;
end;

For basic turorials on Lazarus you can have a look at the WiKi or look at delphi.about.com
What's in a sig? Would my posting look less if it didnot have a sig? (Free after William S.) :)

:( Why cannot I upload my own Avatar? :(

 

TinyPortal © 2005-2018