[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Compound components (Panels inside Panels)?!

Posted on 2006-06-13
6
Medium Priority
?
253 Views
Last Modified: 2010-04-05
Hello experts,

the Delphi component I try to write (using Delphi 6) contains a panel which itself contains 2
more panels. I need to be able to drop other components onto theses
nested panels at design time which works fine but at runtime the
components on the nested panels are gone...

I came across different solutions with the setsubcomponent method and
having the form as the owner of all the panels but these solutions
didn't really work out. A solution that worked fine for me for having
all sorts of components on the top panel in my component was
overwriting the getchildren and getchildparent methods:

procedure TTestPanel.GetChildren(Proc: TGetChildProc; Root:
TComponent);
begin
  FNestedPanel.GetChildren(Proc,Root);
end;

function TTestPanel.GetChildParent: TComponent; override;
begin
  Result := FNestedPanel;
end;

I am sorry if this is a stupid question but this is my first try to write
my own component plus I'm fairly new to Delphi as well and I am stuck now when trying to use this solution
for having more than 1 nested panel as I cannot return Result := FNestedPanel anymore because I don't know which of my nested panels is the correct parent.

I hope anyone can help as I searched several newsgroups and came across different answers but none solved my problem and it is getting quite urgent now!

Many thanks for your help in advance!!!
0
Comment
Question by:Homer30
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
6 Comments
 
LVL 17

Expert Comment

by:TheRealLoki
ID: 16899075
you need to set the new component's "parent" property, or it will be invisible

e.g.
with tlabel.create(somepanel) do
begin
    parent := somepanel;
    left := 10;
    top := 10;
    caption := 'hi';
end;
0
 
LVL 17

Accepted Solution

by:
TheRealLoki earned 2000 total points
ID: 16899098
or, since you are new, this might be a little more obvious

var
    newpanel: TPanel; // the new panel we wish to add inside "nestedpanel1"
begin
    newpanel := TPanel.Create(nestedpanel1); //owner
    newpanel.Parent := nestedpanel1; // note : "parent" is not the same thing as "owner"
    newpanel.top := 10;
    newpanel.left := 10;
    newpanel.width := 100;
    newpanel.height := 100;
end;

oh btw, if I'm on the wrong track, let me know. I've posted this because you said you were new to delphi, and it is easy to overlook it. If this is a different issue, feel free to "i know that, fool" me at will
0
 
LVL 6

Expert Comment

by:saravananvg
ID: 16899992
Hello Sir,

  You need to use sendtoback and bringtofront for the panels to be shown and the remaining panels invisible.

with regards,
padmaja.
0
 
LVL 7

Expert Comment

by:kfoster11
ID: 16908972
Boy, I'm lost after reading this.  Delphi works in this way.  When you .CREATE a component you set the AOWNER in the Create(APanel).  This is so that APanel will destroy or release the memory for the new component.  Then COMPLETELY SEPERATE from the Owner is the Parent.  The parent is responsible for drawing the control so you must set the PARENT of the 2 sub panels to the main panel and then any thing dropped on one of the 2 sub panels need the appropriate panel as their parent.

I know that 2 answers above showed how to do this, but after reading this thread I had to explain this to myself, so I though it might help.  :)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

650 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