Universal Thread
Level Extreme .NET Magazine April 2008 issue

Universal Thread Magazine March 2007 issue

News
Links
Downloads
Articles
Books
Conferences
Magazines
Training
Jobs
Consultants
Companies
Blogs
FAQ
Applications
What's new

User groups

Next meetings
Past meetings
User groups
Available speakers
Tips
User group leaders
Subscribe

Miscellaneous

Personalities

Universal Thread documentation

Acronyms
Affiliates
Support area
Team
Troubleshooting
Time zones
Web Service
Terms & Conditions
Copyright
Manage your account for the messages area options, your subscription information, your invoicing, youir banners and your picturesSubscribe to the Universal Thread and get all the benefits related to the messages areaA corporate subscription is needed for companies that have more than one developerAccess the Universal Thread store to purchase your subscription and bannersThe Universal Thread is covering several conferences per year. On site, reporters cover the technical aspect of the conference as well as making interviews, taking pictures and videos and other related content. Get all the reports from our coverages site.Universal Thread home pageLevel Extreme .NET Magazine, a newly published online magazine by Level Extreme about Microsoft .NET technology and its communityUniversal Thread Magazine, a magazine dedicated to the Visual FoxPro community

 Page:  of 10
Search:  ID:  
Item: 1-50 of 473 

Enumerating printer forms under Windows NT/2K/XP [May 12, 2008 10:57]
It's quite simple to enumerate the forms supported by the specified printer using Windows API, but it is complicated to retrieve information about forms because it's returned as C/C++ structure and VFP doesn't have built-in capabilites to work with structures. However it can be done as shown below. The latest version of this article Enumerating printer forms

How to add/delete custom printer forms under Windows NT/2K/XP [May 12, 2008 10:35]
To distribute applications that use repors with custom paper size you have to create custom printer forms on every destination PC that runs Windows NT/2K/XP. The mskb #Q157172 How to Create Custom Forms in Windows NT 4.0 and Windows 2000 explains how it can be done manually. However there's a way to do that programmatically using Windows API. The latest version of this article Add and delete custom printer forms

How to pass parameters to VFP EXE [May 9, 2008 22:10]
Passing command-line parameters from Windows to VFP EXE is different from passing parameters to VFP programs or functions in VFP application. 1. All parameters are passed to EXE as strings 2. Parameters should not be enclosed in single quotes because quotes will be treated as part of parameter 3. Parameters with spaces can be ecloused in double quotes 4. Prameters are separated by spaces not commas The latest version of this article How to pass parameters to VFP EXE

How can I get the number of jobs in print queue [May 9, 2008 22:08]
The following code uses Windows API function OpenPrinter(), ClosePrinter() and EnumJobs() to get number of jobs in a print queue. It also shows how to use Windows API functions GetLastError() and FormatMessage() to retrieve a code and text of the last API error. The latest version of this article Get number of jobs in print queue

Enumerating jobs in print queue [May 9, 2008 22:07]
It's quite simple to enumerate jobs in print queue using Windows API, but it is complicated to retrieve information about jobs because it's returned as C/C++ structure and VFP doesn't have built-in capabilites to work with structures. However it can be done as shown below. The latest version of this article Enumerating jobs in print queue

Cannot access selected table error [May 9, 2008 22:04]
The explanation for the error 'Cannot access the selected table (Error 1152)' - 'You have attempted to select a table outside the 32K work area range or are attempting to reference a file variable in a table that is not open' in help isn't too helpfull. The latest version of this article Cannot access the selected table (Error 1152)

How to delete all Print Jobs from a print queue [May 9, 2008 22:03]
The Windows API SetPrinter function can be used to delete all jobs from a print queue. A specific print job can be deleted by SetJob function. The following code has been tested under Windows 2000 and Windows XP but may work under earlier Windows versions. The latest version of this article How to delete all Print Jobs from a print queue

