Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6881445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:06:30+00:00 2026-05-27T05:06:30+00:00

I have a component which has a corresponding persistent. This persistent is of course

  • 0

I have a component which has a corresponding persistent. This persistent is of course published as a property of the component, showing in the object inspector. It has a few different properties of its own, mainly 4 integers (Left, Top, Right, Bottom). I also have a property in this persistent called Auto which is intended to automatically calculate the 4 integers based on the size of the component.

More specifically, this graphic component has a border around it, each edge can have a different sized border. This persistent and its properties specify the thickness of the border on each side. When Auto is enabled, the 4 border edges are calculated based on the size of the component.

Now it seems to work fine for the most part, except, somehow this Auto property keeps going back to False randomly. Also, in design-time, when resizing the component with Auto enabled, it does in fact calculate things accordingly, perfectly. But, in run-time, it goes back to False, and no longer calculates them anymore. Upon saving with Auto enabled, closing the form, then re-opening it, this Auto property is back to False again.

The 4 integer properties have setters, which if they are set, it turns this Auto property to false. I’m assuming this is what’s causing it to keep going to false again, except, I’m not telling it to set these properties anywhere.

Here’s the persistent:

  TJDGlassBorder = class(TPersistent)
  private
    fOwner: TJDGlass; //This is the parent component
    fGlow: Integer;
    fBottom: Integer;
    fLeft: Integer;
    fTop: Integer;
    fRight: Integer;
    fColor: TColor;
    fOnEvent: TNotifyEvent;
    fAuto: Bool;
    procedure SetBottom(const Value: Integer);
    procedure SetColor(const Value: TColor);
    procedure SetGlow(const Value: Integer);
    procedure SetLeft(const Value: Integer);
    procedure SetRight(const Value: Integer);
    procedure SetTop(const Value: Integer);
    function GetBottom: Integer;
    function GetLeft: Integer;
    function GetRight: Integer;
    function GetTop: Integer;
    procedure SetAuto(const Value: Bool);
  public
    constructor Create(AOwner: TJDGlass);
    destructor Destroy; override;
    procedure Event;
    procedure Assign(Source: TPersistent); override;
  published
    property Auto: Bool read fAuto write SetAuto default True;
    property Left: Integer read GetLeft write SetLeft default 3;
    property Top: Integer read GetTop write SetTop default 2;
    property Right: Integer read GetRight write SetRight default 3;
    property Bottom: Integer read GetBottom write SetBottom default 4;
    property Color: TColor read fColor write SetColor;
    property Glow: Integer read fGlow write SetGlow default 1;
    property OnEvent: TNotifyEvent read fOnEvent write fOnEvent;
  end;

/////////////

{ TJDGlassBorder }

procedure TJDGlassBorder.Assign(Source: TPersistent);
begin
  inherited Assign(Source);
  Event;
end;

constructor TJDGlassBorder.Create(AOwner: TJDGlass);
begin
  fOwner:= AOwner;
  fAuto:= True;
  fColor:= clBlack;
  fGlow:= 1;
  Event;
end;

destructor TJDGlassBorder.Destroy;
begin

  inherited;
end;

procedure TJDGlassBorder.Event;
begin
  if assigned(fOwner) then 
    if fOwner <> nil then
      fOwner.Invalidate;
  if assigned(fOnEvent) then
    fOnEvent(Self);
end;

function TJDGlassBorder.GetBottom: Integer;
begin
  if fAuto then begin
    if assigned(fOwner) then begin
      if fOwner <> nil then begin
        Result:= Max(2, fOwner.Height div 10);
        fBottom:= Result;
      end;
    end;
  end else begin
    Result:= fBottom;
  end;
end;

function TJDGlassBorder.GetLeft: Integer;
begin
  if fAuto then begin
    if assigned(fOwner) then begin
      if fOwner <> nil then begin
        Result:= (Top + Bottom) div 2;
        fLeft:= Result;
      end;
    end;
  end else begin
    Result:= fLeft;
  end;
end;

function TJDGlassBorder.GetRight: Integer;
begin
  if fAuto then begin
    if assigned(fOwner) then begin
      if fOwner <> nil then begin
        Result:= (Top + Bottom) div 2;
        fRight:= Result;
      end;
    end;
  end else begin
    Result:= fRight;
  end;
