Solved

Component

Posted on 2004-04-26
5
243 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

752 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