Solved

COMPonents

Posted on 1997-05-06
5
235 Views
Last Modified: 2010-04-06
Why use components instead of units? What are the componets, do they do something?
0
Comment
Question by:BJohn
[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
  • 3
5 Comments
 
LVL 2

Accepted Solution

by:
gysbert1 earned 200 total points
ID: 1335962
Componets are firstly visual, which units are not.

Delphi is a visual programming language in a sense. You can thus make a component act differently at runtime and at design time in order to ease the use thereof.

Secondly components have properties that is not that easy to implement in your unit. Definately not as easy as using variables. Any modification to the variable known as a property will have a function call in stead of a simple assignment. It overloads the = operator. So MyProperty=5 will not simply assign, it will call the assign function for MyProperty.

Component help can also be embedded into the standard Delphi help files. This makes shipping and 3rd party use much easier ...

Let me know if you need more reasons !!


0
 
LVL 2

Expert Comment

by:gysbert1
ID: 1335963
Oh yes ...

I should have mentioned this.

Components are esentially only objects which could just as well have been included in units.  Actually a component is only a unit that is included in your delphi file. If you add a component to a form, have a look at it's uses clause. The new component's unit will be added to it. The unit also contains code that is exclusively for design time. The component's unit is precompiled by delphi (you should see this happen if you add any components). Delphi then creates object code that can be linked into your application and adds the design time code to complib.dcl which contains the behaviour of the component at design time.

A component is thus not only a unit, but an object that is situated inside a unit. This means that it does not only contain functions and variables like a unit, but you can have multiple instances of the same component in a single application that shares code segment but not the data segment.

To conclude, if you do not need the design-time interface and you  have your code as an object and you even implemented properties  by overloading the = operator, then using a component is no different from simply using a unit with your code in.
0
 
LVL 4

Expert Comment

by:erajoj
ID: 1335964
First of all: the points for this question are way to many!
The purpose of the components is to make the interface design
easier. The components allow you to set parameters and
connect their events to procedures easily for both visual
and non-visual types, and most of the visual components appear
in design time as they would in run time.
Of course you can combine regular units with components.

/// John

0
 
LVL 2

Expert Comment

by:gysbert1
ID: 1335965
Seems like we have an echo here ;^)
0
 
LVL 3

Expert Comment

by:mheacock
ID: 1335966
Anytime you drag something onto a form (a label, an image box,
a edit box, a list box) those are components.  If you want to
add something new to your project, components are the way to
go.  Right now I'm designing a generic simulation system...
I've designed all the simulation devices as components...the
user simply drags a component onto their form, sets some
properties and away they go.  It's a little more complex than
this, but from a designer stand-point, components (properly
designed ones) can really simplify the visual design and all
the end-programming.

It's kind of hard to explain without actually demonstrating
the usefulness.
0

Featured Post

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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help on project with Soap 10 61
Convert GUI app into console app for Win32 Env 5 125
creating threads in delphi 1 157
Delphi Firemonkey : user drawing in window 3 17
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

740 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