end;

function TJDGlassBorder.GetTop: Integer;
begin
  if fAuto then begin
    if assigned(fOwner) then begin
      if fOwner <> nil then begin
        Result:= Max(1, fOwner.Height div 30);
        fTop:= Result;
      end;
    end;
  end else begin
    Result:= fTop;
  end;
end;

procedure TJDGlassBorder.SetAuto(const Value: Bool);
begin
  fAuto := Value;
  Event;
end;

procedure TJDGlassBorder.SetBottom(const Value: Integer);
begin          
  fAuto:= False;
  fBottom := Value;  
  Event;
end;

procedure TJDGlassBorder.SetColor(const Value: TColor);
begin
  fColor := Value;  
  Event;
end;

procedure TJDGlassBorder.SetGlow(const Value: Integer);
begin
  fGlow := Value;  
  Event;
end;

procedure TJDGlassBorder.SetLeft(const Value: Integer);
begin         
  fAuto:= False;
  fLeft := Value;  
  Event;
end;

procedure TJDGlassBorder.SetRight(const Value: Integer);
begin       
  fAuto:= False;
  fRight := Value; 
  Event;
end;

procedure TJDGlassBorder.SetTop(const Value: Integer);
begin           
  fAuto:= False;
  fTop := Value;
  Event;
end;

EDIT:

I attempted 3 more things in the above code, and still have the problem. This is what I did:

1: Published the Auto property after the other 4 properties, thinking of the order that these properties are retrieved.

published
  property Auto: Bool read fAuto write SetAuto default True;
  property Left: Integer read GetLeft write SetLeft default 3;
  property Top: Integer read GetTop write SetTop default 2;
  property Right: Integer read GetRight write SetRight default 3;
  property Bottom: Integer read GetBottom write SetBottom default 4;

Changed to:

published
  property Left: Integer read GetLeft write SetLeft default 3;
  property Top: Integer read GetTop write SetTop default 2;
  property Right: Integer read GetRight write SetRight default 3;
  property Bottom: Integer read GetBottom write SetBottom default 4;
  property Auto: Bool read fAuto write SetAuto default True;

2: In the property setters for these integers, I’m checking to see if the new value differs from the existing value…

procedure TJDGlassBorder.SetTop(const Value: Integer);
begin         
  if Value <> fTop then begin  
    fAuto:= False;
    fTop := Value;
    Event;
  end;
end;

3: In the property getters for these integers, I changed how it checks the existing value…

function TJDGlassBorder.GetTop: Integer;
begin
  Result:= fTop;
  if fAuto then begin
    if assigned(fOwner) then begin
      if fOwner <> nil then begin
        Result:= Max(1, fOwner.Height div 30);
        fTop:= Result;
      end;
    end;
  end;
end;

