The THtmlViewer component is a component that displays HTML in a Delphi/C++ Builder form. It is also used by the outstanding TRichView component for importing HTML. It is available under the MIT license, so it can be used in commercial projects. It is hosted on Google Code : http://code.google.com/p/thtmlviewer/. It can be downloaded using subversion as described here: http://code.google.com/p/thtmlviewer/source/checkout, and as noted on that page,
# Non-members may check out a read-only working copy anonymously over HTTP.
svn checkout http://thtmlviewer.googlecode.com/svn/trunk/ thtmlviewer-read-only
The author of TRichView recommends that you NOT use the trunk version, but rather branch 11:
svn checkout http://thtmlviewer.googlecode.com/svn/branches/11/ thtmlviewer-read-only
The 2010 Delphi project imports into Delphi XE and compiles, and you can install the resulting package, but the components only show up when running Delphi!
To create the components for C++ projects, you need to create a C++ package, but NOT using File/New/Package — C++ Builder
Instead, Component/Install Component, Install into new package, select the same .pas files used in the Delphi package (basically, all of them in the source folder)
You then need to name the package and choose its save location (for the package folder). You can give it a description, which will later show up in the Component/Install Packages… dialog
Make sure to specify that you want a C++ Package, not a Delphi package. Select Finish, and your package will be created, although linking will fail with an error.
You have more work to do before it will work properly. You need to specify the -LUDesignIDE option to the Delphi compiler — in the Project Options/Delphi Compiler/Compiling/Other options/Additional options to pass to the compiler, include “-LUDesignIDE” (without the quotes). Be sure to use the correct build configuration at the top of the dialog — you will want a Release build, so select Base or Release.
Also, Delphi needs to know to make the .hpp files, etc. In the — in the Project Options/Delphi Compiler/Compiling/Output – C/C++ / C/C++ Output file generation, pick “Generate all C++ Builder files (including package libs)” so you get the header files as well as the package lib to install.
Finally, when you try to install the package, you will get an error that it conflicts with a file included in the vclimg150 package. The solution is to include vclimg150.bpl in the Requires list for the package. Right-click on Requires, and add vclimg150.bpl (just type the name — you don’t need to browse to the file, and when it shows up in the requires list, it will be vclimg.bpi, even though you typed vclimg150.bpl)
Now, pick the Release build, and build it (In the Project Manager, open up Build Configurations, right click on Release, and select Build)
Then, you need to install it, using Component/Install Packages .
First, save and close your THTMLViewer C++ Project. Then, WITH NO PROJECTS OPEN, Select Component/Install Packages… THTMLViewer should not be listed in the design packages check list box.
Click Add… , and go to the directory where your library was placed (this is set under Project/Options for the project that made the THTMLViewer component — by default under Windows 7 and RADStudio XE it is C:UsersPublicDocumentsRAD Studio8.0Bpl . Select the .bpl package library that you just made, and click OK.
Then, you can create a new C++ Project, and you should be able to select the THtmlViewer component and drop it on the form. Make a FormCreate handler, containing the line HtmlViewer1->LoadFromString(WideString(“Hello”)); . Compile the project, and it may complain about missing .h files. Just browse to the source directory, where the .hpp files should be. You can select the .hpp file even though RAD Studio is looking for the .h file. If it compiles and you see “Hello” in the window, you know you are done!
Incidentally, creating the component project under Delphi is easier than under C++ Builder — Delphi automatically recognizes and fixes the vclimg150 problem, presenting it in a dialog box, with “OK” to add the reference and rebuild the component. Also, Delphi automatically installs the component. However, the component does not install under both C++ Builder and Delphi at the same time (I could not figure out how to do that), and since I don’t really need it under Delphi, I did not pursue it.