delphi里面怎样新建一个类啊?

解决方案 »

  1.   

    敲一下classf再Ctrl + J,  快吧:)
      

  2.   

    type
      TNewClass = class
      public
        constructor Create; virtual;
        destructor Destroy; override;
      end;//
    with TNewClass.Create do
    try
    finally
      Free;
    end;
      

  3.   

    unit;
    interface;
    type
      TNewClass = class
      public
        constructor Create; virtual;
        destructor Destroy; override;
      end;implementationconstructor TNewClass.Create;
    begin
    end;destructor Destroy;
    begin
    end;end.
      

  4.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TMyClass=Class(TButton)
        Private
           {私有声明}
        Protected
           {保护声明}
        Public
           Procedure MyShowMessage();
           {公有声明}
      end;//声明自己的类
      TForm1 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}Procedure TMyClass.MyShowMessage();
    begin
      Showmessage('MyTestDiaLog');
    end;procedure TForm1.Button1Click(Sender: TObject);
    Var
      MyClass:TMyClass;
    begin
      try
        MyClass:=TMyClass.Create(self);//实例化
        MyClass.MyShowMessage();
      finally
        MyClass.Free;
      end;
    end;end.
      

  5.   

    敲一下classf再Ctrl + J,  快吧:)NB!
      

  6.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TMyClass=Class(TButton)
        Private
           {私有声明}
        Protected
           {保护声明}
        Public
           Procedure MyShowMessage();
           {公有声明}
      end;//声明自己的类