delphi - Passing methods as parameters on a deserialized form with no ClassType -


I'm effectively trying to deserialize a form.

One of the items in the serial form, which takes a series of events in the form of parameters.

Now that I do not have the class type of the object, when I am deserializing, I have a method that Adder has been declared this way:

  process TMyDeserializer.AddMethod (ControlName, EventName: string; MethodAddr: Pointer); Var TargetControl: TControl; Method: TM method; If not assigned (TempForm) then exit; If TempForm.Name = ControlName then targetControl: = TempForm Other TargetControl: = TempForm.FindChildControl (ControlName); If assigned (target control) starts with method. Code: Add method; Method.Data: = TargetControl; SetMethodProp (Target Control, Event Name, Method); End; End;  

so that I can keep the by-laws in different controls, as I have deserialized them, I need to add the problem as a list of parameters (not for control ). E.g.

SetUpEvents (EventHandler 1: TNotifyEvent; EventHandler 2: TNotifyEvent);

Where EventHandler1 and EventHandler 2 are defined anywhere in the code

  Process Event Handler 1 (Sender: TNotifyEvent); Start / End something;  

These are not methods but sub-rootin alone is standing.

When I assign objects to them, substratting does not need to be part of an object because the AddMethod process handles it like a call

  MyDeserializerInstance.AddMethod (' Button 1 ',' onclick ', @ eventhandler1);  

This works for standard event handlers, such as button 1.nonclick, but not if I want to /

  process SetUpButton1Click ( Method: TNotifyEvent starts TButton (MyDeserializerInstance.TempForm.FindChildControl ('Button1')). OnClick = method; End;  

The problem is that I can not set substrate as a method of method. Set-up process

The created form is not declared in the interface and is fully defined by the file, which is read by some alone alone routine in the code.

So I think the question is, how to turn sub-method (after creating an object) is considered part of it in a method when running, and if I can not do that How can I pass sub-routes in the code as a parameter in another method?

So far I've tried to cover a TMethod as the correct type of event and fill in it. Data as TempForm It has been called correctly but the parameters are scrambled.

Delphi version is 2007

hidden in non-static class methods < Code> Self is the input parameter that is called the method. Is the one that corresponds to the TMethod.Data field. To use a standalone process for an event that expects a class method, in this process there must be an additional parameter defined to represent the Self parameter so that the value is TMethod. Data has to go somewhere, that is:

  process button 1ClickHandler (self: pointer; sender: tubageet); Start / End something; MyDeserializerInstance.AddMethod ('Button 1', 'OnClick', @ Button1ClickHandler);  

Your AddMethod () implementation is designating TargetControl as the TMethod.Data value, hence the Self and The sender will point to the same object on the runtime, but it's okay.

Without defining the obvious self parameter, it explains why your parameters are "scrambled" when the process is called runtime, hidden self value Assigning sender parameter, and the actual sender value is not being ignored.


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -