Visual FoxPro FAQ Part 2

April 15th, 1996 foxfaq@iinet.net.au
Comments, suggestions and better solutions are invited.
INDEX

Vfp - Freeware Utilities

Vfp - Setup Wizard Error

Vfp - Complex Views in a Database Container

Vfp - Control of ComboBox ItemForeColor

Vfp - Editbox class to allow ENTER to move focus


Return to Index
VFP - FREEWARE UTILITIES

Q. What freeware VFP utilities are available? A. Here is an initial list thanks to Pete (the Lenti site) and Willy De la Court (the Ping site). (I will add to these next time. In the meantime, please email me with other entries you think should be here. Gordon) ADDPRP.ZIP - Paul Bienick's property adder to objects outside their class libraries. Very useful.
SLOB.EXE - Tom Rettigs utility to set properties on groups of selected objects - saves a lot of time.
TRUE.EXE - Tom Rettigs Utility Extensions (TRUE). Classes for extending the database container with custom properties (such as a next invoice number counter - incrementing function provided by Tom). Also a class for setting the foxpro enviroment and a function for turning a prg into a class vcx file. The data base extension is a must.
FFRPT.ZIP - Linus Hung's find and filter classes - nice examples.
SUPERCLS.ZIP - Ken Levy's superclass utility that shows and edits the parent class of the method
JTOOL.ZIP - Joe Homnick's formatting toolbar class that automatically formats data bound textbox controls with a caption, input mask, name, height and width property settings. Additionally, it sets font, size, bolding for all selected controls on a form.
LISTRU.ZIP - William J. O'Connor's utility to provide a well formated List Structure report of Visual FoxPro Tables.
CLASSES.ZIP - George L. Dvorak's utility to list all class libraries and program files related to a project file.
BARCODE.ZIP - Paul Andre LeBlanc's barcode font. An easy way to create barcodes from within Visual FoxPro.
DBCX.ZIP - Mike Feltman's utility for extending DBC files.
BLDSQL.ZIP - Jon Wiest's end user SQL Builder enabling users to create create complex boolean expressions.
JMTOOLS.ZIP - Jorge Martinez's set of editor extensions for VFP. including: Comment/UnComment · Indent/Outdent · Nest Structures · AutoExpand · QuickGrab · Remember Caps · Field List Builder · and Set Default To.
VFPTOOLS.ZIP - Kelly G. Conway's VFP object manipulation tools to enable properties to be set for multiple selected objects, and browsing of properties, events and methods for an instantiated class (object)
OBJECT EXPLORER 1.1 The ObjectExplorer by Markus Egger is a tool which allows you to explore objects in the memory of Visual FoxPro. It displays objects, their properties, events and methods, and all their member-objects with all their properties, events and methods. You can edit the properties and you can fire the events and methods. This tool can also act like a builder. In this case you can't fire the methods, but you can edit the source code instead. There are some little bugfixes in this version. But the really important things are the new features to hide methods and default properties. Using this features, you have a lot better overview over your objects.
GENREPOX 2.0 GenRepoX by Markus Egger is a powertool extender. It is very similar to GenScrnX and GenMenuX. It extends the internal FoxPro report writer with *:-commands. This tool is freeware and my be copied and used as often as you want. Some of the most important features are: Functions in reports, multiple detail bands, coloring fields and changing their fonts depending on their values, choosing fields from a list, and lots more.


Return to Index
VFP - SETUP WIZARD ERROR "Setup Was Not Completed Successfully"

John Doppler Q. While trying to install from distribution disk #1, I receive the following message: "Setup Was Not Completed Successfully". No other message appears or gives any clue as to "why" the installation failed. A. John Doppler Try deleting everything in the copyright information field in the Setup Wizard. There's a bug which causes the setup to choke if your copyright info is over a certain length. There is a Knowledge Base article that provides the specifics.



Return to Index
VFP - COMPLEX VIEWS IN A DATABASE CONTAINER

From: Kirby Urner Q. Can I create more complex views in a dbc than the Visual View-Builder allows? A. Kirby Urner The visual query builder is only so-so. Really complex SQL, or even semi-tough, with parenthetical nested ands 'n ors and what not, can't be constructed visually. And forget about stuff like : SELECT blatt FROM table WHERE blatt NOT IN (SELECT...). However, one CAN define such SQL views programmatically, and still have them appear in the dbc. They show up as tables, and when you click on 'em, they activate and show columns in a browse window, like good little views should. The only problem is that you cannot click on 'Modify' in order to change them. You will just get a message 'Feature Not Available' because the behind-the-scenes SQL is too sophisticated for the visual builder.



Return to Index
VFP - CONTROL OF COMBOBOX ITEMFORECOLOR

From: Brien Givens Q.I am struggling with a combobox. I have a table of Consultants (ConsID, ConsName). Every Consultant can be classified by one or more Keywords (KeyID, Kword). Every Keyword belongs to one or more Consultants, so I have a 3rd table KeyCons (ConsID, KeyID). The form shows Consultant per Consultant. I want the combobox to show not only the actual keywords, but all available keywords, with the actual ones highlighted. How to do this? A. Brien Givens So basically you want to design a ComboBox where you have individual control over the ItemForeColor of each item in the list. I toyed with this for a bit and couldn't get it to work. What you could do is use a one column grid that is populated from an SQL statement. When a particular consultant is selected, run this code: SELECT keyid, kword, .t. AS isvalid FROM KeyWords ; WHERE keyid IN (SELECT keyid FROM KeyCons ; WHERE consid = m.consid) ; UNION ; SELECT keyid, kword, .f. FROM KeyWords ; WHERE keyid NOT IN (SELECT keyid FROM KeyCons ; WHERE consid = m.consid) ; ORDER BY 2 ; INTO CURSOR MyCursor In the DynamicForeColor setting for the Grid Column, type this; IIF(IsValid,RGB(0,0,255),RGB(0,0,0)) This will highlight valid rows in red, and leave the rest black. You can include code in the DoubleClick setting for the column that will add (or delete) an appropriate record to the KeyCons table and then rerun the query. This will take up more room on your form than a popup, but it's the best I can come up with.



