raava403

Untitled

Sep 1st, 2020
1,201
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. unit MyComponent;
  2.  
  3. interface
  4.  
  5. uses
  6.     Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, ExtCtrls, Dialogs;
  7.  
  8. type
  9.     TCreateEvent = procedure of object;
  10.     TExecuteEvent = procedure(Response: String) of object;
  11.  
  12.     TMyComponent = class(TComponent)
  13.     private
  14.         { Private declarations }
  15.         FLocalIP: String;
  16.         FOnCreate: TCreateEvent;
  17.         FOnExecute: TExecuteEvent;
  18.     protected
  19.         { Protected declarations }
  20.     public
  21.         constructor Create();
  22.         destructor Destroy();
  23.         procedure Start;
  24.         procedure Stop;
  25.     published
  26.         property LocalIP: String read FLocalIP write FLocalIP;
  27.         property onCreate: TCreateEvent read FOnCreate write FOnCreate;
  28.         property onExecute: TExecuteEvent read FOnExecute write FOnExecute;
  29.  
  30.     end;
  31.  
  32. procedure Register;
  33.  
  34. implementation
  35.  
  36. constructor TMyComponent.Create(AOwner: TComponent);
  37. begin
  38.   if Assigned(FOnCreate) then
  39.     FOnCreate();
  40. end;
  41.  
  42. destructor TMyComponent.Destroy();
  43. begin
  44.     ShowMessage('destroyed');
  45. end;
  46.  
  47. procedure TMyComponent.Start();
  48. begin
  49.     if Assigned(FOnExecute) then
  50.         FOnExecute('executed');
  51. end;
  52.  
  53. procedure TMyComponent.Stop();
  54. begin
  55.     ShowMessage('stopped');
  56. end;
  57.  
  58. procedure Register;
  59. begin
  60.   RegisterComponents('Samples', [TMyComponent]);
  61. end;
  62.  
  63. end.
  64.  
RAW Paste Data