How to make SQL Pass-Through cursor updatable [April 29, 2008 13:34]
The SQLEXEC() function in VFP allows downloading of data from any data source through ODBC. Unlike remote views, SQL Pass-Through approach does not provide default (automatic) settings in the returned cursor to update data on the server after changes in the cursor at the client side. Anyway, it is possible to customize required properties to organize updating. First of all, it is recommended to read chapters about SQL Pass Through commands in the MSDN, specially, chapters that explain propert...

Fastest way to find orphans [April 29, 2008 10:16]
This FAQ describes a fast way to find orphans. There could be several methods to find orphans, but I show the best method for huge tables. I would like to thank Walter Meester for the idea described in this FAQ. This FAQ entry is based on this thread: Databases,Tables, Views, Indexing and SQL syntax Re: Best way to find orphans - seek vs SQL Thread #444141

Data Conversion / Merge with Update and Insert [April 26, 2008 19:51]
Over the years I've seen many people ask how to take a new set of data and use it to update an existing set of data. I've done various versions of this kind of code. Usually this is done with a very large complex program that involves lots of seeks, scan, append blanks and replace commands. Here's my latest approach.

How to return a value from dynamically executed T-SQL code [March 25, 2008 10:30]
You can return a value from a dynamically executed T-SQL into a local variable using OUTPUT parameter of system extended stored procedure sp_executesql. This method is shorter and simplier than the common practice of using a temporary table. It's documented pretty well in SQL Server 2005 Books Online under sp_executesql (Transact-SQL)

Eliminating duplicates in a table [August 3, 2007 12:11]
This FAQ demonstrates several methods to eliminate duplicates from a table with their Pros & Cons. This FAQ entry is based on this thread: Forum: Visual FoxPro Category: Databases,Tables, Views, Indexing and SQL syntax Title: Re: Updating records in FoxPro tables Thread #565010

How can I release all open forms [July 18, 2007 10:49]
This entry is based on the following thread: Coding, syntax & commands Re: Program to close all forms Thread #359746. In order to release all open forms you need to do it backwards through the collection. If the forms use the QueryUnload method to check to make sure the form can be released, you'd need to check the results of that as well.

Removing double quotes from tab delimited file [June 6, 2007 09:07]
Looks like VFP command COPY TO 'TabDelimitedFile.txt' DELIMITED WITH "" WITH CHARACTER TAB now produces the correct result, so the approach described in this FAQ becomes obsolete. ============================================================================== This FAQ illustrates one approach to remove double quotes from text files (which may be huge). VFP can not produce these files natively, therefore we should either produce the file using Textmerge at the first place, or make some tw...

Open any document [March 25, 2007 10:39]
The following function will open any document, with its default association (the same application that will be called when you double-click on the file, in Windows Explorer). Use it to open a text-file, a Word or Excel document, an image, etc., with an external application.

Dataset Databinding and Formatting Not Refresh [February 27, 2007 14:12]
I notice that when you use Databinding with format string, it seems that the format was not refresh in realtime. This can be solved by hooking to BindingComplete Events and force re-evaluated the data.

Class to close any cursors created after it was instantiated [February 2, 2007 18:11]
Generally, datasessions serve this purpose - they create an isolated environment where our code can run and use tables, cursors etc as it pleases, without disturbing other code. Sometimes wee need a little more granularity - to have a routine which may create any number of cursors, open additional tables, and close them all when done, without closing any previously open ones. This simple class will do just that.

Running under Terminal Services [January 20, 2007 12:32]
Is the application running under TSE?

How to prevent BackSpace key in a TextBox from moving a cursor to the previous control [December 22, 2006 09:15]
Deleting characters in a TextBox with BackSpace key doesn't stop when cursor reaches the begining position but unexpectedly moves cursor to the previous control. It could cause unintended deletion of the data there. ...