Return to Index
VFP - EDITBOX CLASS TO ALLOW 'ENTER' TO MOVE FOCUS

From: Mike Chalk Q. When moving through fields (textboxes) on a form using 'ENTER', my cursor sticks at editboxes and I have to use the mouse to move on. How can I fix this? A. Mike Chalk Subject: VFP Editbox enhancement I was asked just recently for a method of allowing users to treat memo edit boxes like normal boxes when they move through the fields on a form by just pressing <ENTER>. You can use <TAB> but that is messed up if you allow tabs in a memo, also <ENTER> rather than <TAB> makes for a more consitant feel to a form. Moving with a mouse can be a real irritation for users entering lots of text in a form. The demo below includes my editbox base class which addresses the problem. Sorry the posting is so long (especially for non VFPers) but I thought it may be useful to some foxfolk out there. Anyone out there got their own VFP snippets they would like to share? Mike ******** Copy from here, paste into an empty .prg and run oTestForm=CREATEOBJECT("Form") WITH oTestForm .WindowType=1 && set modal to avoid using READ EVENTS for demo .Autocenter=.T. .Caption="Move between editboxes without tabs or mouse!" .Width=550 .Height=250 .Addobject("oText1","TextBox") && add an ordinary text box control WITH .oText1 .Top=20 .Left=50 .Width=450 .Value="Standard text box, press enter" .Visible=.T. ENDWITH .Addobject("oEdit1","TestEdit") && add an enhanced edit box control WITH .oEdit1 .Left=50 .Value="Try pressing enter as soon as the cursor focuses here" .Visible=.T. ENDWITH .Addobject("oEdit2","TestEdit") && add an enhanced edit box control WITH .oEdit2 .Left=300 .Value="Add some of your own text and then press enter twice" .Visible=.T. ENDWITH ENDWITH oTestForm.Show DEFINE CLASS testedit AS EnhancedEditBox && Subclass EnhancedEditBox .Width=200 .Top=50 .Height=150 ENDDEFINE ************************************************************************** * Mike Chalk ASAD SYSTEMS Ltd. mikechalk@dial.pipex.com ENGLAND ************************************************************************** * * Enhanced editbox base class - A user can use the enter key to step * through editbox fields by pressing <ENTER> (avoiding having to press * tab or mouse click to move through a form which includes memo edit * boxes). Focus is shifted past the edit box if <ENTER> is the first * key press or if <ENTER> is pressed twice at the end of the memo. * You can also force the memo field to be upper case if you set * property lUppercase=.T. or if you enter a ! in the editbox format * property (like formatting a text box). * ************************************************************************** DEFINE CLASS EnhancedEditbox AS Editbox lUppercase = .F. && Set to .T. if you want to force upper case lEnhanced = .T. && Set to .F. to switch of enhancements Name = "aeditbox" PROTECTED lAllowTabs && Remembers status of allowtabs property PROTECTED nNewKeyCode && Holds the current key pressed PROTECTED nOldKeyCode && Holds the key before this one PROCEDURE GotFocus This.nNewKeyCode=0 && initialise nKeyPress to indicate next key && pressed is the first in this editing session This.AllowTabs=This.lAllowTabs && reset allow allow tabs in case it && was changed by me last session ENDPROC PROCEDURE Init This.lAllowTabs=This.AllowTabs && remember allow tabs setting * Force upper case if put ! in the format (like a texbox control) IF This.lEnhanced AND ('!' $ THIS.format) This.lUppercase=.T. ENDIF ENDPROC PROCEDURE KeyPress LPARAMETERS nKeyCode, nShiftAltCtrl * If escape is pressed then reset as if nothing has been entered * Otherwise remember the last key pressed and the current key IF nKeyCode=27 This.nNewKeyCode=0 ELSE This.nOldKeyCode=This.nNewKeyCode && roll over key presses This.nNewKeyCode=nKeyCode && now remember this key press ENDIF * Force upper case if required IF This.lUppercase AND BETWEEN(nKeyCode,97,122) KEYBOARD UPPER(CHR(nKeyCode)) NODEFAULT ENDIF ENDPROC PROCEDURE InteractiveChange * Terminate edit if the first key pressed is an Enter (so you can * move through the fields by pressing enter. Also terminate if * you have pressed Enter twice at the end of the memo field LOCAL cValue IF This.lEnhanced AND This.nNewKeyCode=13 AND ; (This.nOldKeyCode=0 OR ; RIGHT(This.Value,4)=CHR(13)+CHR(10)+CHR(13)+CHR(10)) * Remove leading and trailing blank lines from the memo cValue=THIS.value DO WHILE LEFT(cValue,2)=CHR(13)+CHR(10) cValue=SUBSTR(cValue,3) ENDDO DO WHILE RIGHT(cValue,2)=CHR(13)+CHR(10) cValue=LEFT(cValue,LEN(cValue)-2) ENDDO This.value=cValue This.AllowTabs=.F. && make sure tab will terminate this edit KEYBOARD CHR(9) && stuff the keyboard with a tab to move on ENDIF ENDPROC ENDDEFINE && EnhancedEditbox ******** End of demo and class definition