Solved

Form in a Panel

Posted on 2000-02-14
24
379 Views
Last Modified: 2010-04-04
Can i insert a Form in a Panel ?
I mean can i create different forms in the IDE and than in one form i show a treeview on the left an one of the created forms in the right panel !
0
Comment
Question by:snoopy_Spy
[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
  • 9
  • 5
  • 4
  • +3
24 Comments
 

Expert Comment

by:Nuno1
ID: 2519118
Please be more specific.

I didnt understand your question..
0
 

Author Comment

by:snoopy_Spy
ID: 2519162
OK
I have a Main Form which is divided into 2 Panels. In the left Panel i have a TreeView, where i can select a Form. In the right Panel i would show the Form which i have selected in the Treeview !
0
 
LVL 2

Expert Comment

by:florisb
ID: 2519164
Hmmm, how do you want to 'insert'? You can place forms on top of eachother and have them moved, but why not use a panel or groupbox?

Is this what you want?
(drop a button and a panel on a form and insert:)

procedure TForm1.Button1Click(Sender: TObject);
var
  newForm : TForm;
begin
newForm := TForm.create(panel1);
newForm.BorderStyle := bsnone;
newForm.color := clBlue;
newForm.left := form1.left+panel1.left+2;
newForm.top := form1.top+panel1.top+21;
newform.width := panel1.Width;
newForm.height := panel1.height;
newForm.show;
end;

Floris.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:florisb
ID: 2519182
Hmmm, how do you want to 'insert'? You can place forms on top of eachother and have them moved, but why not use a panel or groupbox?

Is this what you want?
(drop a button and a panel on a form and insert:)

procedure TForm1.Button1Click(Sender: TObject);
var
  newForm : TForm;
begin
newForm := TForm.create(panel1);
newForm.BorderStyle := bsnone;
newForm.color := clBlue;
newForm.left := form1.left+panel1.left+2;
newForm.top := form1.top+panel1.top+21;
newform.width := panel1.Width;
newForm.height := panel1.height;
newForm.show;
end;

Floris.
0
 
LVL 2

Expert Comment

by:florisb
ID: 2519230
Hmmm, how do you want to 'insert'? You can place forms on top of eachother and have them moved, but why not use a panel or groupbox?

Is this what you want?
(drop a button and a panel on a form and insert:)

procedure TForm1.Button1Click(Sender: TObject);
var
  newForm : TForm;
begin
newForm := TForm.create(panel1);
newForm.BorderStyle := bsnone;
newForm.color := clBlue;
newForm.left := form1.left+panel1.left+2;
newForm.top := form1.top+panel1.top+21;
newform.width := panel1.Width;
newForm.height := panel1.height;
newForm.show;
end;

Floris.
0
 
LVL 2

Expert Comment

by:florisb
ID: 2519232
oops, how did that happen?
0
 

Author Comment

by:snoopy_Spy
ID: 2519266
This doesn't work !
It only creates a new form with the left, top, width and height but doesn't move or size !
And when i click on the main form the newForm is send to back.
I want to insert a form (or a Panel) (which controls on it) in a Panel of a main Form.
0
 
LVL 2

Expert Comment

by:florisb
ID: 2519290
Again: I wouldn't do it with a form... ...why not another panel? Visual the same, programatically 10 times easier.

Somebody else?

F.

0
 
LVL 5

Expert Comment

by:TheNeil
ID: 2519314
You could try using a frame, MDI, or ActiveForms.

Using Floris idea, you could create your form as any other form, set it's formstyle to be StayOnTop and then rather than create a blank form, just showmodal your form over your main form (you could still create it dynamically if you wanted to)

If I understand your original problem, you want to be able to browse through Delphi forms, loading the one you're interested into the second panel. There isn't a way to do this with forms unless you create something executable with them. ActiveForms will do what you want but are tricky, and I'd go for frames

The Neil
0
 

Author Comment

by:snoopy_Spy
ID: 2519317
Because i want to show it in two ways :

1.) In a Panel an the right side
2.) With a double click - In a own Form
0
 

Author Comment

by:snoopy_Spy
ID: 2519464
TheNeil !

I have tried this :

    Panel1.BringtoFront;
    temp := TFrame1.Create(Panel1);
    temp.Show;
    temp.BringtoFront;
    temp.Width := 200;
    temp.Height := 100;
    Panel1.InsertControl(temp);

