Recent

Author Topic: Open a second form/window  (Read 14211 times)

Pascaluvr

  • Full Member
  • ***
  • Posts: 216
Open a second form/window
« on: October 23, 2011, 10:39:16 am »
Sorry, newbie to lazarus here.

I have managed to run a basic program, but now, on the click of a button I want to open a second (modal) window.  Help would be appreciated'

Thanks in advance
Windows 7, Lazarus 1.0.8, FPC 2.6.2, SQLite 3

Avishai

  • Hero Member
  • *****
  • Posts: 1021
Re: Open a second form/window
« Reply #1 on: October 23, 2011, 10:43:18 am »
First, you must add the Second Form unit to the Calling unit 'Uses' statement. Then add 'Form2.ShowModal;' to the button OnClick event.

Example:

Form1 is Unit1 and Form2 is Unit2
Add Unit2 to the 'Uses' statement of Unit1

procedure TForm1.Button1Click(Sender: TObject);
begin
  Form2.ShowModal;
end;
« Last Edit: October 23, 2011, 10:51:35 am by Avishai »
Lazarus Trunk / fpc 2.6.2 / Win32

Pascaluvr

  • Full Member
  • ***
  • Posts: 216
Re: Open a second form/window
« Reply #2 on: October 24, 2011, 01:41:13 am »
Great... thanks Avishai.  I looked everywhere to find how to do that... so simple when you know:)

Thanks again.
Windows 7, Lazarus 1.0.8, FPC 2.6.2, SQLite 3

Avishai

  • Hero Member
  • *****
  • Posts: 1021
Re: Open a second form/window
« Reply #3 on: October 24, 2011, 01:43:19 am »
Almost everything is simple once you know how :)  It's finding out how that is hard.
Lazarus Trunk / fpc 2.6.2 / Win32

 

TinyPortal © 2005-2018