This is an authorised copy of PASTV5.FAQ by Berend de Boer , for Pascal TurboVision; it is no longer being updated. www.merlyn.demon.co.uk 1999-10-29. ====================================================================== From berend@beard.nest.nl Fri Feb 24 00:00:01 1995 Subject: PASTV.FAQ, revision 5 contents (c) 1994,1996 by Berend de Boer (All rights reserved) Use on CD-Rom distribution without permission is forbidden PASTV5.FAQ Frequently (and not so frequently) asked Pascal TurboVision questions with Berend's and other users's answers Comments, corrections, and additions are solicited. You can reach me at: * Berend de Boer cis: 100120,3121 email: 100120.3121@compuserve.com fidonet: 2:281/527.23 .................................................................... Changes to revision 6 * Added Q&A for not-editable inputline Changes to revision 5: * I finally got time to go through a bunch of mail (sometimes very old, shame on me) with suggestions and answers to add to this FAQ. * expanded book section. Changes to revision 4: * new book entry in books section. * added more info about 3rd party products. * extended TurboVision in graphics mode section. .................................................................... Contributors (knowingly or unknowingly) to this faq were: * Michael Charles Carney * Stanley Toney * Sean Wenzel * J R Stockton * Fred Leban * W. Gross * Paul Furbacher * Donald Moe * Peter N Roth * Ken Stuart * Stephen C. Trier * Brugt Kazemier If I inadvertedly forgot you to include, please send me a message. -------------------------------------------------------------------- *General* 0001) What does this FAQ cover? 0002) Are there other Pascal related FAQs? 0003) Where can the C++ TurboVision FAQ be found? 0004) Where are electronic discussions about TurboVision? 0005) Is there a TurboVision buglist? 0006) Are there other Pascal buglists? *How to learn TurboVision* 0101) What's the best way to learn TurboVision? 0102) Which books cover TurboVision? 0103) Which magazines cover TurboVision? *TurboVision archives* 0201) Where can I find official Borland TurboVision demos/examples? 0202) Where can I find useful TurboVision tools/packages? 0203) I can't ftp, get I still get files from an ftp site? *Common questions and their answers* 0301) My helpwindow is displayed in red/white blinking colors, what's wrong? 0302) Is it save to modify a collection of a ListBox? 0303) Does anyone have a progress indicator? 0304) How do I shell out to DOS or start external programs? 0305) Can anyone explain the TPXPictureValidator any better? 0306) How can I disable the close gadget on a window so a user can't close the window? 0307) can I enable/disable commands from certain buttons without effecting the same commands in other windows I have open at the same time? 0308) How can I toggle menuitems (like Compiler Destination)? 0309) Changing of colors 0310) ListBox's NewList method 0311) Making another menu item the default 0312) I inserted an inputline in a window and now the colors are wrong? 0313) How can I disable the close icon in a window? 0314) How can I disable editing of an inputline? *Extended or new TurboVision objects* 0401) How do I display a dialog box with running text? 0402) How can I create a password inputline? 0403) How do my inputlines get Cut/Paste capabilities? 0404) Are there any TV Screen savers? 0405) How do I insert, delete or edit items from a collection assigned to a TListBox? 0406) Can I use the Idle method to do background processing? 0407) Has anyone extended the editors object with word-wrapping, >64KB files, etc.? 0408) How can I add printing capabilities to the editor object? 0409) Is there a way to have multiple (for example *.bat *.com and *.exe) fileselections in TFileDialog? 0412) My popup menu's do not dispose the memory they allocated. What's wrong? 0413) How do I add backtracking to the helpfile enginge? 0414) How can I use the arrow keys to change from one control to another control? 0415) How can I change the DeskTop's background? 0416) F11, F12 keycocdes *3rd party TurboVision products* 0501) Which TurboVision screen generators are available? 0502) Are there other good TurboVision packages? 0503) Which commercial packages offer TurboVision support? *TurboVision and Graphics* 0601) How do I switch to graphics mode and back? 0602) Is there a version of TurboVision completely running in graphics mode? ----------------------------------------------------------------------- ********* *General* ********* Q.0001: What does this FAQ cover? A1: This FAQ tries to be a knowledge base for Pascal programmers who are using TurboVision, a windowing screen package shipped from Turbo Pascal 6.0 unwards. Unless otherwise stated this FAQ covers version 2.0 of the Turbo Pascal Turbo Vision. Some questions and answers are applicable to Turbo Vision 1.0 too. Q.0002: Are there other Pascal related FAQs? A: Yes, a very complete one is maintained by Timo Salmi, email ts@uwasa.fi. New versions can be obtained from the fpt site garbo.uwasa.fi, directory /pc/ts. Lots of BBSs have Timo Salmi's FAQ too. Q.0003: Where can the C++ TurboVision FAQ be found? A: The TurboVision C++ FAQ is called TVPlus. Some information about this FAQ, taken from its posting in the comp.os.msdos.programmers.turbovision newsgroup: TVPlus is maintained by Robert Hazeltine and Rachel Polanskis from Sydney, Australia through our computer host, Zeta Microcomputer This format of TVPlus is posted each calendar month to turbvis@vtvm1.cc.vt.edu. It incorporates changes since being posted last. The document is being submitted to ftp://rtfm.mit.edu for approval and inclusion in news.answers Following approval, it will be possible to obtain a copy from that ftp site. Q.0004: Where are electronic discussions about TurboVision? A: There are several electronic forums available. They are: - Official Borland support for TurboVision can be gained in the CompuServe BPASCAL forum, section 18. Answers guaranteed (well, almost). - On usenet there is the newsgroup COMP.OS.PROGRAMMER.TURBOVISION. - On fidonet there are several forums, or as they more commonly are called, Areas. - there is the international Pascal area: PASCAL - there are several areas local to a country as the dutch pascal forum: PASCAL.028 - There is a new, fidonet technology based, network devoted entirely to pascal called PascalNet. If you want to be on it, you need fidonet capable technology. Write Marc van Leeuwen, 2:285/228.0, for details. The area on PascalNet dedicated to TurboVision is called: TURBOVISION.PAS Q.0005: Is there a TurboVision buglist? A: Yes. The Pascal buglist is maintained by Bob Swart (Dr. Bob from Pascal Magazine). Bob can be reached on the internet at bob@bolesian.nl, on CompuServe at 100434,2072 or on Fidonet at 2:281/256.12. This buglist contains also a list of patches to fix most bugs. To get a copy of this bug list, look for TVBUGSx.ZIP, either where you found this file, or at his Internet ftp site vtucs.cc.vt.edu in the turbo-vision/faq directory. The latest version at time (24 Feb 1995) of this writing was 3.1. If you really have found a bug (99% of the time you have not) you may send it to bugs@borland.com. Note that Duncan Murdoch no longer collects the tv specific bugs (see question 0004). Q.0006: Are there other Pascal related buglists? A: Yes, Duncan Murdoch maintains one. If you are interested in Mr Murdochs buglist, it is called BP7BUGS*.* and can be found on any pascal supporting BBS, anonymous ftp site and on CompuServe (see question 0201). ----------------------------------------------------------------------- ************************** *How to learn TurboVision* ************************** Q.0101: What's the best way to learn TurboVision? A1: Read the manual. The manual of TP7/BP7 is really good. All mastertricks not covered in the TP6 manual are now written clearly. So far for the TurboVision masters. A2: Read other books. I've myself not needed any other source of information so I can't recommend anyone. If anyone can, please submit. A3: Take a look at the sample code: both the examples from the manual (so I started when I got TurboVision in the beginnings of 1991) and from the other TurboVision examples from Borland. They often contain useful ideas, show things of TurboVision not mentioned (or not clearly mentioned) in the manual and give you some feeling for 'good' TurboVision programming. Don't hesitate to modify the examples: so you get the feeling! You can find the examples in three directories /bp/examples/dos/tv* A4: And next: write your first application as try out. Be warned: I'm still working on that first sample application :-) (Currently > 50 000 lines of code) Q.0102: Which books cover TurboVision? A1: Carlos Sotolongo (csoto@tinored.cu) was fairly enthusiastic about the following book, here his message: "Look for 'Borland Pascal Developers Guide', written by Ed Mitchell and Published by QUE Books. I think is the best book about TV and Turbo Pascal 7.0 you can find in the market. It comes with a companion disk including source code and utilities like a string resource compiler and a programmers editor, among others." I've seen other users recommend this book too, although I've not read it myself. A2: PC Techniques recommends "Programming with Turbo Vision" by Blake Watson. You can order it from Bookstream with your credit card. Call 800-410-0192 or 602-483-0192. Or fax to 602-483-0193. See also its very favorable review in the February/March 1995 issue of Pascal Magazine (issue 5). A3: The following might be of more interest for our German readers. It was recommended by Donald Moe. Borland Pascal / Turbo Pascal 7.0 Turbo Vision DOS-Programmierung mit der Objekt-Bibliothek by Otto Fischer 739 pages, diskette included, 69 DM Tewi Verlag Riesstr. 25, Haus D D-80992 Munich Germany ISBN 3-89362-287-X A4: These books were recommended by Peter N Roth. His message: "Herewith the names of 2 books that I found helpful. The first is more directly applicable to TV." Freddy Ertl, Ralph Machholz, and Andi Golgath, A PROGRAMMER'S GUIDE TO TURBOVISION, Addison-Wesley, 1993. Neil Rubenking, TURBO PASCAL 6 TECHNIQUES AND UTILITIES, Ziff-Davis, 1991. Q.0103: Which magazines cover TurboVision? A: The following is probably a not complete list, but these are the magazines I know they cover TurboVision more or less frequent. - PC Techniques (for subscriptions contact Jeff Duntemann at 76711.470@compuserve.com) - Pascal Magazine (for subscriptions contact Chris Frizelle at 70630.717@compuserve.com) - and probably the German magazine C'T covers TurboVision as well, although I haven't read it for a while. ----------------------------------------------------------------------- ********************** *TurboVision archives* ********************** Q.0201: Where can I find Borland official demo and examples? A1: On CompuServe, BPASCAL forum, lib 1. A2: Anonymous ftp to archives that carry official Borland stuff, as ftp.borland.com and oak.oakland.edu (see below) A3: Some of the BBSs mentioned in Q.0202 carry examples also. There are also Borland BBSs, call Borland Support for one near you. Q.0202: Where can I find useful TurboVision tools/packages? A: Systems which are known to have the best/latest TV sources/utilities are: * anonymous FTP - ftp.borland.com, the official Borland ftp site (?) - garbo.uwasa.fi:/pc/turbovis - ftp.cica.indiana.edu:/pub/pc/borland - oak.oakland.edu:/?? - vtucs.cc.vt.edu (128.173.4.72), directory /turbo-vision/ {both, cpp, faq, pascal} * CompuServe - CompuServe, the Borland Pascal forum, lib 1 * fidonet (freqqing even for unlisted nodes) - Contrast (2:281/527) - WhiteHouse (2:281/256) - 3:640/307, a BBS in Australie, distributes TVGraph 2.x. - There are many more systems, so it is higly likely that in your neighbourhood is one too. * PascalNet - Marc van Leeuwen, 115:3100/0.0 (fidonet 2:285/228.0) - Edwin Groothuis, 115:3145/102 (fidonet 2:284/205.1) Fred Leban also presented a list. Here follows his message: Sites with Turbo Vision (& Turbo Pascal) material ================================================= This list is by no means exhaustive. I tried to pick sites from different parts of the globe. These sites are the results of an `archie' search from two archie servers (in other words I don't know whether the info about a particular site is correct or not, except for the ones in the U.S. that I visited frequently). Let me know if there are errors or if you know of site(s) that should be included in this list. The listing includes the name of the site (alternate name in square `[]' brackets, if known), IP address in parenthesis, and the directory below the site's name. Different directories on the same directory level are enclosed in curly brackets (`{}') separated with a comma. Sites ----- cs.ubc.ca (137.82.8.5) /mirror4/msdos/{turbopas, turbovis} ftp.uu.net (192.48.96.9) /systems/ibmpc/msdos/simtel20/{turbopas, turbovis} garbo.uwasa.fi (128.214.87.1) /pc/{turbopas, turbovis} isfs.kuis.kyoto-u.ac.jp (130.54.20.1) /mirrors/simtel20.msdos/{turbopas, turbovis} knot.queensu.ca (130.15.126.54) /wuarchive/systems/ibmpc/garbo/{turbopas, turbovis} /wuarchive/systems/ibmpc/msdos/{turbopas, turbovis} nctuccca.edu.tw (140.111.3.21) /PC-MsDos/Garbo-pc/{turbopas, turbovis} /PC-MsDos/SIMTEL-msdos/{turbopas, turbovis} netserv.cnr.it (192.12.192.6) /pub/msdos/{turbopas, turbovis} nic.switch.ch (130.59.1.40) /mirror/msdos/{turbopas, turbovis} /software/pc/simtel20/{turbopas, turbovis} oliver.sun.ac.za (146.232.212.3) /simtel/{turbopas, turbovis} plaza.aarnet.edu.au [archie.au] (139.130.4.6) /micros/pc/oak/{turbopas, turbovis} /micros/pc/garbo/pc/{turbopas, turbovis} rigel.acs.oakland.edu [oak.oakland.edu] (141.210.10.117) /pub/msdos/{turbopas, turbovis} sprite.cica.indiana.edu [ftp.cica.indiana.edu] (129.79.20.17) /pub/pc/borland/{c, pas}/tv sun.rz.tu-clausthal.de (139.174.2.10) /pub/msdos/programmer/{turbopas, turbovision} swdsrv.edvz.univie.ac.at (131.130.1.4) /pc/dos/{turbopas, turbovis} terra.stack.urc.tue.nl (131.155.2.71) /pub/nfs/pc/borland/{c, pas}/tv /pub/simtel/{turbopas, turbovis} wuarchive.wustl.edu (128.252.135.4) /systems/ibmpc/garbo/{turbopas, turbovis} /systems/ibmpc/msdos/{turbopas, turbovis} /pub/MSDOS_UPLOADS/programming/turbopas Q.0203: I can't ftp, get I still get files from an ftp site? A: If you have email access you can. See for a list of how to do this the FTP.FAQ regularly posted in news.answers. If you don't have ftp access, you might try to obtain a CD-Rom of such an ftp site. Many ftp sites regularly bring out CD-Roms containing all or a large portion of their collection. ----------------------------------------------------------------------- ************************************ *Common questions and their answers* ************************************ Q.0301: My helpwindow is displayed in red/white blinking colors, what's wrong? A: Red blinking colors are a sign that there is no information in the color palette to map colors to. You have forgotten to update TApplication.GetPalette. See /bp/examples/dos/tvdemo/tvdemo.pas for a correct TApplication.GetPalette. Q.0302: Is it save to modify a collection of a ListBox? A: Yes. But update the ListBox range also if you add or delete items by calling SetRange. If you have changed an item call DrawView. See also Question & Answer 0405. Q.0303: Does anyone have a progress indicator? A: see /bp/examples/dos/tvfm/GAUGES.PAS, thanks to Paul Furbacher. Q.0304: How do I shell out to DOS or start external programs? A: For people who don't have the source for the runtime library, I include here the code for the DosShell method. procedure TApplication.DosShell; begin DoneSysError; DoneEvents; DoneVideo; DoneDosMem; WriteShellMsg; SwapVectors; Exec(GetEnv('COMSPEC'), ''); SwapVectors; InitDosMem; InitVideo; InitEvents; InitSysError; Redraw; end; Replace the Exec line with your program. If you only want to add a Dos shell to your program, include a menuitem with the cmDosShell command. That's enough, TurboVision does the rest. Q.0305: Can anyone explain the TPXPictureValidator any better? A: The TPXPictureValidator is not the most intensively covered object in the manual. It's even rather uncovered. Here are some advanced pictures, which show the power of TPXPictureValidator. The following examples are given in TVConst, a unit from the TVTool library from Richard Hansen: UnsignedPic1 = '#[#][#]*{[;,]###}'; { unsigned int with optional commas } UnsignedPic2 = '#[#][#]*{;,###}'; { unsigned int with commas } SignedPic1 = '[-]#[#][#]*{[;,]###}'; { signed int with optional commas } SignedPic2 = '[-]#[#][#]*{;,###}'; { { signed int with commas } MoneyPic1 = '[$]*#.{##,00}'; { dollars, with comma and optinal dollar sign } MoneyPic2 = '$*#{.##,.00}'; { dollars, with comma and dollar sign } DatePic1 = '#[#]/#[#]/##'; { date with 2 digit year (dd/mm/yy or mm/dd/yy) } DatePic2 = '#[#]/#[#]/##[##]'; { date with 2 or 4 digit year (mm/dd/yy or mm/dd/yyyy) } DatePic3 = '#[#]/#[#]/####'; { date with 4 digit year (mm/dd/yyyy) } TimePic1 = '{##}:{##}[:{##}]'; { HH:MM:SS with optional seconds } TimePic2 = '{##}:{##}:{##}'; { HH:MM:SS } PhonePic1 = '[(###) ]###-####'; { phone number with optional area code } PhonePic2 = '(###) ###-####'; { phone number with area code } SSNPic = '###-##-####'; FirstCharUpPic = '*{&*? }'; { uppercase the first char of every word } FilenamePic = '{&*7[&]}.{*3[&]}'; { filename (no path) with extension } Note the *7 and *3 in this last example. A number after a '*' says how many times the next sequence should be repeated. Uncovered in the manuals. But this example is not completely correct, (is this a bug/) because the '*' is interpreted as that there should be exactly 8 characters! No more, no less. Correct is: FilenamePic = '{&[&][&][&][&][&][&][&]}.{[&][&][&]}'; The following examples were given by Sean Wenzel in the Borland Turbo Vision forum on CompuServe: US Phone w/ optional area code [(*3{#})]*3{#}-*4{#} colors w/autofill-in {Red,Gr{ay,een},B{l{ack,ue},rown},White,Yellow} a date in the format "Jan, 31, 1999" with auto fill-in '{J{AN ,U{N ,L }},FEB ,MA{R ,Y },A{PR ,UG },SEP ,OCT ,NOV ,DEC} {1[#],2[#],30,31,#};, 19##' Here my solution for a real validator a validator for the format "1.234E-6" or "3.14159" '[-]#[*#][[.]#[*#]][E[-]#[#]]' Q.0306: How can I disable the close gadget on a window so a user can't close the window? A: Execute: MyWindow^.Flags := MyWindow^.Flags and not wfClose; Q.0307: How can I enable/disable commands from certain buttons without effecting the same commands in other windows I have open at the same time? A: The answer to this question was given by Stanley Toney in the TurboVision newsgroup. What follows is an edited transcript of his message. >I am a bit unsure about the effect of DisableCommands / EnableCommands [stuff deleted ] >The problem is that those commands have effect on all the viewers >open at them time - not just the active one. If i click on an >empty table viewer, all the applicable buttons in all the other >views get disabled too, and if I click on a non-empty one all the >buttons gets enables. What I want is to 'localize' the effect of >disabling/enabling commands. Is there any elegant way to do it, >without assigning different values to each viewer's buttons? I have seen this behavior as well. Where it comes from is that the disable/enablecommand methods broadcast a message that is intended for the menubar, buttons (and possibly the status line too if you set it up right). That broadcast event is not cleared by the views so that all get a chance to see it. The best way around I have found is to write a method that checks using flag checks or what ever to determine which set of commands should be active or disabled and call the appropiate ones. then place a call to it in the HandleEvent of the viewer at the end of the handle event code, i.e. last line. Since HandleEvent is called often, this code will be checked often. I have not found this to slow down the program significantly at all. To cut down a bit on the event traffic, call this method selectively: name it CheckCommands or somthing. Call it only if sfSelected is true, thus only the top viewer should check itself. Q.0308: How can I toggle menuitems (like Compiler Destination)? A1: The Param field of the TMenuItem type determines which parameter to display after the menu item. If it is nil, no parameter will be displayed. Param is a pointer to a string (type PString). You can change Param directly but often it is more convenient to change only the text. Take for example the following MenuBar: NewSubMenu('~C~ompile', hcNoContext, NewMenu( [...] NewItem('~T~arget...', 'Real', kbNoKey, cmTarget, hcNoContext, [...] ) Somewhere deep inside a nesting of MenuItems lies the Param you want to change. You can search this (traversing the list of MenuItems) and then change Param to point to a string containing 'Protected' for example. More convenient is the following code: var TargetParam : PString; function ReturnTargetMenu : PMenuItem; var p : PMenuItem; begin p := NewItem('~T~arget...', 'Real', kbNoKey, cmTarget, hcNoContext, nil); TargetParam := p^.Param; end; I've for the moment assumed that no more menuitems follow Target, else I had to include them in this function. TargetParam points now to 'Real'. Change now to protected mode by DisposeStr(TargetParam); TargetParam := NewStr('Protected.'); and next time you develop for protected mode! A2: The following answer was provided by Brugt Kazemier. "Use the function GetNewItem (see below). This provides the same functionality as the function NewItem, except that it has an extra parameter, which returns a pointer to the newly created menu item" function GetNewItem(Name, Param: TMenuStr; KeyCode: word; Command: word; AHelpCtx: word; var This: PMenuItem; Next: PMenuItem): PMenuItem; begin This := NewItem(Name, Param, KeyCode, Command, AHelpCtx, Next); GetNewItem := This; end; ============================================================================= {Example} program FlexibleMenu; uses App, Drivers, Menus, Objects, Views; { the function GetNewItem provides the same functionality as the function NewItem, except that it has an extra parameter, which returns a pointer to the newly created menu item } function GetNewItem(Name, Param: TMenuStr; KeyCode: word; Command: word; AHelpCtx: word; var This: PMenuItem; Next: PMenuItem): PMenuItem; begin This := NewItem(Name, Param, KeyCode, Command, AHelpCtx, Next); GetNewItem := This; end; const cmThis = 1001; This1 = '~T~ry this'; This2 = 'Try it ~a~gain'; type TTestApp = object (TApplication) This: PMenuItem; procedure InitMenuBar; virtual; procedure HandleEvent(var Event: TEvent); virtual; end; procedure TTestApp.InitMenuBar; var R: TRect; begin GetExtent(R); R.B.Y := Succ(R.A.Y); MenuBar := New(PMenuBar, Init(R, NewMenu( NewSubMenu('TheMenu', 0, NewMenu( NewItem('E~x~it','', kbAltX, cmQuit, 0, GetNewItem(This1, '', 0, cmThis, 0, This, nil))), nil)))); end; procedure TTestApp.HandleEvent(var Event: TEvent); begin inherited HandleEvent(Event); if (Event.What = evCommand) and (Event.Command = cmThis) then begin with This^ do if Name^ = This1 then begin DisposeStr(Name); Name := NewStr(This2); end else begin DisposeStr(Name); Name := NewStr(This1); end; Redraw; MenuBar^.Select; ClearEvent(Event); end; end; var T: TTestApp; begin T.Init; T.Run; T.Done; end. Q.0309: Changing of colors A: ... Q.0310: ListBox's NewList method A: ... Q.0311: Making another menu item the default A: ... Q.0312: I inserted an inputline in a window and now the colors are wrong? A: in the constructor of your window have a line with: Palette := wpGrayWindow; and change GetPalette to function TMyindow.GetPalette : PPalette; const P : array[dpBlueDialog..dpGrayDialog] of string[Length(CBlueDialog)] = (CBlueDialog, CCyanDialog, CGrayDialog); begin GetPalette := @P[Palette]; end; which should do the trick. Q.0313: How can I disable the close icon in a window? A: Anwer was provided by Stephen C. Trier: "Turn off the wfClose flag. You may also need to call disableCommand([cmClose])." Q.0314: How can I disable editing of an inputline? A1: Make it unselectable: Options := Options and not ofSelectable; A2: If making it unselectable is undesirable, give it the following validator: type PDisableEditValidator = ^TDisableEditValidator; TDisableEditValidator = object(TValidator) function IsValidInput(var S: string; SuppressFill: Boolean): Boolean; virtual; end; function TDisableEditValidator.IsValidInput(var S: string; SuppressFill: Boolean): Boolean; begin IsValidInput := False; end; ... MyInputLine^.SetValidator(New(PDisableEditValidator, Init)); ... ----------------------------------------------------------------------- ************************************* *Extended or new TurboVision objects* ************************************* Q.0401: How do I display a dialog box with running text? For example to display the current line when I print a text file. A1: There are several possible solutions. The most simple one, not very TV-ish but very effective is the following program: program Test; uses Objects, Views, Dialogs, App, Crt; type PMyDialog = ^TMyDialog; TMyDialog = object(TDialog) constructor Init; end; var MyText : PStaticText; constructor TMyDialog.Init; var R : TRect; begin R.Assign(0,0, 20,10); inherited Init(R, 'Demo'); Options := Options or ofCentered; R.Assign(0,0,5,1); MyText := New(PStaticText, Init(R, '0')); MyText^.Options := MyText^.Options or ofCentered; Insert(MyText); R.Assign(4,7, 14,9); Insert(New(PButton, Init(R, 'O~K~', cmOK, bfDefault))); end; var MyApp : TApplication; s : string; i : word; begin MyApp.Init; DeskTop^.Insert(New(PMyDialog, Init)); for i := 1 to 100 do begin DisposeStr(MyText^.Text); Str(i:3, s); MyText^.Text := NewStr(s); MyText^.DrawView; Delay(100); end; MyApp.Done; end. This solution relies on having a pointer to a static text. The text of this static text is changed and the now dynamic text is redrawn with a call to its DrawView method. There are other solutions, see A2 and A3. A2: Use an inputline. Again, have a pointer to an inputline. Use now the following sequence of method calls to change the value in the inputline for i := 1 to 100 do begin Str(i:3, s); MyInputLine^.SetData(s); Delay(100); end; A call to DrawView is not necessary anymore as SetData should redraw itself. A3: A very TV-ish solution would be to work with messages. Create for example the TDynamicText object, a descendent of TStaticText. TDynamicText has only the HandleEvent method overridden. This HandleEvent method should react to broadcast messages with the command cmChangeDynamicText and change the Text field according to the PString in Event.InfoPtr. You could then change text as easily as: for i := 1 to 100 do begin Str(i:3, s); Message(DeskTop, evBroadCast, cmChangeDynamicText, @s); Delay(100); end; Q.0402: How can I create a password inputline? A: Easiest is to create TPassWordInputLine, a descendent of TInputLine which overrides the Draw method. Example TPasswordInputLine: type PPasswordInputLine = ^TPasswordInputLine; TPasswordInputLine = object(TInputLine) procedure Draw; virtual; end; procedure TPasswordInputLine.Draw; var s : string; i : integer; begin s := Data^; for i := 1 to length(s) do Data^[i] := '*'; inherited Draw; Data^ := s; end; Q.0403: How do my inputlines get Cut/Paste capabilities? A: The standard inputline doesn't provide this, but it is not difficult to create one. The following code was posted more or less by Michael Charles Carney to the TurboVision mailinglist and implements the Paste capability. I probably add the Cut/Copy facilities in the next release of this FAQ. type PLayoffInputLine = ^TLayoffInputLine; TLayoffInputLine = object(TInputLine) procedure HandleEvent(var event: TEvent); virtual; end; procedure TLayoffInputLine.HandleEvent (var Event: TEvent); procedure ClipPaste(var Buf : PEditBuffer; Offset, Length : word); var rec : string; begin rec := ''; {--- Check to make sure we don't exceed field length ---} if Length > MaxLen then Length := MaxLen; {--- Copy contents of clipboard to input line ---} Move(Buf^[Offset], Rec[1], Length); {--- Set the length of the string ---} Rec[0] := Char(Length); {--- Set the data in the dialog ---} SetData(rec); end; begin inherited HandleEvent(Event); if (Event.What and evCommand <> 0) and (Event.Command = cmPaste) then begin with ClipBoard^ do ClipPaste(Buffer, BufPtr(SelStart), SelEnd - SelStart); ClearEvent(Event); end; end; Note: cmShiftIns should be defined to return cmPaste. Another option is to check for (Event.What = evKeyBoard) and (Event.KeyCode = kbShiftIns). Q.0404: Are there any TV Screen savers? A1: Yes, several. A2: Mr. ?? (gross@aecds.exchi.uni-heidelberg.de) uploaded a sample TP 7.0 screen saver for TurboVision to garbo.uwasa.fi. File name: SCRSAV10.ZIP Small documentation Source included A3: Edwin Groothuis has build a screen saver too. For fidonet users, Freq SCRSAV at 2:284/205. It should also be on simtel and its mirrors. The current version is called SCRSAV4.ZIP. Q.0405: How do I insert, delete or edit items from a collection assigned to a TListBox? A: The concept is very easy. You maintain one collection to which you insert, from which you delete and edit. You should however maintain the relation ship between the number of items the TListBox thinks your collection has and your collection really has. Here follows the code for a simple TStringCollection and the associated TListBox. I called its descendent TStringInputBox. TListBox2 is the general object for editing lists, TStringInputBox is tailored to TStringCollections. type PListBox2 = ^TListBox2; TListBox2 = object(TListBox) constructor Init(var Bounds: TRect; ANumCols: Integer; AVScrollBar: PScrollBar); procedure HandleEvent(var Event : TEvent); virtual; procedure InsertItem; virtual; procedure DeleteItem; virtual; procedure EditItem; virtual; end; PStringInputBox = ^TStringInputBox; TStringInputBox = object(TListBox2) procedure InsertItem; virtual; procedure DeleteItem; virtual; procedure EditItem; virtual; end; {* TListBox2 *} constructor TListBox2.Init(var Bounds: TRect; ANumCols: Integer; AVScrollBar: PScrollBar); begin inherited Init(Bounds, ANumCols, AVScrollBar); Options := Options or ofPostProcess; end; procedure TListbox2.HandleEvent(var Event : TEvent); var b : Boolean; begin inherited HandleEvent(Event); case Event.What of evCommand : begin case Event.Command of cmBInsertItem, cmInsertItem : InsertItem; cmBDeleteItem, cmDeleteItem : if Focused < Range then DeleteItem; cmEditItem : if Focused < Range then EditItem; else Exit; end; { of case } end; evBroadCast : begin case Event.Command of cmReceivedFocus : if Event.InfoPtr = @Self then EnableCommands([cmInsertItem, cmDeleteItem]); cmReleasedFocus : if Event.InfoPtr = @Self then DisableCommands([cmInsertItem, cmDeleteItem]); else Exit; end; { of case } end; else Exit; end; { of case } ClearEvent(Event); end; procedure TListbox2.InsertItem; begin Abstract; end; procedure TListbox2.DeleteItem; begin Abstract; end; procedure TListbox2.EditItem; begin Abstract; end; {* TStringInputBox *} procedure TStringInputBox.InsertItem; var s : string; begin s := ''; if InputString('Parameter', s, 255, '', hcNoContext) = cmOK then begin List^.Insert(NewStr(s)); SetRange(Range+1); Inc(Focused); DrawView; end; end; procedure TStringInputBox.DeleteItem; var s : string; begin if UserAnswer('Delete current item?', hcNoContext) = Yes then begin List^.AtFree(Focused); SetRange(Range-1); DrawView; end; end; procedure TStringInputBox.EditItem; var s : string; begin s := GetStr(PString(List^.At(Focused))); if InputString('Parameter', s, 255, '', hcNoContext) = cmOK then begin List^.FreeItem(List^.At(Focused)); List^.Insert(NewStr(s)); DrawView; end; end; Q.0406: Can I use the Idle method to do background processing? A1: Certainly. A2: A idea, borrowed from Xt (X Intrinsics Toolkit), for general background processing is: - you have a collection with far pointers to boolean functions - add functions to this collection if you need a certain background task to start - when Idle is called it does the following things - if the collectionis empty, do nothing - else for each function in the collection - execute it - if it returns true, remove it from the list - else retain it for the next round I think I post code to do this in the next version of this FAQ. A3: For example printing in the background involves the following steps: 1) Write first to a very fast storage device, usually your local harddisk. Now your application has finished its printing and can return to the user for doing other tasks 2) Now the Idle method comes into play. As the user gets attention again the Idle method will be called when the user does not input anything. As even fast typers don't even approach 100 characters per second the Idle method will be called very often. Now your Idle method can call the PrintInBackground procedure. The PrintInBackGround procedure can print for example the first 10 characters of the file on your harddisk (if you choose to print first to your harddisk). Then it finishes and returns to Idle. Idle returns to, your user can type something and Idle is called again. Now the next 10 characters are printed and so on. Your application will remain responsive and the Idle time will be utilized efficiently. BTW, There are other and more advanced solutions possible to the background printing issue but this is one of the simplest. Q.0407: Has anyone extended the editors object with word-wrapping, >64KB files, etc.? A: I've never used it but the best thing around seems to be NEWED.EXE or NEWEDIT.ZIP. Latest version is 2.00. It's free, but there is no support however. No files bigger than 64KB, but centering text, word-wrapping, auto-indent, and more are included. It's meant as a total replacement for the Editors unit. For TP 6.0 an older version called NED103.ZIP should be still around. These files can be found in CompuServe's BPASCAL forum, library 1 and in most ftp archives and BBSs mentioned above. Q.0408: How can I add printing capabilities to the editor object? A: You need to take the following steps: 1. Add method Print to the TFileEditor object. 2. Add uses Printer to the implementation uses clause. 3. Change TFileEditor.HandleEvent to call the Print method when for example the command cmPrint is received (in this case you need to add the cmPrint command somewhere in the interface also). 4. Code the Print method as follows: function TFileEditor.Print : Boolean; var i : word; begin if CurPtr <> 0 then begin i := 0; while i <= CurPtr do begin write(lst, Buffer^[i]); Inc(i); end; end; i := CurPtr+GapLen; while i < GapLen+BufLen do begin write(lst, Buffer^[i]); Inc(i); end; if IOResult <> 0 then EditorDialog(edPrintError, @FileName) else Print := TRUE; end; 5. This Print method is a bit more advanced than described above, because when an error occurs the EditorDialog is called with the edPrintError constant which is not yet defined. You can add const edPrintError = 11; or something similar to the interface. Q.0409: Is there a way to have multiple (for example *.bat *.com and *.exe) fileselections in TFileDialog? A: Yes. You have to copy code from StdDlg to do this. You need to change TFileDialog (constructor Init and ReadDirectory) and TFileList (ReadDirectory)to do this. I haven't seen any code to cut/paste in your program. It isn't too difficult anyway. BTW, Why isn't TFileDialog.ReadDirectory not virtual??? Q.0412 My popup menu's do not dispose the memory they allocated. What's wrong? A: This is a bug. You need to change the TMenuPop or you can create a new descendent as is done below. type PPopupMenu = ^TPopupMenu; TPopupMenu = object(TMenuPopup) destructor Done; virtual; end; destructor TPopupMenu.Done; begin DisposeMenu(Menu); inherited Done; end; Q.0413 How do I add backtracking to the helpfile enginge? A: That's not done easily yourself. I recommend using TVToys for this. Q.0414: How can I use the arrow keys to change from one control to another control? A: Quite an interesting patch was posted by Mark Cole in the PascalNet area TURBOVISION.PAS. Marc can be reached at 115:4400/0 (you need to be on PascalNet also to reach him). Below his original posting. @@add comment this is global, another solution is to override TDialog.HandleEvent is local solution. @@add your EventError handler which does Enter key as well. It maybe known to most people but I was recently forced to discover this trick. If you want users to be able to use the up/down arrows to move around dialog boxes as they are often used to doing in other applications you can do it in one step by overriding Application.EventError like this... Procedure MyApp.EventError{(VAR Event: TEvent)}; begin case Event.KeyCode of kbDown: if Current <> nil then begin Event.Keycode := kbTab; Event.Command := kbTab; Current^.HandleEvent(Event); end; kbUp: if Current <> nil then begin Event.Keycode := kbShiftTab; Event.Command := kbShiftTab; Current^.HandleEvent(Event); end; end; end; Then, if the current focussed view is one that does not interpret the down/up arrows then it will end up as an abandoned event and get changed into a TAB. Q.0415: How can I change the DeskTop's background? A1: The most basic change is to change the character used to draw the background. You can simply do this by overriding TDesktop.InitBackGround. To get a space instead of a #176, simply write: type PMyDeskTop = ^TMyDeskTop; TMyDeskTop = object(TDeskTop) end; procedure TMyDesktop.InitBackground; var R : TRect; begin GetExtent(R); New(Background, Init(R, ' ')); end; This does not yet work, because the Application object still inserts a desktop of type TDeskTop. To have your desktop inserted, overwrite TApplication.InitDesktop as follows: procedure TMyApplication.InitDesktop; var R : TRect; begin GetExtent(R); Inc(R.A.Y); Dec(R.B.Y); DeskTop := New(PMyDesktop, Init(R)); end; A2: The following code was provided by Edwin Groothuis. It implements a desktop which uses files created by the TheDraw program. Save files as binary and simply use this tool. { ANSI DESKTOP: Creates an desktopbackground for TurboVision with an ansi drawning. (c) Edwin Groothuis 1994. Released in the public domain. Usage: - Make an drawning with TheDraw - Save it as an binary file - Convert it with BinObj (example: BinObj sign.bin sign.obj sign) - Link it with your application Note: Do not (I repeat: Do not) overlay this unit. } {$O+,F+} unit AnsiDesk; interface uses App,Objects; Type PAnsiBackGround=^TAnsiBackGround; TAnsiBackGround=object(TBackGround) BckGrnd:pointer; constructor Init(Var R:TRect;APattern:Char); procedure Draw;virtual; end; PAnsiDesktop=^TAnsiDesktop; TAnsiDesktop=object(TDesktop) procedure InitBackGround;virtual; end; implementation Procedure TAnsiDesktop.InitBackGround; Var R:TRect; AB:PAnsiBackGround; begin GetExtent(R); New(AB,Init(R,#176)); BackGround:=AB; end; Constructor TAnsiBackGround.Init(Var R:TRect;APattern:Char); var f:file; begin Inherited Init(R,APattern); Assign(f,'FNNR.COL'); {$I-}reset(f,1);{$I+} if IOResult<>0 then BckGrnd:=nil else begin case R.B.Y of 23: begin Seek(f,256); GetMem(BckGrnd,4000); BlockRead(f,BckGrnd^,4000); end; 41: begin GetMem(BckGrnd,6880); Seek(f,256+4000); BlockRead(f,BckGrnd^,6880); end; 48: begin GetMem(BckGrnd,8000); Seek(f,256+4000+6880); BlockRead(f,BckGrnd^,8000); end; else begin GetMem(BckGrnd,8000); Seek(f,256+4000+6880); BlockRead(f,BckGrnd^,8000); end; end; close(f); end; end; Procedure TAnsiBackGround.Draw; begin Inherited Draw; if BckGrnd<>nil then WriteBuf(0,0,Owner^.Size.X,Owner^.Size.Y, BckGrnd^); end; end. Q.0416: F11, F12 keycocdes A: ... ----------------------------------------------------------------------- ******************************** *3rd Party TurboVision products* ******************************** Q.0501: Which TurboVision screen generators are available? A: There are several available each with different capabilities and prices. We try to keep the information presented here as up to date and valid as possible, but the facts may supersede the following list. - Shazam II, TP6.0, $99.95 Menubar, statusline and dialog box (DlgDsn included) creating Author: Johnathan J. Stein cis: 76576,470 email: 76576.470@compuserve.com The author provides an update voor Shazam II so it can produce programs which can compile under Turbo Pascal 7.0 For fidonet users, this file can also be requested as UPDATE7.ZIP at Contrast (2:281/527). - DlgDsn 4.6, TP/BP 7.0, $30 (free for non-commercial users) Dialog box creating Author: Dave Baldwin cis: 76327,53 email: 76327.53@compuserve.com - PtGen 1.32, TP/BP 7.0, $35 + $6 shipping and handling Menubar, statusline, dialog box and string resource creating Author: Berend de Boer cis: 100120,3121 email: berend@beard.nest.nl fidonet: 2:281/527.23 - ResEdit vs 2.0, TP 7.0, $149 TURBO VISION Development Toolkit, demo RESDEMO.ZIP in subdirectory /turbo-vision/both at vtucs.cc.vt.edu. Features: TMenuBar, TDialog, TStringList resource file generation, some code generation, extended TV objects, many utilities For TURBO PASCAL and C++ Original author: Blaise Computing Inc. Fred Leban informed me that Blaise computing was acquired by IDC. Here an extract from his message. Blaise Computing has been acquired by Innonative Data Concepts (IDC). You may contact them by phone: (215) 443-9705 fax: (215) 443-9753 bbs: (215) 364-9131 Compu$erve: GO IDCSUPPORT Technical Support: 71333,1575 (internet: 71333.1575@compuserve.com) Customer Support: 75300,564 (ditto) Snail Mail: 122 North York Road, Suite 5 Hatboro, PA 19040 - QuickRez v2.0, TP7.0, $25 ($40 with manual) Resource Generator Features: TMenuBar, TDialog, TStatusLine, TStringList resource file and/or code generation Author: Tri-Power Consultants 3149 Casa De Campo #F306 San Mateo CA 94403-2155 cis: 72451,622 email: 72451.622@compuserve.com Q.0502: Are there other good TurboVision packages? A: Yes. In this section I cover the ones I find good/useful. - CyberTools 2.5, author Steve GoldSmith. You can reach Steve on the internet at s.goldsmith2@genie.geis.com. Formally these tools were known as Custom Characters (?) The greatest problem I have with CyberTools is that it does not work under DesqView/X, but probably view of you use this environment. It works without hitch under Windows 3.x. CyberTools consists of several packages. Quoting from the docs: CyberFont (tm) provides fonts, graphics, PCX images, sprites, bit map animation and DAC palettes. CyberFont is simply the fastest and easiest to use Turbo Vision graphics enhancement around. Now with new Windows (tm) look for CyberFont apps! CyberAnimation is a fast 256 color animation player, creator and PCX importer/exporter. Animation format faster and smaller than FLI format! Great for multimedia or game applications. CyberBase for Paradox Engine 3.x includes a new generic table editor window, generic table and index create, memo editor, cut and paste fields, easy engine configuration, automatic locks and validation. CyberTerm for Async Professional 2.x is a professional multi-session async communications application with CyberScript (tm) script language, IDE and supporting tools. If you were disappointed with other Turbo Vision terminals then CyberTerm is for you! - TVTools 2.0, author Richard Hansen. Richard can be reached on CompuServe as 70242,3367, on the internet at 70242.3367@compuserve.com, on fidonet at 1:282/115. Do not confuse this with TVTool from Marc Stern which is for C++. The package is available both as rhtoolsX.zip (on the internet) and as tvtoolsX.zip. From the docs: The TV Tool Box package was created to fill a few holes in Turbo Vision for Turbo Pascal. TV Tool Box includes formatted data entry with input masks, scrolling data entry dialogs, data entry field locking, check mark menus, enhancements to TApplication, some handy string routines, scrolling dialog boxes, 3D controls, virtual list boxes, spin bars, sliders and more. - TVToys 1.5 from Far Niente Productions. You can reach author Peter Brandstr”m on the internet at d91-pbr@nada.kth.se. Personally I like this package well. I also support a bit of it in PtGen. From the docs: An improved Help viewer with back tracking and the possibility to add Contents and Index pages or whatever without recompiling HelpFile. Extended video mode support. Code that determines what video modes are available and presents a list for the user to choose from. Video7 and VESA support included. Custom fonts. Support for three different font file formats. Palette routines. Change the EGA/VGA palette. A mouse unit that limits the effects of buggy mouse drivers in extended video modes. Three demonstration programs, personal configuration files. Lots of commented code, tried and tested. - TVDMX 2.5, a highly configurable browser object. Recommended if you search a browser. - SCRSAV5, TurboVision Screen Saver Module by Edwin Groothuis. Edwin can be reached on the internet as edwin@mavetju.iaehv.nl Q.0503: Which commercial packages offer TurboVision support? A: Object SkipJack, Turbo Power's BTree ----------------------------------------------------------------------- ************************** *TurboVision and Graphics* ************************** Q.0601: How do I switch to graphics mode and back? A: Borland has provided an example program TVBGI which can be found somewhere down the ftp.cica.indiana.edu:/ftp/pub/pc/borland hierarchy. It is quite non-trivial so no example can be posted here. TVBGI contains the GraphApp unit which has all the procedures you need to do the job. Q.0602: Is there a version of TurboVision completely running in graphics mode? A1: Borland has not released one. A2: But others have filled this gap. There are three programs doing this: TVGraph, CyberTools and TVGraphic. TVGraph seems rather slow, CyberTools does not work under DesqView/X. TVGraphic seems to be the best of the bunch. CyberTools is covered above in the 3rd party section, a short review of the other two follows. - TVGraph 1.21, author Chis Burke. You can reach Chris on Internet as clb@prism.mindware.brisnet.org.au, on fidonet as 3:640/307.0. filename: TVG120P.ZIP Quotes from the documentation: All that is required is to include TVGRAPH in the uses statement in your main program and amazing - TV will work in graphics mode. Multi resolution support 320x200 upto 800x600 (higher resolutions coming) Optional BGI or BIOS graphics initialisation Much faster text emulation since dropping EGA support Much easier graphics capability using object oriented graphics objects which are inserted much the same way as normal TV objects are. More robust displaying of graphics that used to disappear at TV's whim. - TVGraphic 2.0, author Richard P Andresen. Richard can be reached on CompuServe at 71222,1200, on the Internet at 71222.1200@compuserve.com, FAX +1 802-482-6101. Get the latest demo version at: CIS: GO BPASCAL, TV Library (18), TVGR70.ZIP Internet: ftp.std.com:/vendors/Andresen/tvgr70.zip Quotes from the 1.5 documentation: TVGraphic is a port of Borland's text based Turbo Vision to DOS graphics mode with extensions, enhancements and a pleasing graphic look. It runs using the Borland EGA/VGA graphics driver in color or black and white. It requires Turbo Vision TPU's plus the Graph unit to compile programs. Core functionality is nearly identical to Turbo Vision but the BGI coordinate system is used. Minor source changes are required to port existing TV applications that use standard views. Version 1.5 is shareware - see license and registration info on pages five and six. Windows .bmp Bitmaps and an intrinsic blinking text cursor plus the ability to work with a visual design tool for Dialogs are new in ver 1.5. See files BITMAP.DOC and TOOLS.DOC. Future directions may include Protected mode version for BP 7.0, VESA 800x600 support, C++ version, macro recorder/playback. Significant Portions of Turbo Vision not emulated in this version 1. History unit 2. Editors unit - development in process 3. TV2.0 MultiCheckBox 4. TV2.0 Validators 5. TV2.0 Extended Dialog Palette 6. TV2.0 Outline unit TextView unit:a file of mods to the TV source code is supplied. ----------------------------------------------------------------------- The end. --------------------------------------------------------------------