一个例子
unit HyperLabel;interfaceuses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Shellapi, StdCtrls;type
  THyperLabel = class(TLabel)
  private
    { Private declarations }
    FHoverFont: TFont;
    FHoverColor: TColor;
    FHoverCursor: TCursor;
    FOldCursor: TCursor;
    FOldFont: TFont;
    FOldColor: TColor;
    FOldScreenCursor: TCursor;
    FOnMouseEnter: TNotifyEvent;
    FonMouseLeave: TNotifyEvent;
    FURL: string;
    FHCursor: HCURSOR;
    procedure FSetHoverFont(value: TFont);
    procedure FSetHoverColor(value: TColor);
    procedure FSetOnMouseLeave(value: TNotifyEvent);
    procedure FSetOnMouseEnter(value: TNotifyEvent);
    procedure FSetHoverCursor(value: TCursor);
    procedure FSetURL(value: string);
  protected
    { Protected declarations }
    procedure cmmouseenter(var Msg: TMessage); message CM_MOUSEENTER;
    procedure cmmouseleave(var msg: TMessage); message CM_MOUSELEAVE;
  public
    { Public declarations }
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    procedure Click; override;
  published
    { Published declarations }
    property URL: string read FURL write FSetURL;
    property HoverFont: TFont read FHoverFont write FSetHoverFont;
    property HoverColor: TColor read FHoverColor write FSetHoverColor stored true default clBtnFace;
    property HoverCursor: TCursor read FHoverCursor write FSetHoverCursor stored true default crHandPoint;
    property OnMouseEnter: TNotifyEvent read FOnMouseEnter write FSetOnMouseEnter;
    property OnMouseLeave: TNotifyEvent read FonMouseLeave write FSetOnMouseLeave;
  end;procedure Register;implementationprocedure Register;
begin
  RegisterComponents('LZJ', [THyperLabel]);
end;{ THyperLabel }procedure THyperLabel.Click;
var
  Temp: string;
begin
  inherited;
  Temp := Copy(FURL, 1, 5);
  if UpperCase(Temp) = 'HTTP:' then
    ShellExecute(Parent.Handle, 'open', 'explorer.exe', pchar(FURL), nil, SW_SHOW)
  else
    ShellExecute(Parent.Handle, 'open', pchar(FURL), nil, nil, SW_SHOW);
end;procedure THyperLabel.cmmouseenter(var Msg: TMessage);
begin
  FOldFont.Assign(Font);
  Font.Assign(FHoverFont);  FOldColor := Color;
  Color := FHoverColor;  FOldCursor := Cursor;
  FHCursor := LoadCursor(0, IDC_HAND);
  FOldScreenCursor := Screen.Cursors[crHandPoint];
  Screen.Cursors[crHandPoint] := FHCursor;
  Cursor := crHandPoint;  if Assigned(FOnMouseEnter) then
    FOnMouseEnter(Self);
end;procedure THyperLabel.cmmouseleave(var Msg: TMessage);
begin
  Font.Assign(FOldFont);
  Color := FOldColor;
  DestroyCursor(FHCursor);
  Screen.Cursors[crHandPoint] := FOldScreenCursor;
  Cursor := FOldCursor;
  if Assigned(FonMouseLeave) then
    FOnMouseLeave(Self);
end;constructor THyperLabel.Create(AOwner: TComponent);
begin
  inherited;
  URL := 'mailto:[email protected]';
  FHoverFont := TFont.Create;
  FOldFont := TFont.Create;
  FHoverFont.Assign(Font);
  FHoverFont.Color := clBlue;
  FHoverFont.Style := FHoverFont.Style + [fsUnderLine];
  FHoverColor := clBtnFace;
  FHoverCursor := crHandPoint;
end;destructor THyperLabel.Destroy;
begin
  FHoverFont.Free;
  FOldFont.Free;
  inherited;
end;procedure THyperLabel.FSetHoverColor(value: TColor);
begin
  if FHoverColor <> value then
    FHoverColor := value;
end;procedure THyperLabel.FSetHoverCursor(value: TCursor);
begin
  if value <> FHoverCursor then
    FHoverCursor := value;
end;procedure THyperLabel.FSetHoverFont(value: TFont);
begin
  FHoverFont.Assign(value);
end;procedure THyperLabel.FSetOnMouseEnter(value: TNotifyEvent);
begin
  if @FOnMouseEnter <> @value then
    FOnMouseEnter := Value;
end;procedure THyperLabel.FSetOnMouseLeave(value: TNotifyEvent);
begin
  if @FonMouseLeave <> @value then
    FonMouseLeave := value;
end;procedure THyperLabel.FSetURL(value: string);
begin
  if Uppercase(value) <> Uppercase(FURL) then
    FURL := value;
end;end.

解决方案 »

  1.   

    你所说的类,应该可以说是DELPHI控件,你多一些查看DELPHI的VCL控件的源码吧,相信对你有用
      

  2.   

    最简单的例子:
    unit Unit1;
    interface
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;
    type
      TForm1 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
      T1 = class
        private
            member1 : integer;
        public
            function func1 : Integer; virtual;
            function func2 : Integer; virtual;
            function func3 : Integer; virtual;
        end;
      T2 = class(T1)
        private
            member2 : integer;
        public
            function func1 : Integer; override;
            function func2 : Integer; override;
        end;
    var
      Form1: TForm1;
    implementation
    {$R *.dfm}
    function T1.func1:integer;
     begin
      showmessage('T1.func1');
      result:=0;
     end;
    function T1.func2:integer;
     begin
      showmessage('T1.func2');
      result:=0;
     end;
    function T1.func3:integer;
     begin
      showmessage('T1.func3');
      result:=0;
     end;
    function T2.func1:integer;
     begin
      showmessage('T2.func1');
      result:=0;
     end;
    function T2.func2:integer;
     begin
      showmessage('T2.func2');
      result:=0;
     end;
    procedure TForm1.Button1Click(Sender: TObject);
      var O : T1;
       begin
         O := T2.Create;
         O.func1;
         O.func3;
         O.Free;
       end;
    end.
      

  3.   

    我把格式给你就行了
    首先声明类型
    type 类名= class(基础类类型)
         类的成员;
    声明类的实例
    var 类的实例的名:类名;
    对实例赋值
     类的实例.类的成员:=值;
      

  4.   

    type 
        MyClass = class
          a: mytype;
          ...        //变量      function myfun1( ... ): mytype1;
          ...
                    //函数
         end;
      

  5.   

    type
      TForm1 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      protected
        procedure DoSome; virtual; abstract;
      public
        { Public declarations }
      end;  TMyForm1 = class(TForm1)
      protected
        procedure DoSome; override; 
      end;  TMyForm2 = class(TForm1)
      protected
        procedure DoSome; override; 
      end;
    procedure TMyForm1.DoSome; 
    begin
      ShowMessage('TMyForm1');
    end;
    procedure TMyForm2.DoSome; 
    begin
      ShowMessage('TMyForm2');
    end;
      

  6.   

    http://www.csdn.net/expert/topic/695/695211.xml?temp=.285763
    看一看,有好处的
      

  7.   

    我想你说的是如何学习在DELPHI里实现面向对象吧.
    把private,public,protect,published,dynamic,virtual,abstract
    property ,event....那些搞明白了,找几个API风装一个类,
    应该就差不多会了:).