Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Component

Posted on 2004-04-26
5
Medium Priority
?
249 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 1300 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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

824 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