SVG registration issue has been resolved by remote assistance from TMS Software
Recently, we're facing a very strange couple of issues related to using SVG image within FNC components from TMS Software like TMS Ribbon and VCL components using images in general like TBitButton or TSpeedButton. The problems have arisen after unifying existing SVG class for VCL and FMX into one class as TMS mentioned in its blog:
"The initial approach was delivering SVG support in FNC and this meanwhile runs accross all of our FNC products. At some point in time the question came for supporting SVG in TMS VCL UI Pack. As double class registration is not possible in RAD Studio, we worked around this by registering 2 SVG classes. Afterwards, we noticed registering both classes simultaneously breaks the application at designtime. This could be fixed by including the required units to register the class at runtime as well. Updating packages sometimes changed the order and because of that, SVGs that were loaded at designtime did not load properly. We have now implemented a permanent fix and this means that TMS VCL UI Pack and FNC are now simultaneously working with a single SVG class."
We were also warned that certain difficulties could occur while transition to the new approach and these issues were described clearly. In my case, existing SVG images were displayed properly on buttons or toolbars, nevertheless, I met two different issues:
- newly added SVG images were not visible in concerned TADVSVGImageCollection, I could have seen only filenames
- newly added SVG images into TTMSFNCImageContainer weren't displayed full-sized and correctly but they were misshapen
We exchanged some mail messages with technical support of TMS, I sent required screenshots, tried to create new test project but there was still unclear what is the reason of both issues. Consequently, colleagues from TMS (Mr. Scheldeman) offered a remote session through Teamviewer to be able to identify the cause and to propose a viable solution.
After almost an hour of investigation and trying out many approaches Mr. Scheldeman discovered the reason - wrong (or concurrent) SVG registration in one unit of FastReport VCL package. First proposal for the solution was - we'll contact Fast reports and ask for rectifying this drawback. However, the problem has been resolved quickly and efficiently.
During the TeamViewer session, Mr. Scheldeman created a very special BPL package named ZFixSVG that corrects concurrent SVG registration without the necessity of modifying the FastReport units. The content of this package is following:
unit UFixSVG; interface uses Classes, VCL.Graphics, VCL.TMSFNCTypes; implementation initialization begin begin TPicture.RegisterFileFormat('SVG', 'Scalable Vector Graphics', TTMSFNCSVGBitmap); end; end; finalization begin TPicture.UnregisterGraphicClass(TTMSFNCSVGBitmap); end; end.
Main BPL package structure is a quite simple:
UFixSVG must be compiled and installed then - it is displayed as a normal package among other ones:
This unexacting but extremely efficient workaround saved a lot of my programmer's time and allowed me to continue my job without interruption or uncertain modification the code of other component packages. Many thanks for a such superb support!
About the AuthorIng. Karel Janecek, MBA, MSc.