Recent

Author Topic: Creating multiple (maybe hundreds) of almost-identical TForms  (Read 11434 times)

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Creating multiple (maybe hundreds) of almost-identical TForms
« Reply #15 on: September 08, 2014, 06:45:55 pm »
Ok, i think i have almost everything ready.

One more thing. How i can bringtofront a specific form that already exist?

copyform[number].show;
copyform[number].bringtofront;
copyform[number].visible := true;

All  give me errors SIGSEGV.  :(

That means that the specific cell is empty or points to an invalid address
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

minesadorada

  • Sr. Member
  • ****
  • Posts: 452
  • Retired
Re: Creating multiple (maybe hundreds) of almost-identical TForms
« Reply #16 on: September 08, 2014, 08:28:23 pm »
For a dynamic form without resources Myform[index].CreateNew(nil) would be better?
GPL Apps: Health MonitorRetro Ski Run
OnlinePackageManager Components: LazAutoUpdate, LongTimer, PoweredBy, ScrollText, PlaySound, CryptINI

Fred vS

  • Hero Member
  • *****
  • Posts: 3168
    • StrumPract is the musicians best friend
Re: Creating multiple (maybe hundreds) of almost-identical TForms
« Reply #17 on: September 08, 2014, 09:39:49 pm »
Quote
All  give me errors SIGSEGV.  :(

=>
Code: [Select]
if assigned(copyform[number]) then
  begin
copyform[number].show;
copyform[number].bringtofront;
copyform[number].visible := true;
end;
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

torbente

  • Sr. Member
  • ****
  • Posts: 325
    • Noso Main Page
Re: Creating multiple (maybe hundreds) of almost-identical TForms
« Reply #18 on: September 08, 2014, 10:52:10 pm »
Ok, i think i have almost everything ready.

One more thing. How i can bringtofront a specific form that already exist?

copyform[number].show;
copyform[number].bringtofront;
copyform[number].visible := true;

All  give me errors SIGSEGV.  :(

That means that the specific cell is empty or points to an invalid address

You were rigth, i was using a bad counter to check it. Fixed.
Noso Cryptocurrency Main Developer
https://github.com/DevTeamNoso/NosoWallet

bylaardt

  • Sr. Member
  • ****
  • Posts: 309
Re: Creating multiple (maybe hundreds) of almost-identical TForms
« Reply #19 on: September 13, 2014, 05:46:15 am »
Forget arrays!!!
use a parental control to all this forms,
something like this
Code: [Select]
var
   MyParent:TComponent;
begin
  MyParent:=TComponent.create(application);
  CopyForm.create(MyParent);
  CopyForm.create(MyParent);
  CopyForm.create(MyParent);
 
  CopyForm(MyParent.Components[0]).caption:='First Form';
  Shomessage('I Have '+inttostr(MyParent.componentCount)+' copyforms actives')
;end;

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Creating multiple (maybe hundreds) of almost-identical TForms
« Reply #20 on: September 13, 2014, 09:26:37 am »
Your naming here is confusing.
MyParent is not the parent of the created forms, but their owner.

In fact, MyParent is not needed. Your scheme would be simpler if you dispensed with "MyParent" altogether and made the already exisiting Application instance the owner of each form, using the Application.Components[] array to track which forms are visible, how many there are etc.

cpalx

  • Hero Member
  • *****
  • Posts: 753
Re: Creating multiple (maybe hundreds) of almost-identical TForms
« Reply #21 on: September 13, 2014, 07:39:26 pm »
Why dont you use Tframes todo make the pattern form?
Maybe pascal scripts can help you to add code dynamically 8-)

 

TinyPortal © 2005-2018