Finding an object in a report by type

I see from the manual that you can find an object in a report by name, i.e.

TfrxMemoView * Memo = dynamic_cast <TfrxMemoView *> (frxReport1->FindObject("Memo1"));

This does not really help if you are parsing a user designed report and they have assigned some arbitrary name to a component.

However I have a custom component that can be used in a report and I just want to know if this component has been used in a particular report. So I am after something along the line sof

TfrxMemoView * Memo = dynamic_cast <TfrxMemoView *> (frxReport1->FindObjectType(TfrxMemoView));

Can this be done?

Comments

  • edited 7:46AM
    Can this be done?
    I think of such a method:
    - Give your component a special Type,
    - Search through ALL objects of the report,
    - Check if any of its object is of Type you've created for your component.

  • I thought iterating through all components would do the trick but I couldn't see how to do that in the manual - i'll have another look.
  • edited 7:46AM
    I thought iterating through all components would do the trick but I couldn't see how to do that in the manual - i'll have another look.
    Yes, that needs an iterating!
    You can search for knowledge: in manuals, in this forum, through tickets support, and ... hours of testing by yourself.
    No way of those above gives one the whole solution :-(

    My suggestion for an iterating (I did for FastReport script, didn't try to see that in compiler):
    for i:=0 to (Report.AllObjects.Count - 1) do with TObject( Report.AllObjects.Items[i]) do
      if Classname = 'TfrxMemoView' 
        then ShowMessage( TfrxMemoView( Report.AllObjects.Items[i]).Name + #13 +
                          TfrxMemoView( Report.AllObjects.Items[i]).Text)
        else ShowMessage( TfrxComponent( Report.AllObjects.Items[i]).Name);
    
  • Thanks Mick I'll try and have a play later

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.