Graphics Support in Visual FoxPro
Visual FoxPro 8.0 replaces native support for rendering Graphics Interchange Format (.gif) and Joint Photographic Electronic Group (.jpeg) formats with Graphics Device Interface+ (GDI+), the next generation graphics device interface for Microsoft Windows XP and future releases of the Windows operating system. Visual FoxPro supports all formats that GDI+ handles such as the following, including animated .gif files:
File extension | File type name |
---|---|
.ani | Animated Cursor |
.bmp | Bitmap |
.cur | Cursor |
.dib | Device Independent Bitmap |
.emf | Windows Enhanced Metafile |
.exif | Exchangeable Image File |
.gif, .gfa | Graphics Interchange Format |
.ico | Icon |
.jpg, .jpeg, .jpe, .jfif | Joint Photographic Electronic Group, JPEG File Interchange Format |
.png | Portable Networks Graphics |
.tif, .tiff | Tag Image File Format |
.wmf | Windows Metafile |
Note In Visual FoxPro, cursor, animated cursor, and icon files can be used as graphics files. For example, you can specify an animated cursor file for the Picture property for the Image control. However, the Image control displays the static representation of the cursor.
If Visual FoxPro does not recognize a particular version of a natively supported format such as a .bmp, .dib, .cur, .ani, or .ico, it passes them to GDI+ for rendering. Therefore, as new static file formats become supported in future versions of GDI+, Visual FoxPro can support them automatically.
With GDI+, Visual FoxPro includes the RotateFlip property on the Image control so you can rotate and invert, or flip, an image. For more information, see RotateFlip Property.
Note GDI+ is installed with the Windows XP operating system and is required to run Visual FoxPro. Visual FoxPro includes a merge module for redistribution with custom applications running on Windows 98, Windows Me, Windows NT 4.0, and Windows 2000 platforms.
Visual FoxPro provides graphics support in the following three areas:
- Language
- Controls and objects
- User interface
Language
You can use the GETPICT( ) function to access the Visual FoxPro dialog that provides access to valid file formats. You also can access graphics through properties in the controls and objects described here.
Controls and Objects
The following table lists Visual FoxPro controls and objects with properties for which you can specify graphics files. You can now specify .gif, .jpg, .cur, .ani, and .ico graphic files for these properties in addition to the .bmp and .dib graphic files supported in previous versions of Visual FoxPro.
Control or object | Properties |
---|---|
CheckBox Control | DisabledPicture DownPicture Picture |
CommandButton Control | DisabledPicture DownPicture Picture |
ComboBox Control | Picture |
Container Object | Picture |
Control Object | Picture |
Custom Object | Picture |
Form Object | Picture |
Image Control* | Picture |
ListBox Control | Picture |
OptionButton Control | DisabledPicture DownPicture Picture |
Page Object | Picture |
_SCREEN System Variable | Picture |
* Visual FoxPro supports animated .gif files only for the Picture property of an Image control.
User Interface
You can choose graphics files by using the Open dialog box in several Visual FoxPro designers. The Open dialog box for the following designers includes all valid graphic file formats.
Form Designer and Class Designer
You can find and select an image by opening the Open dialog box in the Form and Class designers for a property in those controls that support graphics files.
To select an image in the Form and Class designers
- In the Properties window, double-click the Picture property.
Visual FoxPro displays the Open dialog box for you to find and select an image.
Project Manager
You can find, select, and add a graphics file to a project in the Project Manager.
To add a graphics file to a project
- In the Project Manager, select Other Files in the All or Other tabs and click Add.
Visual FoxPro displays the Open dialog box for you to find and select an image.
Report Designer
You can find and select an image using the Open dialog box in the Report Designer.
To select an image in the Report Designer
- On the Report Controls toolbar, click the Picture/ActiveX Bound Control button. Drag the cursor, which appears as a crosshair, to a band of the Report Designer and click the left mouse button once to make the Report Picture dialog box appear.
- In the Report Picture dialog box, click the File radio button and click the ellipsis (...) button.
Visual FoxPro displays the Open dialog box for you to find and select an image.
GDI+ Image Support
GDI+ is a class-based application programming interface (API) for C/C++ programmers. It enables applications to use graphics and formatted text on both the video display and the printer. Applications based on the Microsoft Win32 API do not access graphics hardware directly. Instead, GDI+ interacts with device drivers on behalf of applications. GDI+ is also supported by the 64-bit Windows operating system.
GDI+ can be used in all Windows-based applications. GDI+ is included in Microsoft Windows XP and Windows Server 2003 operating systems. GDI+ is required and available as a redistributable for Visual FoxPro applications that run on the Windows NT 4.0 SP6, Windows 2000, Windows Millennium Edition, and Windows 98 operating systems. To download the most recent distributable, visit the Platform SDK Redistributables Web site at:
https://www.microsoft.com/msdownload/platformsdk/sdkupdate/psdkredist.htm
or the Microsoft Download Center Web site at:
https://www.microsoft.com/downloads/release.asp?releaseid=32738
Visual FoxPro 8.0 might include both Vfp8r.dll and Vfp8t.dll run-time libraries. The Gdiplus.dll file must be present in the system directory of the user's computer.
Animated .gif Image Support
Animated .gif files are a popular variety of the .gif file format. They use the same file extension (.gif) and contain specific image frames that cycle through to produce an animated effect. The animated .gif file contains the number of times the .gif file cycles through before stopping. Visual FoxPro supports animated .gif files as follows:
- Visual FoxPro supports animated .gif files only for the Picture property in the Image control.
- Animated .gif files are displayed at both design and run time.
- Visual FoxPro displays only the first frame of an animated .gif file when it appears anywhere else but the Image control.
- Visual FoxPro cycles through an animated .gif file based only on its internal loop count setting.
- Visual FoxPro pauses between animation loops for one second.
- If the size or location of the Image control changes at run time while an image animation plays, Visual FoxPro resets to the first frame and continues.
- Visual FoxPro draws the .gif image size as specified by the .gif file author, not the Image control. Visual FoxPro does not clip or stretch the image.
- During animations, the entire image or part of it is erased so that the next frame can be redrawn. Visual FoxPro minimizes unnecessary redrawing to avoid flickering. If the image position is moved, for example, the control or its container is moved, the entire image needs to be redrawn.
- Because Visual FoxPro internally stores a single representation of a particular image as an off-screen bitmap, multiple Image controls using the same animated .gif file are always synchronized together. If you want the animations of the same image to behave differently for each Image control, you should create a copy of each animated .gif file and rename each one.
- The author of animated .gif files can specify the amount of time between frames. This amount of time can differ between each frame. Therefore, it is possible for animated .gif files to have excessively long delays between frames.
- If you use an animated .gif file in a control other than an Image control, animation of the image does not play. However, if you later use the image in an Image control, the image animates only if you first issue a CLEAR...RESOURCES command. This occurs because the image is already stored in memory, and the animation attribute is being ignored when the image is rendered in a non-image control. You must use CLEAR...RESOURCES to reload the image into memory.
See Also
Creating Access and Assign Methods | Access and Assign Methods | Picture Property | Image Control | CLEAR Commands