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
Solved

combining objects from 2 forms into one

Posted on 2004-09-07
17
384 Views
Last Modified: 2010-04-04
hey all
how can I say this, is it possible to insert objects from one form into another form without having to create them?
my main form is minimal and I like it that way, I dont want an app that can take up the whole screen (sort of like icq etc...)
and I open a second form in that app whenever I want to see xtra info which is not often.

Now I know some people who might use this app will probably not like my design. and might want all forms combined into a single form...
so is it possible to combine/insert 2 forms into one? or be able to move the objects from one form into the other at run time?
 or will I have to have 2 different interfaces and switch between them?

curious...
0
Comment
Question by:LMuadDIb
  • 4
  • 4
  • 3
  • +5
17 Comments
 
LVL 13

Accepted Solution

by:
BlackTigerX earned 250 total points
ID: 12000345
you can have panels in your form, and sure, you can switch controls from one panel to another,

I put two panels, put a label in one of them, then added this code in some button click event:

Label1.Parent:=Panel2

the label gets put into Panel2 no problems
0
 
LVL 5

Expert Comment

by:Voodooman
ID: 12000348
Hi

You could put the objects onto panels and show and hide the panels, or use tab and show and hide the tabs.

You can also get controls that embed the Forms (I think ABC do one - its on the Delphi 7 CDs).

Voodooman
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 12000525
Use Frames. See the topic "Working with frames" in the help file.

0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 26

Assisted Solution

by:EddieShipman
EddieShipman earned 100 total points
ID: 12000534
"A frame (TFrame), like a form, is a container for other components. It uses the same ownership mechanism as forms for
automatic instantiation and destruction of the components on it, and the same parent-child relationships for synchronization
of component properties.

In some ways, however, a frame is more like a customized component than a form. Frames can be saved on the
component palette for easy reuse, and they can be nested within forms, other frames, or other container objects. After a
frame is created and saved, it continues to function as a unit and to inherit changes from the components (including other
frames) it contains. When a frame is embedded in another frame or form, it continues to inherit changes made to the frame
from which it derives.

Frames are useful to organize groups of controls that are used in multiple places in your application. For example, if you
have a bitmap that is used on multiple forms, you can put it in a frame and only one copy of that bitmap is included in the
resources of your application. You could also describe a set of edit fields that are intended to edit a table with a frame and
use that whenever you want to enter data into the table."
0
 
LVL 12

Assisted Solution

by:esoftbg
esoftbg earned 50 total points
ID: 12001293
You may move objects from one form into another form at Runtime:
  Form2.Edit1.Parent := Form1.Panel1;
This way Edit1 from Form1 will be moved on Form1.Panel1;
It is easy as you see .... More difficult is if you want to save the configuration and at next start of the application to appear with the new design. For this purpose you may use the Windows registry or .ini file, or Database ....
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 12001309
> This way Edit1 from Form1 will be moved on Form1.Panel1;
to be readed as
This way Edit1 from Form2 will be moved on Form1.Panel1;
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 12003219
What is construction Form2.Edit1 ?
  1.)  Form2 is the Owner of Edit1;
  2.)  Edit1 is the Object (the component);
  3.)  B := (Edit1.Owner=Form1); will be equal to B := True;
  4.)  Owner is a ReadOnly prperty (it could not be changed at all);
  5.)  Parent property can be changed and:
      5.1.) Form2.Edit1.Parent := Form1.Panel1; //  Edit1 with owner Form2 appears on Form1.Panel1;
      5.2.) Form2.Edit1.Parent := Form2.Panel1; //  Edit1 with owner Form2 appears on Form2.Panel1;
0
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 12003312
agreed with Eddie ... go with frames
design it like a normal form, then your end form hosts those frames that the user likes
0
 
LVL 27

Assisted Solution

by:kretzschmar
kretzschmar earned 100 total points
ID: 12003500
>so is it possible to combine/insert 2 forms into one?

i dislike frames, even if this may a solution for you,
but you can also embed two forms into a third one like

have on the third for two panels or a tpagecontrol with two ttabsheets.
in the formcreate of this thirdform use something like this

begin
  with tform1.create(self) do
  begin
    parent := panel1;
    borderstyle := bsNone;
    align := alClient;
    show;
  end;
  with tform2.create(self) do
  begin
    parent := panel2;
    borderstyle := bsNone;
    align := alClient;
    show;
  end;
end;

just remove tform1/tform2 from the autocraete
in the project-options and make tform3 to your mainform.

meikl ;-)
0
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 12003525
and I dislike "hacks" like these :)
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 12003541
its not a hack, its a possibility,
which worked satisfactorily in practice

meikl ;-)
0
 
LVL 22

Expert Comment

by:Ferruccio Accalai
ID: 12004832
In my opinion in this case should be better to use docked forms.
For example a user that likes the ICQ style will continue to use it so, but if some user want to see the whole forms, or just some important (for him) one, he could decide to dock it to the Main one, something like Winamp do...

This could be a good solution without make too many changes at application and form level, and will let the user to decide wich is his better view style.....
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 12006087
Hey, kretzschmar, why the disdain for frames?

Have you had any experience with them? They are wonderful for portions of forms that are being
reused and extended. For someone with your experience, I am surprised to see you say that.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 12006335
>Hey, kretzschmar, why the disdain for frames?
>Have you had any experience with them?

yep, i have experience. the concept of tframes is genius but the ide
implemention is a pain. as long as you develop a tframe until finish
and embed it then all works fine, but if you have already embedded
the tframe, and you have to change somewhat on the tframe itself,
the embedded tframes may not notice this change under some conditions,
specially if you have done adjustments on the embedded tframe.
my workaround of this bahaviour was to delete the embedded frame
and insert it new.

also is there an align/anchor problem, which caused me to not align
embeded tframes at designtime, and do the alignment at runtime

about this see (actual)
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_21122778.htmland
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_10336365.html

also i missed there the onCreate/onDestroy-events

meikl ;-)
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 12006356
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 12007744
While your arguments have validity, the majority of developers that use them are enamored.
I would think that what the OP is asking could be handled very easily with frames and what
others have posted is actually overkill.

While the alignment problems have not been remedied in later versions of Delphi, we were
able to add the OnCreate and OnDestroy events for Frames at my previous employer.
My current job doesn't require the use of frames and I have since forgotten how it was done.

0
 
LVL 4

Author Comment

by:LMuadDIb
ID: 12007795
good info here, thanx all...
didnt think it could be that easy with using parent
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Using idhttp to login to instagram 2 106
how to send memory stream from ics Client To ics server ? 11 135
Dynamically Created Query 3 62
Tvertscrollbox like a whatsapp layout 5 34
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…
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

839 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