but it doesn't work !
0
 
LVL 17

Expert Comment

by:geobul
ID: 2519526
Hi,

Try this:

I use here a button and a panel on the form1 and previously created form2.

procedure TForm1.Button1Click(Sender: TObject);
begin
  Form2.Parent := Form1.Panel1;
  Form2.Left := 0;
  Form2.Top := 0;
  Form2.Height := Panel1.Height;
  Form2.Width := Panel1.Width;
  Form2.Show;
end;

Regards, Geo
0
 
LVL 5

Expert Comment

by:TheNeil
ID: 2519550
Snoopy_Spy,

I've just tried this and it works fine. There are problems if you try to run the code several times without freeing temp first. Have you declared temp properly? I've got it as a global TFrame.

What error messages are you getting and do you have a complete code sample that you can either post or mail?

The Neil
0
 

Author Comment

by:snoopy_Spy
ID: 2519591
TheNeil,
I have foundthe problem, when i use a TPageControl with no pages it works fine. When i add at least one page it doesn't work (Nothing from the Frame is shown !)
0
 
LVL 5

Expert Comment

by:TheNeil
ID: 2519613
Snoopy_Spy,

Err why are you usig a TPageControl? I got it working first time with a normal TPanel. Can you assign the frame to one of the pages rather than the control itself?
Then again, what does it matter - it works.

Should I be the cheekiest person on the face of the planet and ask who (if anyone) gets the points?

The Neil
0
 

Author Comment

by:snoopy_Spy
ID: 2519634
I don't know if i understand your comment at all :
What i did was, it had a PageControl on the Frame   . When i add the Frame manually it works fine. When i add the frame programmatically it only works if i have no pages.

The frame is inserted on a standard TPanel !
0
 
LVL 5

Expert Comment

by:TheNeil
ID: 2519650
Snoopy_Spy,

Sorry, I thought you were trying to insert the frame INTO the PageControl - oops

The Neil
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 2519695
hi friends,

yes it is possible.
i would prefer to design the form which should be shown in the panel with borderstyle bsnone and all others as normal design, like

var f : TForm2;
begin
  f := TForm2.Create(Panel1);
  f.BorderStyle := bsNone;
  f.align := alclient;
  f.parent := panel1;
  f.show;
end;

for a pagecontrol:

var
  t : TTabsheet;
  f : TForm2;
begin
  t := TTabsheet.Create(PageControl1);
  t.PageControl := PageControl1;
  t.Caption := IntToStr(PageControl1.PageCount);

  f := TForm2.Create(t);
  f.BorderStyle := bsNone;
  f.align := alclient;
  f.parent := t;
  f.show;

end;


meikl

ps: frames are similar to forms
0
 

Author Comment

by:snoopy_Spy
ID: 2519731
kretzschmar,
Your first routine doesn't work - The form isn't shown.
Your second routine - i don't want to insert a form (Frame) into a PageControl ! The problem is to insert a frame which contain a PageControl !
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 2519773
hi snoopy,

>Your first routine doesn't work - The form isn't shown.
you dont see it, if the form is empty
(no caption, no min-max-close-sys-buttons,looks like as the panel itselfs)
>to insert a frame which contain a PageControl
just drop a pagecontrol on it and use the first routine

if it not working for you, then leave your email and
i send you my just coded working sample (d3 using a form)

meikl ;-)

0
 

Author Comment

by:snoopy_Spy
ID: 2519811
Kretzschmar,
I have some Controls on the Form. Itried it with and without a PageControl.
My Email : snoopy@rudolfinum.sth.ac.at
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 50 total points
ID: 2519958
sample sent ;-)
0
 

Author Comment

by:snoopy_Spy
ID: 2520034
Thanks
Works fine now
I had set the FormStyle to fsMDIChild . . . . (from previous trying)
0
 
LVL 17

Expert Comment

by:geobul
ID: 2521629
Hi,

Try this:

I use here a button and a panel on the form1 and previously created form2.

procedure TForm1.Button1Click(Sender: TObject);
begin
  Form2.Parent := Form1.Panel1;
  Form2.Left := 0;
  Form2.Top := 0;
  Form2.Height := Panel1.Height;
  Form2.Width := Panel1.Width;
  Form2.Show;
end;

Regards, Geo
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

705 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