Frame not appoearing on Form

Posted on 2004-11-28
Last Modified: 2010-04-05
I have made extensive use of inherited forms in an application and am looking to use frames to individualise some aspects of the interface.

I am new to frames and with a simple test program to see how they work, my test frame did not appear on the form.

I did the following:

I created a new Form and added a button.

I then created a Frame with a different colour to the Form, and some labels (ie something to see).

I declared the frame as a variable on the form i.e

  Form1: TForm1;
  Frame1: TFrame;

I then put the following code behind the Onclick event of the button I placed on the form

  if Frame1 = nil then
     Frame1 := TFrame.Create(self);
  Frame1.Visible := true;
  Frame1.Align := alTop;
  Frame1.Parent := Form1;

I have also used


When I run the program, and click the button, I can't see the frame. However, if I leave some extraneous labels on the form where the frame it to appear, these disappear when I click the button ie, the frame is there in some spiritual form, but I can't see it. What else do I need to do?

I expect this is an easy question for the gurus, but it is worth 200 points (not 50) to me.

Question by:Dennis_Treacy
    LVL 17

    Accepted Solution

    i can only guess (as You don't provide whole code)

    If You have something like this
      TFrame1 = class(TFrame)

    You should have

      Form1: TForm1;
      Frame1: TFrame1;  // not TFrame

      if Frame1 = nil then
         Frame1 := TFrame1.Create(self);  // not TFrame
      Frame1.Visible := true;
      Frame1.Align := alTop;
      Frame1.Parent := Form1;

    Author Comment


    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
    Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    730 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

    19 Experts available now in Live!

    Get 1:1 Help Now