[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 143
  • Last Modified:

Dynamically Created Components In The Other Unit

How can I create component's (runtime) in secundary unit and add some notify_event's on it? If I create it in form it works, but in other unit ...
0
arttu
Asked:
arttu
1 Solution
 
GreymanCommented:
I will assume that youu have created a form called MyForm.  (You'll need to fix up the uses statements that are missing)

So here we are in

unit OtherUnit;

interface
   
type
  TMyClass = class
  private
    procedure ShowEvent(Sender : TObject);
  public
    procedure ShowMyForm;
  end;

implementation

procedure TMyClass.ShowEvent(Sender : TObject);
begin
  ShowMessage('I happened');
end;

procedure TMyClass.ShowMyForm;
var
  MyInstance : TMyForm;
begin
  MyInstance := TMyForm.Create(Application);
  MyInstance.OnShow := ShowEvent;
  MyInstance.Show;
end;
 
0
 
arttuAuthor Commented:
Thanks
0

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now