[Lazarus] Find Form instance with Title

2013-11-15 Thread Timothy Groves
Google has failed me on this one.  :(  I need to check to see if a 
dynamically created form (object) with a given title already exists 
within the application, and if so, to raise it to the front.


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Find Form instance with Title

2013-11-15 Thread K. P.
Look at your Screen object:

http://lazarus-ccr.sourceforge.net/docs/lcl/forms/tscreen.html

Check out FindForm and Forms



 Date: Fri, 15 Nov 2013 22:32:37 -0500
 From: the.tail.kin...@gmail.com
 To: lazarus@lists.lazarus.freepascal.org
 Subject: [Lazarus] Find Form instance with Title
 
 Google has failed me on this one.  :(  I need to check to see if a 
 dynamically created form (object) with a given title already exists 
 within the application, and if so, to raise it to the front.
 
 --
 ___
 Lazarus mailing list
 Lazarus@lists.lazarus.freepascal.org
 http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
  --
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Find Form instance with Title

2013-11-15 Thread Timothy Groves

On 13-11-15 11:13 PM, K. P. wrote:

Look at your Screen object:

http://lazarus-ccr.sourceforge.net/docs/lcl/forms/tscreen.html

Check out FindForm and Forms



 Date: Fri, 15 Nov 2013 22:32:37 -0500
 From: the.tail.kin...@gmail.com
 To: lazarus@lists.lazarus.freepascal.org
 Subject: [Lazarus] Find Form instance with Title

 Google has failed me on this one. :( I need to check to see if a
 dynamically created form (object) with a given title already exists
 within the application, and if so, to raise it to the front.

Thanks for the steer!  In case anyone cares, here's how I implemented this:

procedure TfrmVolume.lstVolumesDblClick (Sender : TObject );
var
  NewStoryForm : TfrmStory;
  FormCaption : string;
  index : integer;
  Present : boolean;
begin
FormCaption := 'Volume ' + Volumes.Current.VolumeName + ''; // 
The caption I want to search for/create.

  index := 0;
  Present := false;
  repeat
if (Screen.Forms [index].Caption = FormCaption) then
  Present := true
else
index += 1;
  until (Present or (index = Screen.FormCount));
  if (Present) then
Screen.Forms [index].BringToFront
  else begin
NewStoryForm := TfrmStory.Create (Application);
NewStoryForm.Caption := FormCaption;
NewStoryForm.Show;
  end;
end;

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus