Delphi控件开发(三)TUrlEdit

unit UrlEdit;

interface

uses
  Windows, SysUtils, Classes, Controls, StdCtrls, Dialogs, ShellAPI, Forms, Messages, Graphics;

type
  TUrlEdit = class(TEdit)
  private
    { Private declarations }
  protected
    { Protected declarations }
    procedure KP(Sender: TObject; var Key: Char);
  public
    { Public declarations }
    constructor Create(a: TComponent);override;
  published
    { Published declarations }
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Samples', [TUrlEdit]);
end;

{ TUrlEdit }

{ TUrlEdit }

constructor TUrlEdit.Create(a: TComponent);
begin
  inherited Create(a);
  OnKeyPress := kp;
end;

procedure TUrlEdit.KP(Sender: TObject; var Key: Char);
begin
  if Key = #13 then
    ShellExecute(Application.Handle,nil,PChar(text),nil,nil,SW_NORMAL);
  inherited;
end;

end.

你可能感兴趣的:(Delphi控件开发(三)TUrlEdit)