Solved

Component

Posted on 2004-04-26
5
236 Views
Last Modified: 2010-04-04
Hello,

I have a .pas file with all my fav functions I have made ect. I want to make it into a drop Component I can put on my projects, Also I want to beable to pic the icon of what the Component is..

Thanks Newt
0
Comment
Question by:GreenNewt
5 Comments
 
LVL 11

Accepted Solution

by:
shaneholmes earned 325 total points
ID: 10922205
Ok,

You will need to derive your new component from TComponent:

Do the following from Delphi Main Menu:

File\New\Other

Double CLick on Component



Select TComponent as Ancestor Type

For Class Name, give it the name you want to give it, example: TMyComponent

Selectthe palette page you want it to reside on, or enter a new one

The point where you want the unit to be saved and give it a name

Example

C:\Program Files\Borland\Delphi7\Lib\MYCOMP.pas

Note: Do not name the file as the same name as component

Then Hit install, and add all your functions and procedures to it, and then compile.









0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10922233
as for adding a component image, you will need to create a  resource file using the image editor included
with Delphi, then in that resource file add a new Bitmap 24x24 (16 colors is what I use) name that
bitmap the same as the name of the new class, so if your new class is TMYCOMPONENT the bitmap would be
named TMYCOMPONENT as well then after you get done with that when you save the resource file itself name it the same as the component's .pas file except use a .dcr extenstion e.g.

If you component is contained in a unit named MyComp.pas you would save the resource file as MyComp.dcr, if this dcr files accessible during the compile then that will be the bitmap used to represent your component on the palette and when you drop it on forms.

Shane
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 10922247
is fav = favorite ?
What is a component ?
You can use 1 or more TEdits, TMemos or TLabels in the same project and every of them is independent and working as individually....
What about your fav functions (if fav = favorites) ? It is enough to be placed into a unit. Then this unit is declared into the uses clause of every other unit which calls one or more of favorite mwthods.
It is not necessary to be a components, you don't need more instances of it....
emil
0
 
LVL 26

Expert Comment

by:Russell Libby
ID: 10922252
Regarding the component resource (which controls the component image in), you should use the Image Editor that comes with Delphi.

File | New | Component Resource
Resource | New | Bitmap
Height and width should be set to 24x24, 16 color
Rename this image to be that of the component (TWhatever)

Save the .dcr file with the same filename that the component unit is called.

So you should have

compsource.pas
compsource.dcr

-----------

Regards,
Russell

0
 

Author Comment

by:GreenNewt
ID: 10922327
Thx
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

744 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

11 Experts available now in Live!

Get 1:1 Help Now