Solved

COMPonents

Posted on 1997-05-06
5
234 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
  • 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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
Printing problem 2 101
Multiple image collision 13 80
how to update exe applicatio from internet ? 6 86
How to convert memory stream to PDF file 6 104
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…
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

791 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