Why non read-only grid behaves as read-only [December 11, 2006 14:24]
One of the common problems with the grid control is that it doesn't like columns controlsources to be specified without table prefix. Quite often in this situation grid starts to behave as read-only. One simple way to avoid it - specify column's controlsource in TableName.FieldName manner and not just FieldName.

Validating that a path and filename is usable [December 11, 2006 12:26]
This presents a function to validate that a path and filename are valid to use. Recently, it became neccesary to validate that the user entered a usable file name. There are certain characters that can not be used in a file or folder name. Not to mention invalid path to the files. The code I present here solves the problem.

SPT cursor fetching and progress displaying for SPT cursor downloading [August 15, 2006 16:01]
SQL Pass Through commands often can take a lot of time for running and returning the result set to the client. It is often usefult to show a progress bar in case of such lengthy process. Also, FetchAsNeeded option, available for views, could be very useful for SPT cursors as well. However, how we can open SPT cursor and set FetchAsNeeded option for it? Here is a sample code for opening the cursor in "FetchAsNeeded" mode, as well as a description of approach for organizing the progress bar for...

Auto-Dock Tool Windows in VFP [August 12, 2006 11:13]
Here's a tip to help keep useful windows available and where you want them. Create a program called devUtils.prg and store it in the VFP home folder. Also, create a file named Config.fpw there. In the Config.fpw file, add the following text: Command = DO devUtils.prg In the devUtils.prg, add the following code: *JCJB* Setup useful OKLs. ON KEY LABEL F12 DO DockWindows IN devUtils *JCJB* Dock the Tool windows and open the Project. DO DockWindows PROCEDURE DockWindows *JCJ...

Duplicating inserts and updates on two databases for two tables [January 19, 2006 16:12]
I'm sure (developers though) you have already lived a situation like this: having 2 databases (with the same tables) and need to "replicate" the data, each time an INSERT or UPDATE is made. It seems very simple, until someone add a new feature: "Oh, by the way, all the fields are equal, except the Number, that should remain sequential for each table". Now, as you can see, you must forget the INSERT FROM... clause.

How to pass cursor between two VFP datasessions (without using XML) [January 19, 2006 02:37]
Example of passing cursor as object across VFP datasessions boundaries. Story is simple. We store cursor (or part of it) into custom object properties using one function 'cur2obj', then we pass that object reference at our own terms to another session object (or form with private datasession), where we use counter function 'obj2cur' to restore original cursor data from that object but this time in receiving session. Since temporary cursor/arrays are used to prepare/store cursor data, we shou...

How to copy more than 16,383 records to Excel [January 10, 2006 17:07]
The COPY TO TYPE XL5 command in VFP copies only 16,383 records. This limitation is due to the XL5 format that had a limit of 16,383 rows per worksheet (see MSKB Q103355). In Excel 97 and Excel 2000 the maximum number of rows is 65,536. Unfortunately, there is no TYPE XL8 keyword in VFP.

Custom Page or Printer Form on Crystal Report and different machines [December 22, 2005 21:49]
When you use Custom page in Window 2000,XP and higher, we have to create first our custom form on the print server. Using Crystal report, we can easily use the custom paper. Example we can create 1/2 of the letter Size or simply 8.5by5.5 paper. This works fine in crystal, but the problem occur when you use different printer model especially on a different machine. This is because crystal report same printer form ID instead to form name. So if you create 8.5by5.5 form on machine1 and machine2 i...

MS Access MDB to VFP tables [November 12, 2005 08:13]
Well it started when I found it hard to check rtf files for MSDN subscription index. In last few shipments there were also an MDB in 'UN-SUPPED' directory but my Access is too perfect to use an MDB so I decided to get Access data to VFP tables.

Inheritance tutorial [October 8, 2005 08:16]
This is a step-by-step tutorial to show inheritance, specifically in Visual FoxPro forms, as a guidance for people who are not familiar with inheritance in general, or who don’t know how to implement it in Visual FoxPro. The basic idea of inheritance is that all your forms, or several of your forms, obtain their properties and methods from a "base form". It is possible to do changes only once, in your "base form"; the changes will be propagated to all your forms.

