Recent

Author Topic: Initializing TFrame private variables. Where?  (Read 7786 times)

Leledumbo

  • Hero Member
  • *****
  • Posts: 8523
  • Programming + Glam Metal + Tae Kwon Do = Me
Initializing TFrame private variables. Where?
« on: April 29, 2010, 12:38:48 am »
TFrame doesn't have OnCreate or something similar. So how can I initialize its private variables?
Follow this if you want me to answer: **://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

**://pascalgeek.blogspot.com
**s://bitbucket.org/leledumbohttps://github.com/leledumbo
Code first, think later - Natural programmer B)

Imants

  • Full Member
  • ***
  • Posts: 196
Re: Initializing TFrame private variables. Where?
« Reply #1 on: April 29, 2010, 05:11:47 am »
Just override existing constructor like this:

  TFrame1 = class(TFrame)
  private
    MyVar: Integer;
  public
    constructor Create(TheOwner: TComponent); override;
  end;


.....

constructor TFrame1.Create(TheOwner: TComponent);
begin
  inherited Create(TheOwner);
  MyVar := 0;
end;

Leledumbo

  • Hero Member
  • *****
  • Posts: 8523
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Initializing TFrame private variables. Where?
« Reply #2 on: April 29, 2010, 07:47:57 am »
Hahaha... I guess I was too sleepy to think about it. Thanks.
Follow this if you want me to answer: **://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

**://pascalgeek.blogspot.com
**s://bitbucket.org/leledumbohttps://github.com/leledumbo
Code first, think later - Natural programmer B)

wOvAN

  • New Member
  • *
  • Posts: 47
    • wxSoft.Ru
Re: Initializing TFrame private variables. Where?
« Reply #3 on: April 29, 2010, 11:30:01 am »
Code: [Select]
  Frame1 = class(TFrame)
  public
    { public declarations }
    procedure AfterConstruction; override;
    procedure BeforeDestruction; override;
  end;

mas steindorff

  • Hero Member
  • *****
  • Posts: 518
Re: Initializing TFrame private variables. Where?
« Reply #4 on: April 30, 2010, 02:15:49 am »
since were on frames....
I have a project that uses a TFrame. 
When I Update the Frame's looks at design time, the copies on the form do not change.
When I run the program, all looks and works well. 

Is there an easy way to update the frames I've placed other than to delete them and add them back in?
windows 7/10 - laz 2.0 / 1.2.6 general releases

Imants

  • Full Member
  • ***
  • Posts: 196
Re: Initializing TFrame private variables. Where?
« Reply #5 on: April 30, 2010, 05:38:59 am »
I think the esyest vhay is to close and then open again those files where your frame copy is.

mas steindorff

  • Hero Member
  • *****
  • Posts: 518
Re: Initializing TFrame private variables. Where?
« Reply #6 on: April 30, 2010, 10:19:41 pm »
Wow, it works!  I tried closing the IDE and the same old frame would appeared after I restarted it.
Your advice to just close the form and then reopen it works like a charm ;D  Thanks
windows 7/10 - laz 2.0 / 1.2.6 general releases

 

TinyPortal © 2005-2018