Solved

Default property values for components in delphi.

Posted on 2007-11-14
2
2,455 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now