Home RAP
New Blog Posts: Merging Reports - Part 1 and Part 2

How to create RTTI a component with event (EventToRec)?

edited October 2005 in RAP
How to create RTTI a component with event (EventToRec)?
--
Vadim
?



--- posted by geoForum on http://delphi.newswhat.com

Comments

  • edited October 2005

    1. Event prop list

    If the event is not published, then override the GetEventList method and add
    it to the list. (if its published it will be added automatically).

    2. Event Id

    For each event, you need to have a unique event id - which is an integer
    used to identify the event and route it. ReportBuilder defines constants for
    the events that it uses. These are defined in ppTypes and prefixed with a
    'ci'.

    3. Event prop rec

    Override the GetPropRec method and add a call to EventToRec. For an example
    in ppVar.pas, the TraTppVariableRTTI.GetPropRec method has the following...
    (Note: ciComponentCalc and ciComponentReset are event id constants defined
    in ppTypes.)

    {events}
    if (CompareText(aPropName, 'OnCalc') = 0) then
    EventToRec(aPropName, ciComponentCalc, True, aPropRec)

    else if (CompareText(aPropName, 'OnReset') = 0) then
    EventToRec(aPropName, ciComponentReset, True, aPropRec)

    4. Event params

    If the event requires parameters, then override the GetParams method. For
    example in ppVar.pas, the TraTppVariableRTTI.GetParams method contains the
    following


    if (CompareText(aMethodName, 'OnCalc') = 0) or (CompareText(aMethodName,
    'OnReset') = 0) then
    begin
    Result := TraParamList.Create;

    Result.AddParam('Value', daVariant, nil, '', False, True);
    end


    5. Fire the event.

    To fire a RAP event, requires that the component send an event notification
    . For example, in ppVar.pas, the TppVariable.DoOnCalc method contains the
    following. Note that the event id ciComponentCalc is used.


    lParams := TraTppVariableRTTI.GetParams('OnCalc');
    lParams.CreateValuePointer(0, lValue);

    SendEventNotify(Self, ciComponentCalc, lParams);

    lParams.Free;





    --
    Nard Moseley
    Digital Metaphors Corporation
    http://www.digital-metaphors.com



    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited October 2005


    Those are simple integer constants. If applicable you can use any of the
    constants defined in ppTypes.pas. Otherwise defin and use your own custom
    id's. Sorry if that was not clear.


    --
    Nard Moseley
    Digital Metaphors Corporation
    http://www.digital-metaphors.com


    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited October 2005
    > EventToRec(aPropName, ciComponentCalc, True, aPropRec)

    ciComponentCalc - ???????

    I speak about new (my) events (constants such as ciComponentReset are
    unsuitable):


    TMyEvent = procedure(Sender: Tobject; MyObj: TMyRTTIObject);

    --
    Vadim



    --- posted by geoForum on http://delphi.newswhat.com
  • edited October 2005
    Thanks !
    --
    Vadim



    --- posted by geoForum on http://delphi.newswhat.com
This discussion has been closed.