Again, none of these attempts worked, I still have this problem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T05:06:31+00:00Added an answer on May 27, 2026 at 5:06 am

    FIXED!

    The 3 attempts I put in my edit above were partially the problem, but the actual fix was removing the default of the Auto property. The thing is, I had this defaulted to True, which, in this case, that property is not saved in the DFM file. Therefore it did not even attempt to set this Auto property. Removing the Default fixed, because now whether it’s true or false, it’s always saved in the DFM file, therefore always setting this value. The order of publishing the properties was also half of the problem.


    Here’s the final code for what I posted above:

      TJDGlassBorder = class(TPersistent)
      private
        fOwner: TJDGlass; //This is the parent component
        fGlow: Integer;
        fBottom: Integer;
        fLeft: Integer;
        fTop: Integer;
        fRight: Integer;
        fColor: TColor;
        fOnEvent: TNotifyEvent;
        fAuto: Bool;
        procedure SetBottom(const Value: Integer);
        procedure SetColor(const Value: TColor);
        procedure SetGlow(const Value: Integer);
        procedure SetLeft(const Value: Integer);
        procedure SetRight(const Value: Integer);
        procedure SetTop(const Value: Integer);
        function GetBottom: Integer;
        function GetLeft: Integer;
        function GetRight: Integer;
        function GetTop: Integer;
        procedure SetAuto(const Value: Bool);
      public
        constructor Create(AOwner: TJDGlass);
        destructor Destroy; override;
        procedure Event;
        procedure Assign(Source: TPersistent); override;
      published
        property Left: Integer read GetLeft write SetLeft default 3;
        property Top: Integer read GetTop write SetTop default 2;
        property Right: Integer read GetRight write SetRight default 3;
        property Bottom: Integer read GetBottom write SetBottom default 4;
        property Color: TColor read fColor write SetColor;
        property Glow: Integer read fGlow write SetGlow default 1;
        property OnEvent: TNotifyEvent read fOnEvent write fOnEvent;
        property Auto: Bool read fAuto write SetAuto;
      end;
    
    /////////////
    
    { TJDGlassBorder }
    
    procedure TJDGlassBorder.Assign(Source: TPersistent);
    begin
      inherited Assign(Source);
      Event;
    end;
    
    constructor TJDGlassBorder.Create(AOwner: TJDGlass);
    begin
      fOwner:= AOwner;
      fAuto:= True;
      fColor:= clBlack;
      fGlow:= 1;
      Event;
    end;
    
    destructor TJDGlassBorder.Destroy;
    begin
    
      inherited;
    end;
    
    procedure TJDGlassBorder.Event;
    begin
      if assigned(fOwner) then 
        if fOwner <> nil then
          fOwner.Invalidate;
      if assigned(fOnEvent) then
        fOnEvent(Self);
    end;
    
    function TJDGlassBorder.GetBottom: Integer;
    begin
      Result:= fBottom;
      if fAuto then begin
        if assigned(fOwner) then begin
          if fOwner <> nil then begin
            Result:= Max(2, fOwner.Height div 10);
            fBottom:= Result;
          end;
        end;
      end;
    end;
    
    function TJDGlassBorder.GetLeft: Integer;
    begin
      Result:= fLeft;
      if fAuto then begin
        if assigned(fOwner) then begin
          if fOwner <> nil then begin
            Result:= (Top + Bottom) div 2;
            fLeft:= Result;
          end;
        end;
      end;
    end;
    
    function TJDGlassBorder.GetRight: Integer;
    begin
      Result:= fRight;
      if fAuto then begin
        if assigned(fOwner) then begin
          if fOwner <> nil then begin
            Result:= (Top + Bottom) div 2;
            fRight:= Result;
          end;
        end;
      end;
    end;
    
    function TJDGlassBorder.GetTop: Integer;
    begin
      Result:= fTop;
      if fAuto then begin
        if assigned(fOwner) then begin
          if fOwner <> nil then begin
            Result:= Max(1, fOwner.Height div 30);
            fTop:= Result;
          end;
        end;
      end;
    end;
    
    procedure TJDGlassBorder.SetAuto(const Value: Bool);
    begin
      fAuto := Value;
      Event;
    end;
    
    procedure TJDGlassBorder.SetBottom(const Value: Integer);
    begin
      if Value <> fBottom then begin
        fAuto:= False;
        fBottom := Value;  
        Event;
      end;
    end;
    
    procedure TJDGlassBorder.SetColor(const Value: TColor);
    begin
      fColor := Value;  
      Event;
    end;
    
    procedure TJDGlassBorder.SetGlow(const Value: Integer);
    begin
      fGlow := Value;  
      Event;
    end;
    
    procedure TJDGlassBorder.SetLeft(const Value: Integer);
    begin         
      if Value <> fLeft then begin
        fAuto:= False;
        fLeft := Value;  
        Event;
      end;
    end;
    
    procedure TJDGlassBorder.SetRight(const Value: Integer);
    begin       
      if Value <> fRight then begin
        fAuto:= False;
        fRight := Value; 
        Event;
      end;
    end;
    
    procedure TJDGlassBorder.SetTop(const Value: Integer);
    begin        
      if Value <> fTop then begin   
        fAuto:= False;
        fTop := Value;
        Event;
      end;
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a component which has a List<T> property. The class in the list
I have a WPF application which has a DirectX component within it. This component
I have a Windows.Forms component which has a mySize property that returns a Size
I would like to have a Java component which has a resize icon on
I have an old C++ COM component which has to stay in Visual Studio
I have a page-scoped component, which has an instance variable List with data, which
I have a component which writes/generates javascript from a server side renderer. This component
I have developed some reusable android component which is basically a class . This
I have a pickerView which has a component of colors. I have a textField
I have a base class called Component which has a number of classes derived

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.