Sign in Join
Wiki copytemporary

Delphi form to HTML converter: what changed

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

OldNewLine
11## About
22
33*Delphi Form to HTML Converter component (F2H)* is a Lazarus version of a new component, originally developed for Delphi 3.
44
55Designed for... Delphi coders who wish to re-use a Delphi form design on a web page
66
77It's main caracteristics are :
88
99- It inputs a Delphi form (soon to support Lazarus forms)
1010- It outputs HTML forms (which two variations) ... Standard HTML or WebHub Chunks
1111- Originally commercial for US\$99 in Delphi 3 by href.com
1212- Released under the Creative Commons License - contributors can donate money if they decide to support it.
1313- etc
1414
1515### Overview and Benefits
1616
1717If 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.
1818
1919**There are two different techniques for using the converter component**
2020
21211\) Use it to export static HTML files
2222
2323In 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.
2424
2525For 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.
2626
27272\) Use it as part of an interactive web application, to create dynamic HTML pages
2828
2929In 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.
3030
3131The 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).
3232
3333### Requirements and/or Compatible Software
3434
3535Delphi 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.
3636
3737### Documentation
3838
3939Look for f2h-readme.txt which gives you everything you need for installing and using the component.
4040
4141f2h-readme.txt (follows)
4242
4343#### OVERVIEW
4444
4545TwhForm2HTML is a WYSIWYG Delphi form to HTML translator.
4646
4747Drag and drop a TwhForm2HTML component on any Delphi form and you are ready to export it in HTML.
4848
4949A custom editor gives you full control on the HTML attributes used, plus a few options.
5050
5151Exports can be done :
5252
5353- in standard HTML or as WebHub chunks
5454- at design time or dynamically at run time.
5555
5656As 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.
5757
5858Who is the ideal user ?
5959
6060- 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.
6161
6262- 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.
6363
6464By 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.
6565
6666#### SUPPORTED CONTROLS
6767
6868- TLabel
6969- TEdit
7070- TMemo
7171- TCheckBox
7272- TRadioButton
7373- TListBox
7474- TComboBox
7575- TButton
7676- TImage
7777- TGroupBox
7878- TPanel
7979- and any other TWinControl container.
8080
8181#### AT DESIGN-TIME
8282
8383##### PROPERTIES FROM THE OBJECT INSPECTOR
8484
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 :
85+AlternateFonts : string = Optional string appended to the 'Face' attribute of the tags. Attributes... = Open the editor (see below) BGColor : string = Fixes the form's background color. Accepts :
8686
8787- \[None\] : no background color
8888- \[Same\] : same background color as the Delphi form color
8989- any HTML color name
9090- any HTML color string in the form \#RRGGBB
9191- any color picked in a TColorDialog (opened by double clicking)
9292
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
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 tag to keep the elements fonts. The controls which are concerned are : labels, radiobuttons and checkboxes
9494
9595##### THE ATTRIBUTES EDITOR
9696
9797Opened 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.
9898
9999The editor shows three kinds of attributes :
100100
101101- HTML attributes
102102- HTML attributes used when exporting in WebHub mode : they have the same name as the standard
103103
104104attribute, prefixed by 'WH'. Example : Action \<--\> WHAction.
105105
106106- TwhForm2HTML options
107107
108108Only the TwhForm2HTML options are documented here. They vary depending on the control selected :
109109
110110Options for all elements :
111111
112112- AfterElement : string = Lets you insert any HTML code after the element
113113- BeforeElement : string = Lets you insert any HTML code before the element
114114
115115Options for all elements but containers and labels :
116116
117117- ExtraAttributes = To define additionals HTML attributes (like scripts handlers
118118
119119for example) under the form : 'AnAttribute1="Value1" AnAttributeN="ValueN"'
120120
121121Options for a TForm :
122122
123123- Border : Boolean = If True, the form is rendered with a border around it
124124- ShowCaption : Boolean = If True, the title bar of the form is kept
125125- CaptionBGColor : string = Back color of the title bar if ShowCaption is True
126126
127127Default = 'Navy'
128128
129129- CaptionColor : string = Text color of the title bar if ShowCaption is True
130130
131131Default = 'White'
132132
133133Options for a TButton :
134134
135135- AsImage : Boolean = Specifies if the button has to be converted in an \<INPUT\>
136136
137137tag (standard HTML button, type "submit" or "reset"), or in an \<IMG\> tag.
138138
139139Options for a TImage :
140140
141141- AsButton : Boolean = If True, the TImage is translated in an \<INPUT Type="image"\>
142142
143143tag. If False, the TImage can be handled as an anchor or not.
144144
145145- AsAnchor : Boolean = If True, you can edit the HREF link attribute.
146146
147147#### AT RUN-TIME
148148
149149The 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.
150150
151151Example in WebHub mode :
152152
153153``` pascal
154154with WHForm2HTML1 do
155155begin
156156 CGIUserAgent := WebServer1.CGIUserAgent; // set BrowserFamily automatically
157157 ExportWHChunkFName := 'aChunk.txt'; // set the export filename
158158 if exportWHChunk then // function exportWHChunk : Boolean
159159 // do something with the text file
160160end;
161161```
162162
163163In place of writing the chunk in a text file, you can get the chunk string through the public property WHChunk : string read getWHChunk.
164164
165165Example in standard mode :
166166
167167``` pascal
168168with WHForm2HTML1 do
169169begin
170170 CGIUserAgent := WebServer1.CGIUserAgent; // sets BrowserFamily automatically
171171 ExportFName := 'aForm.HTML'; // sets the export filename
172172 if exportHTML then // function exportHTML : Boolean
173173 // do something with the HTML page
174174end;
175175```
176176
177177In place of writing the page in a text file, you can get the its string through the public property HTML : string read getHTML.
178178
179179Notice 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.
180180
181181Example :
182182
183183``` pascal
184184var
185185 attrObject : THAttrObject;
186186begin
187187with WHForm2HTML1 do
188188begin
189189 // Creation of controls on the fly
190190 // ...
191191 // ...
192192 synchronize; // Now the component knows about them
193193 // ...
194194 // Now let's say that you created a TButton named 'Button1' and you
195195 // need to access the corresponding THButton object in order to set
196196 // one of its HTML attributes :
197197
198198 attrObject := WHForm2HTML1.HMainContainer.FindHObjectByName('Button1');
199199 if attrObject <> nil then
200200 begin
201201 with attrObject do
202202 begin
203203 Attributes['AsImage'].BooleanValue := False; // set the 'AsImage' option
204204 Attributes['Type'].Value := 'reset'; // set the 'Type' attribute
205205 end;
206206 end;
207207end;
208208```
209209
210210### INSTALLATION
211211
212212TWHForm2HTML currently supports Delphi 5+, C++ Builder and Lazarus.
213213
214214``` pascal
215215unit regf2h;
216216
217217{*******************************************************}
218218{ }
219219{ Form to HTML converter "F2H" }
220220{ Register component to Delphi palette }
221221{ }
222222{ Copyright (c) 1998-2010 HREF Tools Corp. }
223223{ http://www.href.com/f2h }
224224{ }
225225{ This file is licensed under a Creative Commons }
226226{ Share-Alike 3.0 License. }
227227{ http://creativecommons.org/licenses/by-sa/3.0/ }
228228{ If you use this file, please keep this notice }
229229{ intact. }
230230{ }
231231{ Developed by HREF Tools Corp. 1998-2010 }
232232{ First author: Philippe Maquet }
233233{ }
234234{*******************************************************}
235235```
236236
237237- Install component via regf2h.pas as a new component as per normal.
238238
239239### WebHub VCL Developers
240240
241241- F2h is automatically installed on the WebHub palette when you build your component library or package.
242242- Rebuild your component library or package to take advantage of your new code.
243243
244244### How to install into IDE
245245
246246- Unzip the ZIP file in any folder
247247- Menu: Component \> Install Packages
248248- Install the package for your compiler: D06 = Delphi 6, D07 = Delphi 7, D11 = Delphi 2007, D12 = Delphi 2009
249249
250250The component will be installed on a palette named "WebHub".
251251
252252## Screenshot
253253
254254(not currently available) -- single form component.
255255
256256## Author
257257
258258Ann Lynneworth of HREF.com
259259
260260 { Developed by HREF Tools Corp. 1998-2010 }
261261 { First author: Philippe Maquet }
262262 { Redeveloped by http://pews-freeware-games.org }
263263 { Second author: Peter Eric Williams (pew) }
264264 { for Lazarus and Free Pascal }
265265
266266## License
267267
268268 { This file is licensed under a Creative Commons }
269269 { Share-Alike 3.0 License. }
270270 { http://creativecommons.org/licenses/by-sa/3.0/ }
271271 { If you use this file, please keep this notice }
272272 { intact. }
273273
274274[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.
275275
276276## Download
277277
278278The latest stable release can be found on
279279
280280<https://sites.google.com/site/pewtas/form2html_lazarus.zip?attredirects=0&d=1>
281281
282282This 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.
283283
284284## Change Log
285285
286286- Version 1.0 *date*
287287
288288## Dependencies / System Requirements
289289
290290- None
291291
292292Status: *Stable*
293293
294294Issues:
295295
296296See 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.
297297
298298---
299299*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).*
300300Category: Components

Back to history