home *** CD-ROM | disk | FTP | other *** search
/ Delphi Programming Unleashed / Delphi_Programming_Unleashed_SAMS_Publishing_1995.iso / misc / objects / subcomp / subcomp.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-03-21  |  1.2 KB  |  60 lines

  1.   unit Subcomp;
  2.  
  3. { Program copyright (c) 1995 by Charles Calvert }
  4. { Project Name: SUBCOMP }
  5.  
  6.   { Create a TPanel descendant with objects on it. Shows how to
  7.     use wm_Create messages to access methods not available to
  8.     you in the constructor.
  9.   }
  10.  
  11.   interface
  12.  
  13.   uses
  14.     Classes, Controls, StdCtrls,
  15.     ExtCtrls, Messages;
  16.  
  17.   type
  18.     TMyPanel = class(TPanel)
  19.     private
  20.       FMyEdit: TEdit;
  21.     protected
  22.       procedure wmCreate(var M: TMessage); message wm_Create;
  23.     public
  24.       constructor Create(AOwner: TComponent); override;
  25.  
  26.     end;
  27.  
  28.   procedure Register;
  29.  
  30.   implementation
  31.  
  32.   procedure Register;
  33.   begin
  34.     RegisterComponents('Unleashed', [TMyPanel]);
  35.   end;
  36.  
  37.   constructor TMyPanel.Create(AOwner: TComponent);
  38.   begin
  39.     inherited Create(AOwner);
  40.     Visible := True;
  41.     Width := 100;
  42.     Height := 100;
  43.     FMyEdit := TEdit.Create(Self);
  44.     FMyEdit.Parent := Self;
  45.     FMyEdit.Left := 5;
  46.     FMyEdit.Top := 5;
  47.     FMyEdit.Height := 25;
  48.   end;
  49.  
  50.   { You can't access ClientWidth in the Create method,
  51.     so respond to wm_Create message }
  52.   procedure TMyPanel.wmCreate(var M: TMessage);
  53.   begin
  54.     inherited;
  55.     FMyEdit.Width := ClientWidth - 10;
  56.   end;
  57.  
  58.   end.
  59.  
  60.