home *** CD-ROM | disk | FTP | other *** search
- unit NewComp;
-
- { Program copyright (c) 1995 by Charles Calvert }
- { Project Name: FRM2COMP }
-
- {
-
- Converting Forms into Components
- ================================
-
- The description below is of a kluge, but it is a very
- useful kluge.
-
- This is a form that has been converted into a component.
- You can still edit it in the form designer as if it were a
- form, however, you should not try to make it part of
- project, but should choose, File | Open File, and load
- it into Delphi, edit as you please, then close it out.
-
- Make sure that its DFM file does not include the
- following lines:
-
- PixelsPerInch = 96
- TextHeight = 16
-
- More generally, make sure it does not contain any properties
- that are not part of TPanel. To get rid of them, you need to
- translate the DFM file to text, delete them, then translate
- the file back into a DFM file. Do it either in the editor, or
- else use the CONVERT.EXE command line utility. After
- you have converted the Text file back into a DFM,
- rebuild your project.
-
- Inside the DFM file, give the main object its own name:
-
- object CompForm: TCompForm
- Left = 15
- Top = 22
- Width = 435
- Height = 300
- Caption = 'Form2'
- Font.Color = clWindowText
- Font.Height = -13
- Font.Name = 'System'
- Font.Style = []
- object SpeedButton1: TSpeedButton
- Left = 168
- Top = 96
- Width = 25
- Height = 25
- end
- object BitBtn1: TBitBtn
- Left = 32
- Top = 24
- Width = 89
- Height = 33
- Caption = 'BitBtn1'
- TabOrder = 0
- end
- object BitBtn2: TBitBtn
- Left = 136
- Top = 24
- Width = 89
- Height = 33
- Caption = 'BitBtn2'
- TabOrder = 1
- end
- end
-
-
- }
-
- interface
-
- uses
- SysUtils, WinTypes, WinProcs,
- Messages, Classes, Graphics,
- Controls, Forms, Dialogs,
- StdCtrls, Buttons, ExtCtrls;
-
- type
- TCompForm = class(TPanel)
- BitBtn1: TBitBtn;
- BitBtn2: TBitBtn;
- Panel1: TPanel;
- Label1: TLabel;
- procedure BitBtn1Click(Sender: TObject);
- procedure BitBtn2Click(Sender: TObject);
- private
- { Private declarations }
- public
- Constructor Create(AOwner: TComponent); override;
- { Public declarations }
- end;
-
- var
- CompForm: TCompForm;
-
-
- implementation
-
- {$R *.DFM}
-
- constructor TCompForm.Create(AOwner: TComponent);
- begin
- inherited Create(AOwner);
- IsControl := True;
- Caption := '';
- ReadComponentRes(ClassName, Self);
- end;
-
- procedure TCompForm.BitBtn1Click(Sender: TObject);
- begin
- Label1.Caption := BitBtn1.Caption;
- end;
-
- procedure TCompForm.BitBtn2Click(Sender: TObject);
- begin
- Label1.Caption := BitBtn2.Caption;
- end;
-
- end.
-