• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2811
  • Last Modified:

Default property values for components in delphi.

Hi All.

I was wondering if there is a way to change the default creation properties of a component at design time.

i.e. I have a Component, that has a flat and a transparent property, when I create one of these on my form at design time, these properties default to False. I then have to manually modify the properties.

The version of Delphi is Delphi 4 and I do have the source code for the component which is sub-classed from the TDBNavigator component.

I tried setting the Default of the transparent property to true :

// --------------------------------------------------------------------------------------------------//

 TBiDiDBNavigator = class(TDBNavigator)
  private
    fTransparent: Boolean;
    procedure SwapButtons;
    procedure SwapGlyphs;
    function Swaped: Boolean;
    procedure SetTransparent(Value: Boolean);
    procedure SetGlyphs(Index: TNavigateBtn; Glyph: TBitmap);
    function GetGlyphs(Index: TNavigateBtn): TBitmap;
  protected
    procedure Paint; override;
    procedure Loaded; override;
    procedure WMSize(var Msg: TWMSize); message WM_SIZE;
    procedure CMBiDiModeChanged(var Msg: TMessage); message CM_BIDIMODECHANGED;
  public
    property Glyphs[Index: TNavigateBtn]: TBitmap read GetGlyphs write SetGlyphs;
  published
    property BiDiMode;
    property ParentBiDiMode;
    property GlyphFirst: TBitmap index nbFirst read GetGlyphs write SetGlyphs;
    property GlyphPrior: TBitmap index nbPrior read GetGlyphs write SetGlyphs;
    property GlyphNext: TBitmap index nbNext read GetGlyphs write SetGlyphs;
    property GlyphLast: TBitmap index nbLast read GetGlyphs write SetGlyphs;
    property GlyphInsert: TBitmap index nbInsert read GetGlyphs write SetGlyphs;
    property GlyphDelete: TBitmap index nbDelete read GetGlyphs write SetGlyphs;
    property GlyphEdit: TBitmap index nbEdit read GetGlyphs write SetGlyphs;
    property GlyphPost: TBitmap index nbPost read GetGlyphs write SetGlyphs;
    property GlyphCancel: TBitmap index nbCancel read GetGlyphs write SetGlyphs;
    property GlyphRefresh: TBitmap index nbRefresh read GetGlyphs write SetGlyphs;
    property Transparent: Boolean read fTransparent write SetTransparent default True;
  end;

// --------------------------------------------------------------------------------------------------//

But that had no effect.
0
kevincox29
Asked:
kevincox29
1 Solution
 
developmentguruCommented:
You just need to add a line to the constructor to set the property to your default value.  The Default specifier on the property line only indicates that it does not need to store the value if it happens to be the default.

Let me know if you need more
0
 
kevincox29Author Commented:
Excellent ..

I overrode the constructor and put my defaults in.. It worked a charm ... Thanks
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now