Cannot access component property within a TFramebar

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #44097
    Support
    Keymaster

      Hello and thank you for the demo.

      The error occurs because frame is not created – frame is created immediately before opening.

      You can add such line in your code : if sFrameBar1.Items[0].Frame <> nil then …

      #44112
      mol
      Participant
        'Support' wrote:

        The error occurs because frame is not created – frame is created immediately before opening.

        Yeah, I know. Is there a way to prevent the destruction of the attached frame when I close (click on) an item?

        #44116
        mol
        Participant

          Okay, I found it: CanDestroy. Can I leave both procedures below as they are or do I need to test for sFrameBar1.Items[0].Frame <> nil and then explicitely free the frame? There do not seem to be any memory leaks if I don't, but I want to make sure that it doesn't have any other implications when CanDestroy is set to false. Thanks.

          procedure TForm1.sFrameBar1Items0CreateFrame(Sender: TObject;

          var Frame: TCustomFrame);

          begin

          Frame := TFrame1.Create(nil); // <


          do I have to check if the frame already exists before I create it?

          end;

          procedure TForm1.sFrameBar1Items0FrameDestroy(Sender: TObject;

          var Frame: TCustomFrame; var CanDestroy: Boolean);

          begin

          CanDestroy := False;

          end;

        Viewing 3 posts - 1 through 3 (of 3 total)
        • You must be logged in to reply to this topic.