Sign in Join
Wiki copytemporary

Delphi form to HTML converter: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: Delphi form to HTML converter

OldNewLine
1+## About
2+
3+*Delphi Form to HTML Converter component (F2H)* is a Lazarus version of a new component, originally developed for Delphi 3.
4+
5+Designed for... Delphi coders who wish to re-use a Delphi form design on a web page
6+
7+It's main caracteristics are :
8+
9+- It inputs a Delphi form (soon to support Lazarus forms)
10+- It outputs HTML forms (which two variations) ... Standard HTML or WebHub Chunks
11+- Originally commercial for US\$99 in Delphi 3 by href.com
12+- Released under the Creative Commons License - contributors can donate money if they decide to support it.
13+- etc
14+
15+### Overview and Benefits
16+
17+If you can make a Delphi or C++Builder form, you can now create HTML pages instantly, and have them look just as sharp. Drop the Form to HTML Converter component onto your existing form, right-click, choose Browse It!, and you'll have your HTML file.
18+
19+**There are two different techniques for using the converter component**
20+
21+1\) Use it to export static HTML files
22+
23+In this scenario, you put the component into an existing Delphi form, set the main container, and export an HTML file. Most likely, you would then maintain that HTML page using an HTML editor such as FrontPage. This is the most likely situation for a Delphi programmer who does not use WebHub. Your main benefit is that you do not have to recreate form layouts in HTML that you have already created in Delphi.
24+
25+For gain the fullest support for Netscape 3.0 and 4.0 and for Internet Explorer 3.0 and 4.0, export a tailored page for each version of the browsers. Then change the browser family property and export again.
26+
27+2\) Use it as part of an interactive web application, to create dynamic HTML pages
28+
29+In this scenario, you also put the component onto your existing Delphi form and choose your container. However, your application would use the WebHub components, and you would use the converter component to generate a WebHub style "chunk" rather than a standard HTML file. That chunk would become part of a web page within a larger application. You would then set the browser family based on the information from the current surfer's browser, and the dynamic page would always be optimized for that surfer.
30+
31+The download contains the component, ( no an installation package nor demo application, that illustrates the features of the component along with some instrumentation for evaluating the chart on a given system, yet).
32+
33+### Requirements and/or Compatible Software
34+
35+Delphi or C++Builder for win32, or Lazarus Other browsers/versions: The generated HTML was designed precisely for Netscape 3/4 and Microsoft IE 3/4. If you need to support another browser brand or version, try the default Netscape setting because that will look good in most browsers.
36+
37+### Documentation
38+
39+Look for f2h-readme.txt which gives you everything you need for installing and using the component.
40+
41+f2h-readme.txt (follows)
42+
43+#### OVERVIEW
44+
45+TwhForm2HTML is a WYSIWYG Delphi form to HTML translator.
46+
47+Drag and drop a TwhForm2HTML component on any Delphi form and you are ready to export it in HTML.
48+
49+A custom editor gives you full control on the HTML attributes used, plus a few options.
50+
51+Exports can be done :
52+
53+- in standard HTML or as WebHub chunks
54+- at design time or dynamically at run time.
55+
56+As browsers size objects quite differently, the component may address the four main browsers differently in order to keep a common look and feel despite of their different behaviours.
57+
58+Who is the ideal user ?
59+
60+- The Delphi developer which has an HTML form to code and doesn't master HTML too much - or simply wants to save time - can use the component at *design time* only, and export the HTML code to integrate it in a static page. By letting the BrowserFamily property to bfDefault, the component chooses a mean way in sizing objects which gives an acceptable rendering with all browsers.
61+
62+- The Delphi developer which has an existing C/S Delphi application to be ported for remote access through the Web, with tens of data entry screens can do it in a breeze.
63+
64+By adding the component to all the forms for which a remote access is needed and including those forms in a WebHub project, a big part of the job is got immediately. In that way of use, keeping the original look and feel of the form is a big plus of course.
65+
66+#### SUPPORTED CONTROLS
67+
68+- TLabel
69+- TEdit
70+- TMemo
71+- TCheckBox
72+- TRadioButton
73+- TListBox
74+- TComboBox
75+- TButton
76+- TImage
77+- TGroupBox
78+- TPanel
79+- and any other TWinControl container.
80+
81+#### AT DESIGN-TIME
82+
83+##### PROPERTIES FROM THE OBJECT INSPECTOR
84+
85+AlternateFonts : string = Optional string appended to the 'Face' attribute of the <FONT> tags. Attributes... = Open the editor (see below) BGColor : string = Fixes the form's background color. Accepts :
86+
87+- \[None\] : no background color
88+- \[Same\] : same background color as the Delphi form color
89+- any HTML color name
90+- any HTML color string in the form \#RRGGBB
91+- any color picked in a TColorDialog (opened by double clicking)
92+
93+Browse it ! = Opens the HTML form using your default browser. BrowserFamily should be set before, according to that browser. BrowserFamily = (bfDefault, bfIE3, bfIE4, bfNS3, bfNS4). Fixes the target browser. bfDefault equals to bfIE4 because of the mean way of IE4 in sizing objects. ChunkOnly : Boolean = When exporting in standard mode if ChunkOnly is False, the component exports a whole HTML page, including a page title. Export HTML... = Opens a TSaveDialog to perform the export in standard HTML mode Export WebHub chunk... = Opens a TSaveDialog to perform the export in the WebHub mode MainContainer : TWinControl = By default, TwhForm2HTML converts the whole form. By setting MainContainer to any other container (groupbox, panel, ...), you may restrict the export to that container. SetFonts : Boolean = If True, TwhForm2HTML uses the <FONT> tag to keep the elements fonts. The controls which are concerned are : labels, radiobuttons and checkboxes
94+
95+##### THE ATTRIBUTES EDITOR
96+
97+Opened by double clicking on the component, the editor lists the controls in a tree view on the left panel. By selecting a control in the tree, you may check / edit its attributes on the right panel. The first element in the tree (\<FORM\>..\</FORM\>) gives you control on the \<FORM\> tag attributes.
98+
99+The editor shows three kinds of attributes :
100+
101+- HTML attributes
102+- HTML attributes used when exporting in WebHub mode : they have the same name as the standard
103+
104+attribute, prefixed by 'WH'. Example : Action \<--\> WHAction.
105+
106+- TwhForm2HTML options
107+
108+Only the TwhForm2HTML options are documented here. They vary depending on the control selected :
109+
110+Options for all elements :
111+
112+- AfterElement : string = Lets you insert any HTML code after the element
113+- BeforeElement : string = Lets you insert any HTML code before the element
114+
115+Options for all elements but containers and labels :
116+
117+- ExtraAttributes = To define additionals HTML attributes (like scripts handlers
118+
119+for example) under the form : 'AnAttribute1="Value1" AnAttributeN="ValueN"'
120+
121+Options for a TForm :
122+
123+- Border : Boolean = If True, the form is rendered with a border around it
124+- ShowCaption : Boolean = If True, the title bar of the form is kept
125+- CaptionBGColor : string = Back color of the title bar if ShowCaption is True
126+
127+Default = 'Navy'
128+
129+- CaptionColor : string = Text color of the title bar if ShowCaption is True
130+
131+Default = 'White'
132+
133+Options for a TButton :
134+
135+- AsImage : Boolean = Specifies if the button has to be converted in an \<INPUT\>
136+
137+tag (standard HTML button, type "submit" or "reset"), or in an \<IMG\> tag.
138+
139+Options for a TImage :
140+
141+- AsButton : Boolean = If True, the TImage is translated in an \<INPUT Type="image"\>
142+
143+tag. If False, the TImage can be handled as an anchor or not.
144+
145+- AsAnchor : Boolean = If True, you can edit the HREF link attribute.
146+
147+#### AT RUN-TIME
148+
149+The component can be used to generate the forms chunks on the fly. A write-only 'CGIUserAgent' property, compatible with TWebServer.CGIUserAgent must be used to inform the component of the target browser.
150+
151+Example in WebHub mode :
152+
153+``` pascal
154+with WHForm2HTML1 do
155+begin
156+ CGIUserAgent := WebServer1.CGIUserAgent; // set BrowserFamily automatically
157+ ExportWHChunkFName := 'aChunk.txt'; // set the export filename
158+ if exportWHChunk then // function exportWHChunk : Boolean
159+ // do something with the text file
160+end;
161+```
162+
163+In place of writing the chunk in a text file, you can get the chunk string through the public property WHChunk : string read getWHChunk.
164+
165+Example in standard mode :
166+
167+``` pascal
168+with WHForm2HTML1 do
169+begin
170+ CGIUserAgent := WebServer1.CGIUserAgent; // sets BrowserFamily automatically
171+ ExportFName := 'aForm.HTML'; // sets the export filename
172+ if exportHTML then // function exportHTML : Boolean
173+ // do something with the HTML page
174+end;
175+```
176+
177+In place of writing the page in a text file, you can get the its string through the public property HTML : string read getHTML.
178+
179+Notice that if you create controls at run-time, TWHForm2HTML must be informed in order to take those new controls into account. To achieve that, simply call the Synchronize procedure. As shown below, it's also possible to set attributes on-the-fly.
180+
181+Example :
182+
183+``` pascal
184+var
185+ attrObject : THAttrObject;
186+begin
187+with WHForm2HTML1 do
188+begin
189+ // Creation of controls on the fly
190+ // ...
191+ // ...
192+ synchronize; // Now the component knows about them
193+ // ...
194+ // Now let's say that you created a TButton named 'Button1' and you
195+ // need to access the corresponding THButton object in order to set
196+ // one of its HTML attributes :
197+
198+ attrObject := WHForm2HTML1.HMainContainer.FindHObjectByName('Button1');
199+ if attrObject <> nil then
200+ begin
201+ with attrObject do
202+ begin
203+ Attributes['AsImage'].BooleanValue := False; // set the 'AsImage' option
204+ Attributes['Type'].Value := 'reset'; // set the 'Type' attribute
205+ end;
206+ end;
207+end;
208+```
209+
210+### INSTALLATION
211+
212+TWHForm2HTML currently supports Delphi 5+, C++ Builder and Lazarus.
213+
214+``` pascal
215+unit regf2h;
216+
217+{*******************************************************}
218+{ }
219+{ Form to HTML converter "F2H" }
220+{ Register component to Delphi palette }
221+{ }
222+{ Copyright (c) 1998-2010 HREF Tools Corp. }
223+{ http://www.href.com/f2h }
224+{ }
225+{ This file is licensed under a Creative Commons }
226+{ Share-Alike 3.0 License. }
227+{ http://creativecommons.org/licenses/by-sa/3.0/ }
228+{ If you use this file, please keep this notice }
229+{ intact. }
230+{ }
231+{ Developed by HREF Tools Corp. 1998-2010 }
232+{ First author: Philippe Maquet }
233+{ }
234+{*******************************************************}
235+```
236+
237+- Install component via regf2h.pas as a new component as per normal.
238+
239+### WebHub VCL Developers
240+
241+- F2h is automatically installed on the WebHub palette when you build your component library or package.
242+- Rebuild your component library or package to take advantage of your new code.
243+
244+### How to install into IDE
245+
246+- Unzip the ZIP file in any folder
247+- Menu: Component \> Install Packages
248+- Install the package for your compiler: D06 = Delphi 6, D07 = Delphi 7, D11 = Delphi 2007, D12 = Delphi 2009
249+
250+The component will be installed on a palette named "WebHub".
251+
252+## Screenshot
253+
254+(not currently available) -- single form component.
255+
256+## Author
257+
258+Ann Lynneworth of HREF.com
259+
260+ { Developed by HREF Tools Corp. 1998-2010 }
261+ { First author: Philippe Maquet }
262+ { Redeveloped by http://pews-freeware-games.org }
263+ { Second author: Peter Eric Williams (pew) }
264+ { for Lazarus and Free Pascal }
265+
266+## License
267+
268+ { This file is licensed under a Creative Commons }
269+ { Share-Alike 3.0 License. }
270+ { http://creativecommons.org/licenses/by-sa/3.0/ }
271+ { If you use this file, please keep this notice }
272+ { intact. }
273+
274+[modified](http://svn.freepascal.org/svn/lazarus/trunk/COPYING.modifiedLGPL) [LGPL](http://svn.freepascal.org/svn/lazarus/trunk/COPYING.LGPL) (same as the FPC RTL and the Lazarus LCL). You can contact the author if the modified LGPL doesn't work with your project licensing.
275+
276+## Download
277+
278+The latest stable release can be found on
279+
280+<https://sites.google.com/site/pewtas/form2html_lazarus.zip?attredirects=0&d=1>
281+
282+This is the new component for Lazarus "Delphi Form to HTML Converter" (originally for Delphi 3). Needs some work... please contact PEW... It should work fine with Delphi 3 forms... Help is requested to make it work for Lazarus forms and also changes documented in the enclosed HTML file re: detecting and calling default web browser in a cross-platform way.
283+
284+## Change Log
285+
286+- Version 1.0 *date*
287+
288+## Dependencies / System Requirements
289+
290+- None
291+
292+Status: *Stable*
293+
294+Issues:
295+
296+See Webbrowser / Webbrowser - Lazarus wiki.html ... code needs to be added to make it check for the default web browser and call the default web browser as per code on html file (copy of Lazarus wiki). This is to provide cross-platform call of default web browser.
297+
298+---
299+*From the Free Pascal wiki, page "Delphi form to HTML converter", as it stood on 2020-02-12 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
300+Category: Components

Back to history