Component Template
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.
AI
AI 摘要: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
源代码
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: OpenSave Clear Exit 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); begin if OpenDialog1.Execute then Memo1.Lines.LoadFromFile(OpenDialog1.FileName); end;Double-Click on the second Button (The Save button) and enter this code: procedure TForm1.Button2Click2(Sender: TObject); begin if SaveDialog1.Execute then begin Memo1.Lines.SaveToFile(SaveDialog1.FileName); end; end;Double-Click on the third Button and enter this code: procedure TForm1.Button3Click2(Sender: TObject); begin Memo1.Clear; end;Double-Click on the forth button and add this code: procedure TForm1.Button4Click2(Sender: TObject); begin Close; end;Click on the OpenDialog1 component and in the Object Inspector double-click on Filter, then put in this text: TXT *.txt 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!
原始评论 (3)
从 Wayback Machine 恢复