Component Template

Submitted on: 1/1/2015 1:05:00 AM
By: Anonymous (from psc cd)  
Level: Beginner
User Rating: By 3 Users
Compatibility: Delphi 5, Delphi 4, Pre Delphi 4
Views: 4414
     Here is an example showing how to use the Component Template. You will find it under 'Component' on the Delphi menu. Component Templates are very handy, yet very simple to use.

				irst start with a blank Form.
Add a Panel, and set Panel1.Align to alTop.
Drop 4 Button components on Panel1 in a row.
Put these names in the Buttons Captions:
In that order.
Next drop a StatusBar component on the Form, this should be aligned to alBottom.
Then drop a TMemo on the Form, and set its Align Property in the Object Inspector to alClient.
Next drop a OpenDialog component on the Form and a SaveDialog component.
Double-Click on the first Button, this is the Button with Open as its caption.
Then enter this code (the code between Begin & End;):
procedure TForm1.Button1Click2(Sender: TObject);
 if OpenDialog1.Execute then
end;Double-Click on the second Button (The Save button) and enter this
procedure TForm1.Button2Click2(Sender: TObject);
 if SaveDialog1.Execute then
end;Double-Click on the third Button and enter this code:
procedure TForm1.Button3Click2(Sender: TObject);
end;Double-Click on the forth button and add this code:
procedure TForm1.Button4Click2(Sender: TObject);
end;Click on the OpenDialog1 component and in the Object Inspector double-click on Filter, then put in this text:
All files *.*Do the same for the SaveDialog component.
Here comes the nifty part.
Go up to Edit in the Delphi menu and then
click on Select All then...
Click on Component in the Delphi file menu, then click on Create Component Template...
Type in the name you wish to use for the component template.
You can leave the Palette page name as Template.
And pick an icon for the new Template.
Click on OK and that's it.
Start a new project, go to the Template palette and click on your new component template.
Drop this on the Form and run the program.
And there you have it, an instant text editor.
You can set the StatusBar anyway you want.Just another amazing thing you can do with Borland's Delphi!

Other 4 submission(s) by this author


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this article (in the Beginner category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)

Other User Comments

 There are no comments on this submission.

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular article, please click here instead.)

To post feedback, first please login.