** Visual FoxPro Tips, Tricks and Utilities
This page contains answers to common questions
handled by me, along with some tips and tricks that I have found
useful. These have been presented here as questions and answers.
Click on the topics listed to view the answers.
Some useful utilities are also added.
- DataBase
- Utility to Pack all tables in a directory.
You can use this generic routine to pack all tables in your data
directory without need to specify individual table names.
This will work from FoxPro Dos 2 to current VFP 8 version.
- Utility to Reindex all tables in a directory.
You can use this generic routine to reindex all tables in your
data directory without need to specify individual table names.
This will work in FoxPro Dos 2 version to the current VFP 8 version.
- Utility to Rebuild CDX Index Files.
Use this utility to drop the compound index and rebuild them
without having to worry about the index expressions.
- Extract Structure of all DBFS in a Project.
Use this utility to get the tables structure of all tables in the active
project. The utility will save the table structure in a text file.
This will be handy for project documntation.
- Utility to copy DBFs from one DBC to another DBC.
Use this utility to create a table in a project which will be identical
to the table in another project.
- Utility to set up the view Captions as in parent Tables.
Views created will not carry with them the captions used in the tables.
After creating the views, run this utility to copy the field captions to
the views quickly.
- How to extract duplicate records from a table ?
For example, a sigle field such as Account_Id field may be existing more
number of times in a table, while the rest of the records content could
be different. Or simply two fields concatenated may exist more than once
in the same table. We can quickly obtain a list of such field values or
a complete list of all such extra records as shown in this link.
- Forms
- A sample search form.
The form displays the table open in the current default work area.
The form has buttons to go to First, Last, Next, Previous records.
- A form to disply PDF files from within VFP.
As the title goes, a simple form to display PDF files within VFP.
This can be suitably modified to pass on a file name as parameters
to auto open and display a PDF document.
- A form to disply HTML files from within VFP.
A simple form to display HTML files within VFP. This can be suitably modified
to pass on a file name as parameters to auto open and display a HTML document.
- How to animate in VFP form ?
We can show animation using AVI files in VFP forms to show file-copy in
progress, backup-in-progress and such activities. This can be achieved
easily as shown in this sample form.
- A sample form with OUTLOOK components.
A simple real VFP form containing Outlook automation components.
One can see the code behind and incorporate the needed functions in a
similar way into a VFP application.
- How to hide the Main VFP Screen ?
The VFPs screen appears as default background screen in all the
applications built. Click open this link to see a simple way to
hide this VFP's background screen.
- Why does Lost focus does not retain focus ?
Click this link to find out how to do this.
This can help to use the LostFocus event in the place of Valid event.
- How to provide TAB facility in Edit Control ?
When you create an Edit Control for Memo fields data entry, the user may
need to TAB within the control. However, by pressing TAB key, VFP's default
behaviour of switching the focus to next control happens. Here is a
simple way to provide the user with the TAB facility.
- How to control the focus in the current object
while arrow keys or backspaces tend to take the control to the next object ?
When a textbox is in focus, it is likely that a backspace or left/right
arrow key or home or end key is pressed while at the initial or ending
positions of the control. The default behaviour is to take the focus to
the next control as if up arrow key or down arrow key is pressed.
To avoid this situation you can do what has been suggested here.
- How to release a form or shut an application after inactivity ?
You can aoto release a form or application after a certain allowed time
of keyboard inactivity or no mouse clicks by a user. Look here to see
how this can be done.
-
Why do my forms dont show up in a client computer, while it shows in development environment ?
Why do I get an error, 'Cannot Quit Visual FoxPro' ?
Why do my application dont close or shut when I release the form or Click on X in the titlebar ?
- A form to collect your KB articles from internet.
This is an internet pages copy/download organizer. We cut and paste a
lot of articles while browsing the internet. You may be doing the cut
and paste even from these pages. This utility form provided in this link
will help to collect all these data conveniently and in one single table,
so that we can view them easily when we want.
- Greetings form - a foxy way to send your greetings.
My seasons greetings to all the readers and a happy healthy prosperous
new year ahead. This is a cool vfp code that can be used as a greetings
form. You can call this as a function with your custom greetings words to
suit the occassion and add your personal name as signature besides using
your own bmp or gif or jpg to show picture. You can also compile it to
an EXE or as COM DLL whatever, and distribute. Have fun !
- Grids
- Menus
- Reports
- Upgraded - Cross Tab generator - gsXtab1 - An alternative to VFPXTAB
This is an alternative to VFPXTAB.PRG, the default _genxtab. The earlier
gsXtab has now been upgraded to gsXtab1 to take care of VFP version 8.
This will work with VFP6 or VFP7 also. Still earlier versions have not
been checked by running this. This can be used as the default xtab by
specifying _genxtab = "gsXtab1.prg". This gsXtab1 is expected to do the
job several times faster, could be even upto 10 times faster, depending
on the specific table involved and the environment.
- How to hack FRX file and strip printer driver information ?
The VFP application building process also build the printer driver
information as it appears in the application developers system.
This could lead to some gotchas when the application is installed in a
clients computer (if the client does not have the same printer as the
application developer). You can use this function to solve this anomoly
and make the reports free of these drivers.
- How to print Multiple Detail bands in a Report ?
An ingenious way to allow the two child tables records to be output in a
sigle detailed band making it to appear as if it is multiband report form.
- How to print Multiple copies of same report ?
We can hack the report header and make it print multiple copies efficiently.
While one can ask why we need the complicated way of hacking the report header
and set the number of copies, quite often the need arises based on the users
requirements to pre-set the number of copies depending on the user.
The number of copies required can be easily captued and saved.
While that part of setting is not explained here, this topic discusses
how we can achieve to set the number of copies on the fly.
- How to make my Report Tool Bars to appear while Print Preview ?
The end users of a developed application can thus be provided with the
native VFPs report tool bar.
- How to remove the printer button from the print preview toolbar ?
How can we stop one user from printing a report using the print preview
toolbar while we can allow another user to print using the same.
-
What's New in the VFP 8 Report Writer ?
By Cathy Pountney - " Yes, Hell has frozen over and pigs do fly!
Microsoft has made some improvements to the Report Writer in Visual FoxPro 8.0.
Some developers thought this day would never come, but surprisingly it has.
Cathy Pountney explores." - a FoxTalk article.
- Tips and Tools
- Utilities and Useful Functions
- A simple utility to take backup using CABARC.
You can customise it to take backup using WinZips command line utility also.
- A Number to Word convertion utility.
One can use this utility to convert numbers into words such as a total
bill amount printed in words at the end of a document.
- A cursor to collect all files in a specified directory.
Use this function to collect all the file names in a directory into a
cursor. This function also gets all the names of files in any
sub-directory. It is quite easy to modify the function and make these as
parameters to suit your needs.
- How do I send Email using OUTLOOK from my application ?
Explain how an email can be directly sent from VFP using Outlook automation.
- How to build a Password control for my application ?
An ingenious way to build a password control for an application.
Though this may not be en excellent way, this provides a simple concept
and developers can make use of this idea to build more complicated
ways of password control as may be required for their environment.
- How to force current users out of my application ?
In a multiuser environment, need arises to force out other users of the
same application such as while taking data backups.
This link provides a way to do the same.
- How to limit the number of users for an application ?
Cool tips to limit the number of concurrent users for your application.
So you can market your application as 'n' user version to your choice !
- How to ensure that only one instance of my application is running in my desktop ?
How many times we find the users click on the same application icon on the
desktop and open the application multiple times. These extra instances of the
same application, besides adding confusion, eat away the resources making
application slower. You can now control and ensure that the application is
started only once in the same computer.
- How to copy files from one directory to another with the file names case preserved ?
You can use this method to make a regular backup of your data files in a backup directory.
- How to synchronize client computer time with server time ?
With this code snippet, you can synchronize your users workstation date
and time to that of the server.
- How to calculate the difference between two dates in Years, Months, Days ?
It is easy to find the difference between two dates in number of days.
It is not that simple if you want to find that in Years, Months, Days as
a text variable. This function here will return that for you.
- How to calculate the difference between two datetime variables in Hours, Minutes, Seconds ?
This function will provide the code to find the difference between two
date time variables in simple Hours, Minutes, Seconds format as a text variable.
- An application starter utility with added benefits.
This application loader can distribute the server copy of the application
to the local harddisk of network users and then run it. This gives the
advantage of reducing network trafic besides giving the benefit to copy
newer versions without having to ask all users to quit the application.
The next time, the users start, they will get distributed the newer copy
by the loader.
- A choice of different thermometer classes.
It is a nice idea to show a progress bar or a thermometer bar on the form
to let the users know that some activity is in progress. It is made easy
with the simple class code provided. You can have a thermometer based on
careful placement of labels OR based on a OLE class or based on a container
control. All these are provided in PRG code format. A wrapper is put as
an example and so you can download and see how the thermometers or progress
bar will look. The example serves to show how you can integrate the class
code with your application.
- *How to read data from a MICR cheque reader connected to communication port ?
The following example will describe how to read magnetic code line of the
cheques and return the Cheque Number, Bank Code and Branch code using
communication port using a Cheque Reader.
Home
- Ramani's pages access counter since 1 Aug 2003