Recent

Author Topic: 'component' creation order  (Read 5562 times)

JimBodkins

  • Jr. Member
  • **
  • Posts: 63
'component' creation order
« on: November 22, 2006, 09:05:02 pm »
I have the following form  declaration

   { TForm1 }

  TForm1 = class(TForm)
    Button1: TButton;
    ChmsDB1: TChmsDB;
    Chmscombo1: TChmscombo;
    ChmsLabeledEdit1: TChmsLabeledEdit;
    chmstables1: Tchmstables;
    procedure Button1Click(Sender: TObject);
    procedure Chmscombo1ChmsSelect(Sender: TObject);
    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    procedure FormCreate(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

TChmsDB, TChmscombo,TChmsLabeledEdit and TChmstables are all custom.

TChmsDB opens the database

TChmscombo is a multifield combobox that displays and selects one field and sets a second (ordinally equal) to a new field (KeyText). It can also handle single fields.

TChmsLabledEdit just changes some of the defaults for labelededit (to same manual editing)

TChmstables defines the struction of all the tables/keys/foreignkeys/functions-to-access etc (huge file ~50,000 lines)


TChmscombo has a property 'loadoncreate' which I would like to use. To use it however, I must be able to guarantee that TChmsDB has already been created prior to the creation of TChmscombo , since the database must be open at this point.

I tried manually to modify to position of TChmsDB in the LFM, but that had no descernable effect.

Is it possible to 'order' the creation of form componenets and if so, how?

Thanks
(unedited and my font is too small to see clearly under fedora :( )

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
RE:
« Reply #1 on: November 22, 2006, 09:26:36 pm »
I don't think you can force the creation order. At least I wouldn't build any components on it.

I would override the Loaded method and also look good at the ComponentState, which has a possible csLoaded value.

JimBodkins

  • Jr. Member
  • **
  • Posts: 63
'component' creation order
« Reply #2 on: November 23, 2006, 12:49:15 am »
This is a little baffling.

If I use  Form1.loaded (override), I can create/open the database prior to the creation of teh data aware combobox. However, at the time of creation (post inherited), it appears that properties that are needed to load the combobox and associated stringlist that were defined at design time are not set.

I experimentally overrode the combo's loaded which worked one time and has failed since with no code mods. (I am checking for csDesigning).

It would be so much easier if I could just force the creation order. :)

JimBodkins

  • Jr. Member
  • **
  • Posts: 63
'component' creation order
« Reply #3 on: November 23, 2006, 02:39:45 am »
In the Chmscombo component, I have additional datastructiures. (Data aware). I have created a new event ChmsOnSelect. When the component receives the OnSelect event, it updates the new internal datastructures from the database and fires the ChmsOnSelect event.

In the application, I had

  if csDesigning in ComponentState then
    exit;

... in the proceduress that open and load the table data. Oddly, this resulted in the CHmsOnSelect wasnt firing. I commented the if test  out and the ChmsOnSelect begain firing.

Is there some connection, under the hood, between ComponentState and events?

JimBodkins

  • Jr. Member
  • **
  • Posts: 63
'component' creation order
« Reply #4 on: November 24, 2006, 11:38:22 pm »
Bump

Any chance of adding the ability to define creation order (even based on lfm order would be ok)

Jim

 

TinyPortal © 2005-2018