Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Controls, Events, Commands, and More : Page 4

Dive right in to Visual FoxPro 9.0's new properties, events, and methods; new or improved commands; and FoxPro Foundation Classes (FFCs).


advertisement
Retrieving Active SQL Connection Statement Handles
The new ASQLHandles function creates an array with the handles for all active SQL connections. Those handles can then be used with other functions such as SQLExec and SQLDisconnect.

lnConn1 = SQLStringConnect(; "driver=sql server;server=(local); "+; "database=northwind;") lnConn2 = SQLStringConnect(; "driver=sql server;server=(local); "+; "database=pubs;") ASQLHandles(laHandles) Display Memory like laHandles

Get Cursor and Count Records Affected by SQL Pass-Through Execution
The SQLExec function has been improved to make it possible to immediately get cursor and count records affected by the SQL Pass-Through command. A parameter is passed determining the name of the created array with a list of aliases and a record count produced by the SQL commands.

This code snippet demonstrates this enhancement, producing multiple result-sets:

lnConn = SQLStringConnect("driver=sql server;"+; "server=(local);database=northwind;") SQLExec(lnConn, ; "Select * from Customers; "+; "Select * from Employees", "", aCount) Display Memory like aCount

View Classes Inside a Program File (.prg) with the Class Browser
The Class Browser now has the ability to manage program-based (PRG) classes. In previous versions, only Visual Class Library-based (VCX) classes could be viewed. For developers who write several PRG-based classes (like me!), this is definitely a very-welcome feature.

GDI+ FFC classes
 
Figure 3. Image Manipulation: You can now draw images directly onto a form using GDI+.
Visual FoxPro 9 has a new FFC (FoxPro Foundation Class) library for the Graphics Device Interface (GDI) called _GDIPlus.vcx. This library has many classes working as wrappers around the GDI+ API.

By using GDI+, you can manipulate graphics and images, so this is a really powerful feature. Entire articles could be devoted to this topic, exploring the different classes, how to use them, and when to use them, but it's beyond the scope of this article. I'll just mention these classes here so that you don't overlook this new feature in your excitement over the other new features.

One simple example of image manipulation is a small program that loads an existing bitmap file from disk, and then creates a new JPEG file from it, as shown in the following code snippet:



*-- Create an Image object. Local oLogoImage As GpImage ; Of Home(1)+"ffc/_gdiplus.vcx" oLogoImage = ; Newobject('GpImage',Home(1)+'ffc/_gdiplus.vcx') *-- Load an image file in memory. oLogoImage.CreateFromFile("c:\Fox.bmp") *-- Save the image to a JPG file on disk. oLogoImage.SaveToFile("c:\Fox.jpg",; oLogoImage.GetEncoderCLSID("image/jpeg"))

Another example is the ability to manipulate images and draw them on a device such as a form. Listing 2 shows an implementation of that, and Figure 3 shows the result. Notice that the image shown on the form was drawn right onto it, rather than added using the Visual FoxPro Image object.

 
Figure 4. FFC Classes: The new FFC classes for GDI+ are similar to the ones found in the .NET Framework.
The important thing to notice is that you can manipulate the image before drawing it, perhaps adding a logo or watermark, or drawing text on it. It's also worth mentioning that the new Report engine in Visual FoxPro can leverage the power of GDI+, so if you're planning on doing powerful stuff with reports, take a serious look at the GDI+ FFC classes.

These classes (shown in Figure 4) map to the classes available in the .NET Framework. I strongly suggest that you read the articles about using GDI+ with the .NET Framework published in previous editions of CoDe Magazine, so that you can understand what sorts of things can be done with this technology. Then you should be able to translate most of the .NET code into Visual FoxPro using the FFC classes.

There are many improvements and new features in Visual FoxPro 9 that are both productivity tools and exciting new ways of building interesting and useful applications. I've only briefly covered some of the developments you'll find when you start playing with this new version. Make sure you take a close look into the "What's New in Visual FoxPro" section on the Help file, and have fun!



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date