CHM help file shows error messages instead of help pages [October 7, 2005 22:01]
Due to a recent Windows security fix, users can no longer access a CHM file on a server. The table of contents appears, but the individual pages are replaced by error messages. Access to CHM files in specific folders can be explicitly allowed through special registry settings.

Getting the names of parameters in the parameter list at runtime. [July 12, 2005 11:18]
Sometimes the developer needs to determine the names or values of the parameters in a parameter list during runtime. The following routine returns the name of the parameter based on it index into the list of parameters. It is a refined routine first conceived by Hugo Ranea. Thanks Hugo.

Running a VFP app as a Service on Win 2003 & XP Pro Systems [June 15, 2005 22:30]
Running a VFP app as a service is a snap! Just download the Windows 2003 Resource Kit from Microsoft at... http://www.microsoft.com/downloads/details.aspx?FamilyID=9d467a69-57ff-4ae7-96ee-b18c4790cffd&DisplayLang=en and follow the instructions in this FAQ's description.

Save General Data to a File [June 11, 2005 13:20]
This code and information is designed to put you on the right path to retrieve the stream of data from a general field and store it into a file. I have put together useful sites and code snippets that will help you retrieve data for BMPs, JPGs and PDFs. Using these general techniques you should be able to get data for any file type.

Progress Bar Class Example [May 18, 2005 23:36]
We often find the need for progress indication (read: eye candy) in our applications. While many different solutions for progress bars are available, I like having a pure VFP solution that runs in its own process. So here is an OLEPUBLIC Progress Bar Class (designed to be compiled into a COM Server EXE). Its chief advantage is the ability to run smoothly even when your application is crunching on a single line of code.

How to keep focus in Last Control that have it [April 21, 2005 02:25]
Many times you want the Last Control in your form to keep the focus after you made some operations that cause LostFocus of that control (Clickig on Button in the form or something similar). This code is tested on VFP 8 SP1, but I am sure that there will be no problems in other version of VFP.

Is a table part of DBC? [April 18, 2005 10:19]
It is easy to find out if a table belongs to the open DataBase Container (DBC) using INDBC() function. Sometimes it's neccessary to check it w/o refering to DBC itself. The low level VFP file functions (LLFF) can be used to open a table as a file and check it's header for relevant information. The Table Header Record Structure is documented in VFP help under Table File Structure.

Printer Pooling for DOS Printing in WIndows XP [November 15, 2004 18:37]
A printer pool is a physical group of identical printers (printers of the same model or that have a similar emulation which allows them to share the same print driver) that are connected to a single computer via different logical ports. When configured as a printer pool the group of printers behave as one printer. In Windows XP, when a user sends a print job to the printer, the job goes to the print queue first. Then the print server polls the printer to see if it is available. If it is, the jo...

How to Turn Off a TreeView's Tooltips [November 15, 2004 18:37]
The current MS TreeView ActiveX (SP4) control does not support a property for turning off tooltips. The following code will set the TVS_NOTOOLTIPS style bit so that Tooltips will not be processed. #define TVS_NOTOOLTIPS 128 #define GWL_STYLE -16 DECLARE INTEGER SetWindowLong IN win32api INTEGER, INTEGER, INTEGER = SetWindowLong(ThisForm.oleTree.hwnd, GWL_STYLE, TVS_NOTOOLTIPS) As you can see it relies on the undocumented HWND property exposed by the TreeView control.

Getting Windows Folders [September 8, 2004 00:02]
A number of different methods exists to retrieve information about where Windows stores its system and user-related common files, these locations, refererred to as Special Folders, systems folders and the like, are in reality something called CSIDLs (Common System ID Locations), which although may be different on a per-user or per-system basis, will always exist on a system.

