Solved

Component

Posted on 2004-04-26
5
239 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how to center only a line in richedit? 4 59
Print Graphic and Text to Epson TM-T88v 12 264
How to debug For loops? 3 50
control image tags in a string ? 12 134
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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

832 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