Jump to content

Peet Terluin

Members
  • Content Count

    2
  • Joined

  • Last visited

Community Reputation

0 Neutral
  1. There are (as allways...) many ways to solve this, you can pick the solution you want. But ... there's no reason why "DoOnClick" in my earlier example cannot be strict private. It can. Unit5.pas
  2. Something like this will work. You need to use a "holder"-control for the eventmethods you want to assign. procedure TForm5.btnCreateControlClick(Sender: TObject); var btn: TButton; begin btn := TButton.Create(self); btn.Caption := 'Click'; btn.Left := 10; btn.Top := 10; btn.Parent := self; if IsPublishedProp(btn, 'OnClick') then SetMethodProp(btn, 'OnClick', GetMethodProp(fProcHolder, 'OnClick')); end; procedure TForm5.DoOnClick(Sender: TObject); begin ShowMessage('Hello'); end; procedure TForm5.FormCreate(Sender: TObject); begin fProcHolder := TEdit.Create(self); fProcHolder.OnClick := DoOnClick; end;
×