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 8561373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:29:18+00:00 2026-06-11T16:29:18+00:00

I have a component that I create and then pass into it a panel

  • 0

I have a component that I create and then pass into it a panel on my main form.

Here is a very simplified example:

procedure TMy_Socket.StatusPanel_Add(AStatusPanel: TPanel);

This component will then update the panels caption as the need arises.

In my main program if I FreeAndNil the panel the next time the component tries to update the panel I get an AV. I understand why: the component’s reference to the panel now is pointing to an undefined location.

How can I detect within the component if the panel has been freed so I know I can not reference it?

I tried if (AStatusPanel = nil) but it is not nil, it still has an address.

  • 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-06-11T16:29:20+00:00Added an answer on June 11, 2026 at 4:29 pm

    You have to call the Panel’s FreeNotification() method, and then have your TMy_Socket component override the virtual Notification() method, eg (given your naming scheme, I assume you can add multiple TPanel controls to your component):

    type
      TMy_Socket = class(TWhatever)
      ...
      protected
        procedure Notification(AComponent: TComponent; Operation: TOperation); override;
      ...
      public
        procedure StatusPanel_Add(AStatusPanel: TPanel); 
        procedure StatusPanel_Remove(AStatusPanel: TPanel); 
      ...
      end;
    
    procedure TMy_Socket.StatusPanel_Add(AStatusPanel: TPanel); 
    begin
      // store AStatusPanel as needed...
      AStatusPanel.FreeNotification(Self);
    end;
    
    procedure TMy_Socket.StatusPanel_Remove(AStatusPanel: TPanel); 
    begin
      // remove AStatusPanel as needed...
      AStatusPanel.RemoveFreeNotification(Self);
    end;
    
    procedure TMy_Socket.Notification(AComponent: TComponent; Operation: TOperation);
    begin
      inherited;
      if (AComponent is TPanel) and (Operation = opRemove) then
      begin
        // remove TPanel(AComponent) as needed...
      end;
    end; 
    

    If you are only tracking one TPanel at a time instead:

    type
      TMy_Socket = class(TWhatever)
      ...
      protected
        FStatusPanel: TPanel;
        procedure Notification(AComponent: TComponent; Operation: TOperation); override;
      ...
      public
        procedure StatusPanel_Add(AStatusPanel: TPanel); 
      ...
      end;
    
    procedure TMy_Socket.StatusPanel_Add(AStatusPanel: TPanel); 
    begin
      if (AStatusPanel <> nil) and (FStatusPanel <> AStatusPanel) then
      begin
        if FStatusPanel <> nil then FStatusPanel.RemoveFreeNotification(Self);
        FStatusPanel := AStatusPanel;
        FStatusPanel.FreeNotification(Self);
      end;
    end;
    
    procedure TMy_Socket.Notification(AComponent: TComponent; Operation: TOperation);
    begin
      inherited;
      if (AComponent = FStatusPanel) and (Operation = opRemove) then
        FStatusPanel := nil;
    end; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Something that is very handy in flex is that you can create a component,
I have a component that uses log4net. I want to create unit tests, that
I have a visual component that I built from a TFrame (but then registered
I want to create a panel (or any other component) inside a component that
I have created a Hexagon component that extends JPanel . It draws a hexagon
I have created a plugin in that i included one component.. So in that
I have a component that I hand over a function public var func :
I have a component that is made up of various components such as a
I have a component that i want to store to an SQLite database. public
I have a component that has a sub-component they both use a shared variable

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.