Recent

Author Topic: New component and default value  (Read 4120 times)

Dibo

  • Hero Member
  • *****
  • Posts: 1048
New component and default value
« on: June 19, 2009, 06:17:27 pm »
Hi
I try to create own component inherited from TDBEdit, but I have a problem with setting default color values. It seems to me that I do everything correctly, but for both the color is black. Why is this happening? I have Revision 20080, I not found a matching declaration in bugtracker. Whether this is an error or I do something wrong?
Regards

This is the code:
Code: [Select]
  TKDDBEdit = class(TDBEdit)
  private
    FColorIfNotReadOnly: TColor;
    FColorIfReadOnly: TColor;
    FReadOnlyWithCustomColor: Boolean;
    procedure SetColorIfNotReadOnly(const AValue: TColor);
    procedure SetColorIfReadOnly(const AValue: TColor);
    procedure SetReadOnlyWithCustomColor(const AValue: Boolean);
    { Private declarations }
  protected
    { Protected declarations }
  public
    { Public declarations }
  published
    { Published declarations }
    property ColorIfReadOnly: TColor read FColorIfReadOnly write SetColorIfReadOnly stored True default clWindow; //this is black
    property ColorIfNotReadOnly: TColor read FColorIfNotReadOnly write SetColorIfNotReadOnly stored True default clBtnFace; //... and this too
    property ReadOnlyWithCustomColor: Boolean
      read FReadOnlyWithCustomColor write SetReadOnlyWithCustomColor;
  end;

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
Re: New component and default value
« Reply #1 on: June 20, 2009, 07:53:39 pm »
What is the problem? Are the published values stored in the lfm? Does your constructor assign the default values?

Dibo

  • Hero Member
  • *****
  • Posts: 1048
Re: New component and default value
« Reply #2 on: June 20, 2009, 08:34:30 pm »
Ouch, the constructor. I don't have a large experience in the creation of components. I thought that it is enough to indicate the default value. Sorry. Problem resolved

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
Re: New component and default value
« Reply #3 on: June 20, 2009, 08:40:17 pm »
Well, that explains why the code snippet didn't include the constructor. :)

 

TinyPortal © 2005-2018