Solved

COMPonents

Posted on 1997-05-06
5
232 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Seems like we have an echo here ;^)
0
 
LVL 3

Expert Comment

by:mheacock
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

762 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

9 Experts available now in Live!

Get 1:1 Help Now