Installing Internet Information Server (IIS) on Windows 2000 (Win2k) [August 27, 2004 05:26]
Instructions on installing and securing Internet Information Server on Windows 2000. It is recommended to read this even if your IIS is running smoothly on your Windows development/server machine. Tools are applicable to Windows XP and IIS 6.0. Notice that IIS is present in Windows 2000 Pro and Server versions and in Windows XP Pro and Server versions, but is not available in Windows XP Home edition.

How to make a grid appear like a list similar to list box [July 28, 2004 00:28]
This article describes how to configure grid to appear as a list similar to the list box or the drop-down list of combo box. It is for appearance only. All other things are as usual for any grid. This is useful for case when need to replace list box by a grid to display more records, because listbox is slow when displaying 1000+ rows in listbox.

How to create a custom script with intelliscript [July 1, 2004 00:41]
Custom scripts are different from scripts that are invoked via a command or function. The big plus to command or function is that custom scripts may invoke everywhere in a line, while command can be invoked only as first word and functions need a "(". There are some problems to write a custom script with intellisense. It is even uneasy to duplicate the examples zloc and zdef that ship with VFP8.0 and beyond. This FAQ points to the steps to create a custom script. It will use a IF .. ENDIF st...

Least common multiple and greatest common factor [May 30, 2004 20:51]
The code shows how to quickly obtain the greatest common factor, and the least common multiple. Both functions are used when manipulating fractions, among others. Several methods are possible; the method usually taught in school involves prime numbers, but this code will execute much faster (and it is much simpler) than the use of prime numbers.

How to determine Debug or Release Mode [February 15, 2004 18:26]
This FAQ will show you how to extract a compiler emitted attribute to determine if the current assembly has been built using a Debug or Release configuration and set debug specific JIT compiler settings for Release builds. The information is current for the .NET Framework 1.1, documentation version 1.1.0.

How to check if drive is ready [December 25, 2003 23:19]
It's a good idea to make sure that there is media in the removable drive before accessing it and display user friendly message instead of system error message if drive isn't ready. It can be done using Windows Scripting Host (WSH) or with help of Windows API.

A faster alternative - Replace your OptionGroups/ComboBoxes by TextBoxes. [July 17, 2003 08:52]
I've been using FoxPro since 2.5 DOS and I used a lot of TextBoxes to set something like "[Y]es or [N]o". When I started to use VFP, I changed this kind of control to OptionGroups. It looks great, but the users complain a lot arguing that pressing "Y" or "N" is much simpler (and faster) than using this new control. So, I decided to go on using the TextBoxes for this sittuation. Look at it and learn the easy way to control it!

An easy way to distribute small binary files [June 13, 2003 16:32]
The type of small binary file that come to mind was the cursor files. These littles files that we must copy somewhere on the user machine during install. If you have icons or bitmaps, it's not a problem, the files can be build into the executable. But the cursor must reside on the disk somewhere near the exe. This was the @beep*&% little binary that i always remember to add to the installation after the build of the install disks.

Terminal Server Auto Logon [May 15, 2003 19:27]
This describes how to assign a valid userid and password for network authentication when using Terminal Server.

Using Oracle SPs to Insert and Update Data from VFP [April 14, 2003 10:50]
This demo code will connect to Oracle [using your ID and password] to create a table of Presidents, a trigger, a sequence and some stored procedures. The stored procedures can be called to insert and update data in the Presidents table. Three of the methods in the VFP class will pass data values to the Oracle procedures which will either be inserted into the table or update existing records in the table. The update SPs will also return a value equal to the number of records updated.

How to Change a file's Attributes (With only the Window API)? [April 3, 2003 17:42]
Here is a way to set a file's attributes (System, Readonly, Hidden, Archive, etc) without requiring any component other than the standard Windows API.

Copyright © 1993 - 2008, Level Extreme Inc., All Rights Reserved
62 rue Doucet, Petit-Rocher, New Brunswick, E8J 1L3
Telephone: 506-783-9007 Email: mfournier@levelextreme.com