Solved

Form in a Panel

Posted on 2000-02-14
24
369 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
  • 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
 
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

708 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

18 Experts available now in Live!

Get 1:1 Help Now