Solved

Default property values for components in delphi.

Posted on 2007-11-14
2
2,523 Views
Last Modified: 2013-11-23
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
Comment
Question by:kevincox29
2 Comments
 
LVL 21

Accepted Solution

by:
developmentguru earned 250 total points
ID: 20280918
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
 

Author Comment

by:kevincox29
ID: 20281145
Excellent ..

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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi XE10 Round Image 2 193
Print Graphic and Text to Epson TM-T88v 12 478
Adoquery sql  left join does not work 25 106
Add New Database Table in database file using delphi 3 32
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question