Links
EControl Form Designer Pro
TzFormDesigner.OnSetScriptProc Property

Occurs when method property editor assigns script procedure to the event.

property OnSetScriptProc: TSetScriptProcEvent;

Write this event handler to save association between event property end script procedure.

OnGetMethodNames, OnRenameMethod, OnShowMethod, OnGetScriptProc

In this sample associations of script procedures and properties are stores in TStrings object (property Items in list box EventsList) with items - <ObjectName>.<PropertyName>=<ScriptProcedure> 

 

procedure TForm4.zFormDesigner1SetScriptProc(Sender, Instance: TObject;
  pInfo: PPropInfo; const EventProc: String);
var idx: integer;
    pn: string;
begin
  if Instance is TComponent then
   begin
    // event name for root object is without object name
    if zFormDesigner1.Root = Instance then
      pn := PInfo^.Name
    else
      pn := (Instance as TComponent).Name + '.' + PInfo^.Name;
    // Delete previous association
    idx := EventsList.Items.IndexOfName(pn);
    if idx <> -1 then
      EventsList.Items.Delete(idx);
    // Add new association
    if EventProc <> '' then
     begin
      // Saving associating
      EventsList.Items.Add(pn + '=' + EventProc);
      // Creating event handler text body
      CreateMethod(EventProc, Instance, pInfo);
     end;
   end;
end;
Copyright (c) 2004 - 2011 EControl Ltd.. All rights reserved.
What do you think about this topic? Send feedback!