Custom control
I have a TfrxPictureView object that uses some custom logic in the OBP event to obtain a picture from a file based on a value passed in another field of the database. This works well.
However, I would like to give my users the option of designing their own reports and want to hide this logic from them so they can just drag a modfied/descendant of PictureView onto their report.
Rather than write a custom control from scratch is there an example of modifying a control just to include some logic in an event such as this?
However, I would like to give my users the option of designing their own reports and want to hide this logic from them so they can just drag a modfied/descendant of PictureView onto their report.
Rather than write a custom control from scratch is there an example of modifying a control just to include some logic in an event such as this?
Comments
I have something similar but is personalized for my application and I need to work a little to extract.
If you have sources look a little to TfrxPictureView and TfrxPictureView.GetData.
Copy all TfrxPictureView object and modify it to your needs. I deleted more than half from TfrxPictureView.
In GetData you need to call your procedure to get the image.
You can pass an ID into the table field and your function will fill FPicture accordingly.
If you want to add a new property to the component do not forget to write into TfrxPictureView.Diff(). For me it was a pain to understood why I loos the values.
Something like:
Best Regards,
Cristian Peta
I want to create a descendant of tfrcMemoView that automatically does the above and hides it from my users. I can't see which files I need to edit, or whether I need to edit any files but rather create new ones. I cant see how FR will know where/how to pick up my custom component once I have written it.
I assume that I need to write in Pascal/Delphi rather than C++
Does anyone have an idiots guide (preferably a very small example of a similarly modified component - rather than creating a component from a base class) with step by step instructions of which files to edit and why?
I have read the following in the developers manual
FastReport Class Hierarchy
Writing Custom Report Components
Thanks
I attached an example of bitmap component that print the bitmap from a TBitmap array named MyImageList.
Simply add FastReport_Comp to your uses clause and you have the component that print an image from your list. The image index is from DataField.
With C++ you know the best what you need to do more.
There is a resource identifier frxWA_MyBmpImage that you need to have it into the project resources.
I have not tested this component because this is a light version of my image component.
Best Regards,
Cristian Peta
I add your component to my project and try to compile ag get the error below. I am using C++ Builder XE3 (I dont have Delphi - although clearly the compiler seems to be there)
I am wondering whether this is a fundamental flaw in my understanding of what goes on here - do I need to recompile fastreports to make the component 'visible', can I actually recompile fast reports?
[DCC Fatal Error] fastreport_mycomp.pas(1): F1027 Unit not found: 'System.pas' or binary equivalents (.dcu)
Does anyone else on here actually write custom components in using Builder rather than Delphi?
try to search google with "Mixing C++Builder and Delphi code"
Or maybe is easy to translate pascal to C.
Recompiling FR is not necessary from what I know.
Best Regards,
Cristian Peta
In my custom component, i override Diff but it is never used so I loose my own properties.
I've made a simple arrow (like in Developer Manual) with an integer property.
Hello
If you post your component here I can take a look.
Best Regards,
Cristian Peta
Thanks for your answer.
Here it is a test project that I'm using to test custom components.
Anyway, I have advanced on my problem and now I think I know why it doesn't work but I don't know how to fix it.
What I want is to pass some parameters to my component on the event OnBeforePrint. I successed with it but when the Report is drawn, a totally new instance of my component is created and this instance doesn't shoot any event so I have not access to give it these parameters.
How can I dinamically modify a custom component? Is it normal what happened in my project? The new instance should have exactly the same values on all properties that the instance that shoot the OnBeforePrint, isn't it?
I hope you could help me.
Thanks in advance.
I used C++ more than ten years ago and now I am a Delphi guy... but I hope I can help you.
1. Diff() works well with public properties. You must have a public property numero so FastReport can write into.
2. I use only Diff() and do not use AllDiff()
Best Regards,
Cristian Peta
I used AllDiff() to see if it work but it doesn't.
I made a public property but I see that Diff() method is never called, maybe that is my problem. When has FastReport to call Diff() method?
Thanks again!
actually my properties are published. Maybe is not enough to be public. I know, the user will see them.
And Diff() is called only to store values after prepare the report. The FastReport store your values caling Diff(). And when show the report, RTTI is used to restore values in newly created objects.
And one more thing. You must override Diff() function in your object and not declare it virtual. Because this your Diff is not called.
Best Regards,
Cristian Peta
I created my component, I registered It but I can't see it in designer ?
Forgot something?
Join my component here...
Thx a lot.
Christof