Using Win32 functions in Visual FoxPro Image Gallery

Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /u/a/anatoliy/ on line 784

Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in /u/a/anatoliy/ on line 786

Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /u/a/anatoliy/ on line 825

Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in /u/a/anatoliy/ on line 827

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /u/a/anatoliy/ on line 490

Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /u/a/anatoliy/ on line 83

Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in /u/a/anatoliy/ on line 85

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /u/a/anatoliy/ on line 793

Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /u/a/anatoliy/ on line 797

Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in /u/a/anatoliy/ on line 803

Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in /u/a/anatoliy/ on line 529
Code examples:
A client for testing non-blocking Winsock server
A procedure for setting file times
Accessing Adobe Reader 7.0 main menu from VFP application
Accessing examples contained in this reference from a VFP application
Accessing examples contained in this reference through Web Services
Accessing LSA Policy object (Local Security Authority)
Accessing Windows Control Panel from VFP Application
Adding a background image to VFP report (VFP9, ReportListener)
Adding an ODBC data source with the SQLConfigDataSource; use automatic or interactive mode
Adding and deleting Scheduled Tasks using NetScheduleJob API functions
Adding and deleting User Accounts
Adding printer to the list of supported printers for the specified server
Adding supplementary data to AVI files
Adding user-defined items to the Control Menu of VFP form (requires VFP9)
Animating a transition of the VFP form (a wire-frame rectangle)
Another way to go online (it is not about choosing an ISP)
Attaching menu to a top-level form
Bitmap Class for Visual FoxPro application
Browsing Windows Known Folders (Special Folders)
Building a tree of subdirectories for a given path using FindFile functions
Capturing keyboard activity of another application with the Raw Input API (VFP9)
Changing file attributes
Changing pitch and speed of a wave file
Class for sound recording
Class library providing access to the System Registry
Clipping mouse cursor area
Comparing dimensions of the VFP main window with _SCREEN properties
Comparing file times
Compressing and decompressing files with Windows API Runtime Library routines
Configuring DEVMODE structure for a printer
Confining Windows calculator inside the VFP main window
Connecting a local device to a network resource
Converting a hexadecimal string to an integer
Converting an HTTP time/date string to a SYSTEMTIME structure
Converting an integer value to a hexadecimal string
Converting characters in a URL into corresponding escape sequences and backwards
Converting command-line string to a set of Unicode argument strings
Converting image file to .ICO file
Converting twips to pixels and vice versa
Converting Unicode data from the Clipboard to a character string using a given code page
Copying picture of the active form to the Clipboard using Enhanced Metafile API functions
Copying strings through the global memory block
Creating a clipping region from the path selected into the device context of a form
Creating a console window for Visual FoxPro application
Creating a device context for the specified printer
Creating a directory on the FTP
Creating a folder
Creating a mailslot
Creating a unique filename based on existing filename
Creating a window using CreateWindowEx function
Creating an Open dialog box to specify the drive, directory, and name of a file to open (Shell32 version)
Creating hash values for the list of names
Creating irregularly shaped FoxPro form using transparency color key
Creating the Open dialog box to specify the drive, directory, and name of a file to open
Creating the Save dialog box to specify the drive, directory, and name of a file to save
Creating two-byte hashes for a list of URLs
CryptoAPI: Collection of Providers class
CryptoAPI: retrieving list of providers
Current keyboard type
Current System information
Custom FTP Class for Visual FoxPro application
Custom GDI+ class
Custom HttpRequest class (WinHTTP)
Custom HttpRequest class (WinINet)
Customizing the frame of top-level form: removing the standard frame (VFP9, Vista)
Deleting files into the Recycle Bin
Detecting changes in connections to removable drives (VFP9)
Dial the Net Automatically
Disabling drawing in the VFP form
Disabling mouse and keyboard input for the main VFP window (with the app still running)
Disconnecting USB Mass Storage Device programmatically
Disk in drive A:
DiskFreeSpace class
Displaying all TCP connections for the local system
Displaying animated images on FoxPro form with BitBlt and StretchBlt functions
Displaying bitmap using the AlphaBlend function
Displaying dimmed window behind VFP top-level form
Displaying hypertext links with the SysLink control (VFP9, Comctl32.dll)
Displaying icons in the system tray (VFP9)
Displaying OS Memory Status
Displaying printer-properties Property Sheet for the specified printer
Displaying standard progress dialog box when copying files
Displaying system dialog that selects a folder
Displaying the associated icons and descriptions for files and folders
Displaying the drive type value
Displaying the main Dial-Up Networking dialog box
Displaying Windows shell folders in TreeView control with Visual FoxPro FLL
Downloading files from the FTP server using InternetReadFile
Dragging files from Explorer window and dropping them on FoxPro control (requires VFP9)
Drawing a rectangle using Windows regular edges and borders
Drawing a window caption using the DrawCaption routine
Drawing cursors for the classes defined by the system (preregistered): BUTTON, EDIT, LISTBOX etc.
Drawing icons associated with the VFP main window
Drawing standard Windows icons
Drawing Windows frame controls using the DrawFrameControl function
Drawing Windows predefined bitmaps using the LoadBitmap functions
Dynamic strings implemented through VFP Custom class
Encapsulating access to the Windows Services in a class
Enhanced GetFont dialog
Enumerating connections made to a shared resource for the local computer (WinNT only)
Enumerating data formats currently available on the clipboard
Enumerating devices installed on the local machine
Enumerating files opened on the network
Enumerating global and local group accounts on a server (WinNT/XP/2K)
Enumerating MIDI output devices
Enumerating network interfaces on the local computer
Enumerating network resources
Enumerating network sessions established on a server
Enumerating ODBC Data Sources available on the local computer
Enumerating ODBC drivers available on the local computer
Enumerating ports that are available for printing on a specified server
Enumerating print jobs and retrieving information for default printer (JOB_INFO_1 structures)
Enumerating print processors and supporting data types installed on the specified server
Enumerating printer drivers installed
Enumerating Processes -- Win9*
Enumerating Processes -- WinNT
Enumerating raw input devices attached to the system (keyboard, mouse, human interface device)
Enumerating servers of the specified type (e.g. SQL Server) in the primary domain
Enumerating the subkeys for a given registry key
Enumerating the subkeys of a user-specific key
Establishing connection using the SQLDriverConnect
Exporting DLL icon resources as .ICO files
Extended MessageBox Class
Extended OS Version info
Extensible Storage Engine class library
Extracting the name and extension parts of a path string
Finding out if the current user is the Guest account
Finding parameters for the region specified
Finding the path to the VFP executable running
FindText -- the hopeless and useless Common Dialog
GDI+ fun: roach-infested desktop
GDI+: copying to the Clipboard (a) image of active FoxPro window/form, (b) image file
GDI+: creating a gradient
GDI+: creating scaled copy of image file
GDI+: Creating thumbnails to preview images in a directory
GDI+: cropping images
GDI+: custom Clock Control
GDI+: Drawing a Pie Chart
GDI+: enumerating fonts installed on the system
GDI+: how to make VFP controls visually shake and shudder
GDI+: Implementing image scrolling with inertia
GDI+: printing image file
GDI+: printing vertical text on VFP reports via generated images (VFP8)
GDI+: printing vertical text on VFP reports via generated images (VFP9)
GDI+: reading and writing metadata in JPEG and TIFF files
GDI+: retrieving list of available image encoders and image decoders
GDI+: rotating images using matrix transformations
GDI+: saving image of FoxPro form to graphics file (BMP, GIF, JPG, PNG, TIF)
GDI+: Scrolling through large image using the mouse
GDI+: sending image of FoxPro form to printer
GDI+: Storing content of the Clipboard to a bitmap file
Generating random cryptographic keys
Get the power status of your laptop computer
GetFocus returns a HWND value
GetProcessVersion points at target OS
Getting a bit more than the _CLIPTEXT offers
High-powered ALLTRIM
How to activate Windows Calculator
How to adjust monitor brightness (Vista, monitor with DDC support)
How to assemble an array of strings and pass it to external function
How to block the ALT+TAB shortcut (WinXP)
How to block the PrintScreen key
How to browse and connect to printers on a network (WinNT)
How to build UDP responder
How to change display settings: screen resolution, screen refresh rate
How to change the name and the size of the font in the MessageBox dialog
How to convert a bitmap file to monochrome format (1 bpp)
How to copy the image of a form to the Clipboard using Bitmap API functions
How to create a desktop shortcut (shell link)
How to create non-blocking Winsock server
How to create transparent areas inside a form -- punching holes in the form
How to delete all print jobs for a printer
How to delete file on FTP server
How to delete IE cookies, clear IE history and delete files in Temporary Internet Files directory
How to detect if additional monitor is connected and active
How to disable the Windows Clipboard (VFP9)
How to display a dialog box with which the user can add a data source (DSN)
How to display a Task Dialog (Vista)
How to display a user-defined icon in the MessageBox dialog
How to display advanced Task Dialog (Vista)
How to display picture stored in enhanced-format metafile (*.emf)
How to display the port-configuration dialog box for a port on the specified server
How to display the Print property sheet
How to display the Properties dialog box for a file (ShellExecuteEx)
How to download a file from the FTP server using FtpGetFile
How to download this reference`s archive through WinInet functions using InternetOpenUrl
How to draw custom Window Caption on FoxPro form
How to empty the Recycle Bin
How to enable the SE_SHUTDOWN_NAME privilege for the application
How to enumerate cookies and URL History entries in the cache of the local computer
How to enumerate logon sessions on local computer
How to enumerate sessions and processes on a specified terminal server
How to enumerate terminal servers within the specified Windows domain
How to enumerate, add and delete shares on the local computer (WinNT/XP)
How to extract frames from AVI files
How to find the application associated with a file name
How to find when the application started
How to find which fonts Windows uses for drawing captions, menus and message boxes
How to generate GUID values
How to hide your program from the Close Program dialog (Win9* only)
How to hot-track menu item selection in top-level form (requires VFP9)
How to initiate System shutdown
How to load a user profile
How to make a VFP form fading out when released (GDI version)
How to make a VFP form fading out when released (GDI+ version)
How to make application automatically close all documents it opened
How to make the caption of a VFP application flashing in the Windows task bar
How to obtain Content-Type value for a file type from the System Registry
How to obtain the number of rows affected by remote UPDATE, INSERT or DELETE statement
How to ping a remote site using ICMP API calls
How to ping a remote site using IP Helper API calls
How to play AVI file on the _screen
How to play MIDI notes
How to position the GETPRINTER() dialog
How to prevent users from accessing the Windows Desktop and from switching to other applications
How to print a bitmap file
How to print FoxPro form
How to print FoxPro form -- II
How to print picture stored in enhanced-format metafile (*.emf)
How to put a horizontal text scrolling on the form (a news line, marquee)
How to put a vertical text scrolling on the form (a movie cast)
How to read email messages using Simple MAPI
How to release and renew a lease on an IP address previously obtained through Dynamic Host Configuration Protocol (DHCP)
How to remove a directory that is not empty
How to remove FTP directory
How to retrieve adapter information for the local computer (including MAC address)
How to retrieve configuration data for a specified printer stored in the registry (PrinterDriverData key)
How to retrieve information about a cache entry (Internet Explorer)
How to retrieve list of system DSNs (Data Source Name) with parameters
How to retrieve network parameters for the local computer (including Host name, Domain name, and DNS Server)
How to retrieve the number of objects stored in the Recycle Bin
How to retrieve the number of print jobs queued for the printer
How to retrieve the size of a remote file (FTP)
How to retrieve version information for the specified file
How to run FoxPro application under different user name (impersonating user)
How to save registry key including its subkeys and values to a file
How to set Creation Date/Time for a folder (WinNT)
How to Start a Process as Another User (NT/XP/2K)
How to suspend or hibernate your system
How to test file attributes (key method for FileExists and DirectoryExists routines)
How to view icons stored in executable files (Icon Viewer) - II
How to view system icons for the classes installed on the local machine
How to write and read Window Properties for the specified window
HOWTO: Use the Win32 API to Access File Dates and Times
Initiating Inet connection using a modem
Listing child windows for the Windows desktop
Listing INF files in a specified directory
Loading a string resource from an executable file
Locking and unlocking file of a VFP table
Locking mouse and keyboard input for the VFP application
Locking the workstation
MapiSendMail class for Visual FoxPro application
Mapping and disconnecting network drives
Memory usage info for current VFP session (WinNT only)
Minimizing all running applications
Monitoring changes in a directory
Monitoring changes occurring within a directory
Monitoring clipboard content changes (VFP9)
Moving shortcut to a specified position on the Windows Desktop
MSMQ: how to open a queue
Number of clipboard formats available
Obtaining a handle to the desktop associated with the calling thread
Obtaining addresses for the adapters on the local computer (Win XP/2003/Vista)
Obtaining current Internet Explorer browser version and UserAgent
Obtaining heap handles and enumerating memory blocks for the current VFP session (WinNT only)
Obtaining I/O counts for the current process
Obtaining information about all user accounts on a server (WinNT only)
Obtaining list of tables stored in an ODBC Data Source
Obtaining MAC address through Address Resolution Protocol (ARP) request
Obtaining names and positions for shortcuts located on the Windows Desktop
Obtaining names of local and global groups for current user (WinNT/XP/2K)
Obtaining OS memory performance information
Obtaining physical parameters for a drive: sectors, clusters, cylinders...
Obtaining provider name for a specific type of network
Obtaining Shell32.dll version
Obtaining some properties for the Windows desktop using the GetWindowPlacement function
Obtaining the bounding rectangle for the specified device context
One more way to retrieve environment strings
Opening access to the Microsoft Internet functions for the application
Opening the Page Setup dialog box to specify the attributes of a printed page
OS version and revision
Passing data records between VFP applications via the Clipboard
Peer-to-peer LAN messenger built with Mailslot API functions
Placing a button on the VFP form as a new child window
Placing an arbitrary rectangular area of main VFP window on the Clipboard
Placing On-screen Alert on top of all windows
Playing WAV files on InteractiveChange
Playing WAV sounds simultaneously
Pocket PC: base class
Pocket PC: creating backup for the System Registry
Pocket PC: creating new database in the Object Store and copying Contacts Database records into it
Pocket PC: custom RAPI class for operating with files and folders on mobile device
Pocket PC: custom RAPI class for operating with the Object Store Databases
Pocket PC: custom RAPI class for operating with the System Registry
Pocket PC: enumerating mounted database volumes and databases in the Object Store
Pocket PC: Folder Viewer
Pocket PC: modifying keys in the System Registry
Pocket PC: retrieving data from the Contacts Database
Pocket PC: System Registry Viewer
PocketPC: creating directories and files
PocketPC: custom RAPI class for executing routines on remote Windows CE device
Power capabilities of the system: battery, UPS, sleep and hibernation modes, processor throttling
Printf-style formatted text output in VFP
Printing Image File, programmatically set print page orientation to landscape
Printing text on the client area of the main VFP window
Printing text on the main VFP window
Printing text with the Escape function
Quering a waveform-audio input device
Quering Audio Mixer Device
Quering waveform-audio output devices
Reading and setting Environment variables
Reading and setting system access privileges for the current process
Reading and setting the priority class values for the current process and thread
Reading current hardware profile
Reading entries from Event logs
Reading header information from AVI file
Reading Internet Query options
Reading keys in the specified section of the Win.ini file
Reading list of folders and files on FTP server
Reading metrics for the currently selected font
Reading parameters of streams in AVI file
Reading security permissions for NTFS files and folders
Reading STARTUPINFO structure for the current VFP session
Reading the state of mouse buttons within DO WHILE loop
Reading the structure of VFP main menu
Reading VFP settings from the Windows Registry
Retrieveing general information about the driver and data source associated with an ODBC connection
Retrieveing information about the active window (even if it is not owned by the calling process)
Retrieving a universal form for the drive-based path for a network resource
Retrieving configuration information for the specified server (Win2000/XP)
Retrieving configuration information for the specified server (Win98/Me)
Retrieving configuration information for the specified workstation (Win2000/XP)
Retrieving country-specific dialing information from the Windows Telephony list of countries
Retrieving current settings for an ODBC connection
Retrieving file information for the VFP executable running
Retrieving geometrical parameters of the system desktop window
Retrieving graphic capabilities of default printer
Retrieving graphic capabilities of your display
Retrieving information about all users currently logged on to the workstation (WinNT only)
Retrieving information about the main VFP window
Retrieving information about the specified icon
Retrieving information specific to the current Time Zone
Retrieving IP statistics for the computer
Retrieving list of all active RAS connections
Retrieving list of files on the FTP directory
Retrieving list of Global Atom names
Retrieving long values associated with the class of the VFP window
Retrieving names for the registered clipboard formats
Retrieving Network Provider information
Retrieving Printer Device Context using PrintDlg function
Retrieving statistics for the TCP protocol running on the local computer
Retrieving System Error message strings
Retrieving the command line for the VFP session
Retrieving the interface–to–IP address mapping table
Retrieving the IP-to-physical address mapping table
Retrieving the name and type of all available RAS-capable devices
Retrieving the name of the default printer for the current user on the local computer (Win NT/XP)
Retrieving the name of the primary domain controller (PDC) and join status information
Retrieving the names of all sections in an initialization file
Retrieving the priority class for the current process
Retrieving the rectangle area where the mouse cursor is confined
Retrieving the state of your Internet connection
Retrieving the System Time adjustment
Retrieving the User Datagram Protocol (UDP) listener table
Retrieving top-child window for the VFP form
Retrieving various system metrics
Retrieving Window Class information for the VFP window
Returning some basic information for the specified INF file
Round FoxPro form
Running a regular FoxPro form while main VFP window is minimized
Running MSDOS Shell as a child process with redirected input and output (smarter RUN command)
Saving available locale records into a cursor
Saving local machine ODBC Registry Entries to XML file
Scanning a hierarchy of child windows down from the Windows Desktop
Scanning the hierarchy of child windows down from the main VFP window
Semi-transparent Form
Sending a standard message with one or more attached files using default email client
Sending email messages with Simple MAPI
Setting properties of the window: caption and user-defined value
Setting the date and time that a file was created
Setting the mouse capture to the specified window
Setting the volume label
Shortcut Menu Class
Simple MAPI: how to pick an email recipient from Outlook Express address book
Simple MAPI: how to resolve a name to unique address list entry
Simple printer queue monitor: deletes, pauses, resumes print jobs for local printer
Simple Window Viewer
Simulating DOEVENTS
Splash Screen for the VFP application
Start an executable from VFP application by using the CreateProcess
Starting a dialog box for connecting to network resources (mapping network drive)
Starting a dialog box for connecting to network resources and passing input parameters
Starting an external application in VFP using WinExec
Starting external program from VFP and waiting for its termination
Storing content of the Clipboard to a bitmap file
Storing registration key in the resources of an executable file
Storing screen shot of a form to bitmap file
Storing screen shot of a form to enhanced metafile (*.emf)
Storing the environment strings in cursor
StrDup returns a pointer to the duplicate of a source VFP string
String representation for disk or memory capacity
Subclassing CommandButton control to create BackColor property
System and Local Time values
System Image List Viewer
Testing an ODBC connection for supporting specific functionality
Testing Clipboard functions: emptying the clipboard
Testing if a connection to an Url can be established
Testing serial ports
The DetectAutoProxyUrl function identifies the auto-config script location
The original LoadPicture() function in VFP returns valid handles to bitmaps, icons, cursors, and metafiles
The SQLGetProp() creates a bridge between Visual FoxPro and the ODBC API
The window and its ancestors
Time in milliseconds represented as string (e.g. 1 hour 24 min 36 sec)
Tracking mouse movement to detect when to start dragging
Transparent Menu Class (requires VFP9)
Uploading file to the FTP server using InternetWriteFile
Uploading local file to FTP server with FtpPutFile
URL: splitting into its component parts
Using an Event Object. Part A: running an application that creates an Event object
Using an Event Object. Part B: running an application responding to events
Using Beep and Sleep functions to make the old tin buzz sing (WinNT only?)
Using Change Notification Objects to monitor changes to the printer or print server
Using Common Controls: the Header Control
Using EnumPrinters function to enumerate locally installed printers
Using Extended MessageBox() Class
Using File Mapping for enumerating files opened by Visual FoxPro
Using FillMemory
Using FlashWindowEx to flash the taskbar button of the VFP application
Using Font and Text functions
Using FoxTray ActiveX control: System Tray Icon and menu attached to VFP form
Using FrameRgn for displaying system colors
Using FtpCommand
Using GetBinaryType (WinNT only) to determine the type of an executable file
Using GetNearestColor
Using GetSysColor
Using InternetGoOnline function
Using InternetSetFilePointer when resuming interrupted download from the Internet
Using IsChild() for testing ThisForm.ShowWindow property
Using mailslots to send messages on the network
Using MessageBeep
Using Month Calendar Control (VFP9, Comctl32.dll)
Using NetWkstaTransportEnum to obtain MAC Address of remote server
Using Path functions from Shell Lightweight Utility APIs (shlapi.dll)
Using the ChooseColor function
Using the CreateFile
Using the DeleteFile
Using the DrawText function
Using the FindMediaType function
Using the GetTempFileName
Using the GradientFill function
Using the heap of the calling process to allocate memory blocks
Using the IsWindowEnabled function
Using the LoadImage function to have a bitmap file loaded and displayed on VFP main window
Using the MessageBox Win32 function
Using the NetMessageBufferSend to send messages on the network
Using the RestartDialog function -- restarting Windows
Using the Semaphore object to allow only one instance of VFP application running
Using the SetErrorMode for determining if a floppy drive is ready
Using the SystemParametersInfo function
Using vendor-neutral SQL constructs
Using Video Capture: displaying on FoxPro form frames and previewing video obtained from a digital camera
Using WM_COPYDATA for interprocess communication (VFP9)
Validating the heap of the calling process
Validating URLs using moniker functions
Verifying a file using the Authenticode policy provider
Vertical Label control
WAV file player
Windows Shell Icons displayed and exported to ICO files (Vista)
Wininet last error description
Winsock: changing the byte ordering
Winsock: connecting to a news server (NNTP, port 119)
Winsock: creating a socket that is bound to a specific service provider
Winsock: how to retrieve a service information corresponding to a port
Winsock: how to retrieve a service information corresponding to a service name
Winsock: how to retrieve the protocol information corresponding to a protocol name
Winsock: how to retrieve the protocol information corresponding to a protocol number
Winsock: initializing the service in the VFP application
Winsock: reading and setting socket options
Winsock: reading email messages (POP3, port 110)
Winsock: resolving an address to a host name
Winsock: retrieving directory listing from an FTP server using passive data connection (FTP, port 21)
Winsock: retrieving information about available transport protocols
Winsock: retrieving information from a host database for a given host name
Winsock: retrieving the host information corresponding to a network address
Winsock: retrieving the standard host name and IP address for the local machine
Winsock: retrieving Web pages using sockets (HTTP, port 80)
Winsock: sending email messages (SMTP, port 25)
Writing entries to custom Event Log
Writing to INI file
Yet another modal dialog: now HTML-based
GDI+: printing vertical text on VFP reports via generated images (VFP8)

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
More code examples    Listed functions    Add comment     W32 Constants      Translate this page Printer friendly version of this code sample
Before you begin:
The code is based on custom GDI+ class. Download the class module first and save it in gdiplus.prg file.

This code sample is presented in two versions, each shows how to generate images (adhoc) and display them on VFP report. While this one is VFP8 based, the other version requires VFP9 and employs its unique features -- ReportListener and its GDIPlus Graphics object.

This is what we are going to achieve in this code sample. For each record two images are generated and imported into general fields BARCODE and BARCODE1. The second image is created by rotating the first one 90-degree counter clockwise.

Two general fields are used for demonstration purposes only -- showing the object before and after being rotated. In a real-life situation there is no need in interim BARCODE field.

Note: these above are entirely fictional names and addresses. Any coincidence is completely unintentional.

* * *
Here the fields from the cursor are displayed in a sample report:

See also:
  • Adding a background image to VFP report (VFP9, ReportListener)
    #DEFINE IMAGE_TARGETFILE SYS(2023)+"\barcode.bmp"
    #DEFINE IMAGE_BACKCOLOR ARGB(255,255,255,255)
    * replace with valid barcode font name
    #DEFINE BARCODE_FONT "barcod39"
    * an instance of gdiplusinit should be created before
    * and released after using any of gdi+ objects
    PRIVATE gdiplus As gdiplusinit, img As gdibitmap
    gdiplus = CREATEOBJECT("gdiplusinit")
    PRIVATE oFont1 As gdifont, oFont2 As gdifont, oFont3 As gdifont,;
        oMatrix as gdimatrix
    STORE 0 TO oFont1, oFont2, oFont3, oMatrix
    DO CreateFonts
    DO CreateMatrix
    DO GenerateData
    DO BrowseResults
    * end of main
    PROCEDURE GenBarcode(cBarcode, cMailtype)
        LOCAL oImage As gdibitmap, oImage1 As gdibitmap
        * create blank image
        oImage = CREATEOBJECT("gdibitmap",;
        * printing text including barcode on the first image
        WITH oImage
            * setting the background, otherwise it is black
                0, 0, .imgwidth, .imgheight)
                oFont1, 2, 5, .imgwidth, .imgheight)
                oFont2, .imgwidth-70, 3, 68, .imgheight)
                oFont2, 10, .imgheight-16, .imgwidth, 14)
                oFont3, .imgwidth-80, .imgheight-14, 78, 13)
        * the first image is saved to bitmap file
        * then imported to general field
        SELECT cs
        * create another blank image
        * note that image width and height are switched
        oImage1 = CREATEOBJECT("gdibitmap", IMAGE_HEIGHT, IMAGE_WIDTH)
        WITH oImage1
            * setting the background, otherwise it is black
                0, 0, .imgwidth, .imgheight)
            * rotation matrix applied
            * the second image is used as a canvas
            * to draw the first image on it
            * note that X coordinate is not zero 
            .graphics.drawimage(oImage, -.imgheight, 0)
        SELECT cs
    PROCEDURE CreateMatrix
        oMatrix = CREATEOBJECT("gdimatrix")
    PROCEDURE CreateFonts
        LOCAL oFontcollection As gdifontcollection
        oFontcollection = CREATEOBJECT("gdifontcollection")
        LOCAL oFamily as gdifontfamily
        oFamily = oFontcollection.GetFontFamily(BARCODE_FONT)
        IF EMPTY(oFamily.familyname)
        * barcode font not found, default font used
            oFamily = oFontcollection.GetFontFamily(_screen.FontName)
            oFont1 = CREATEOBJECT("gdifont", oFamily,;
                14, 1, BARCODE_FORECOLOR)
            = MESSAGEBOX("Barcode font [" + BARCODE_FONT +;
                "] not found on the local computer.     " + CHR(13) +;
                "The " + _screen.FontName + " font is used instead.     ",;
                64, "Font not found")
            oFont1 = CREATEOBJECT("gdifont", oFamily,;
                28, 0, BARCODE_FORECOLOR)
        oFamily = oFontcollection.GetFontFamily(IMAGE_FONT)
        oFont2 = CREATEOBJECT("gdifont", oFamily,;
            8, 0, IMAGE_FORECOLOR)
        oFamily = oFontcollection.GetFontFamily(IMAGE_FONT)
        oFont3 = CREATEOBJECT("gdifont", oFamily,;
            7, 0, IMAGE_FORECOLOR)
    PROCEDURE GenerateData
        CREATE CURSOR cs (firstname C(20), lastname C(30), city C(50),;
            state C(2), zip C(7), mailtype C(50))
        * preparing test data
        * these are entirely fictional names and addresses
        * any coincidence is completely unintentional
        * the mailtypes do not make any sense either
            "12545", "First Class Mail and Periodicals")
            "01331", "Standard Mail ")
            "06783", "First Class Mail and Periodicals")
            "11106", "First Class Mail and Periodicals")
            "10306", "Standard Mail ")
            "01524", "Standard Letters")
            "32906", "Standard Letters")
        * adding two GENERAL fields for storing images
        ALTER TABLE cs ADD COLUMN barcode G  && regular
        ALTER TABLE cs ADD COLUMN barcode1 G  && rotated
        SELECT cs
        SCAN ALL
            DO GenBarcode WITH;
                ALLTRIM(, cs.mailtype
    PROCEDURE BrowseResults
        DEFINE WINDOW cs FROM 1,1 TO 14,114 IN SCREEN;
        SYSTEM FONT "Arial", 8 FLOAT CLOSE
        DEFINE WINDOW barcode FROM 15,1 TO 25,30 IN SCREEN;
        DEFINE WINDOW barcode1 FROM 15,40 TO 35,50 IN SCREEN;
        SELECT cs
        GO TOP
        MODIFY GENERAL barcode WINDOW barcode NOWAIT
        MODIFY GENERAL barcode1 WINDOW barcode1 NOWAIT
        BROWSE FIELDS firstname:16, lastname:16,;
            city:25, state:8, zip:12, mailtype:30,;
            barcode, barcode1;

    User rating: 0/10 (0 votes)
    Rate this code sample:
    • ~
    5230 bytes  
    Created: 2006-03-10 14:26:26  
    Modified: 2009-12-17 09:45:06  
    Visits in 7 days: 48  
    Listed functions:
    Printer friendly API declarations
    My comment:
    This is VFP8 solution. It works quite slow, mainly because of multiple bitmap files imported into general fields. Some ways can be found to optimize the speed, still it is rather lenghy process -- about 25..50 seconds per 100 APPEND GENERAL calls.

    As shown in the second version of this code sample, in VFP9 the ReportListener used with GDI+ library speeds up the process very much due to the images directly rendered in report without going through file and general field stages.

    * * *
    This is how GDI+ rotates images:

    Word Index links for this example:
    Translate this page:
      Spanish    Portuguese    German    French    Italian offers instant, free translations of text or web pages.
    User Contributed Notes:
    There are no notes on this subject.

    Copyright © 2001-2018 News2News, Inc. Before reproducing or distributing any data from this site please ask for an approval from its owner. Unless otherwise specified, this page is for your personal and non-commercial use. The information on this page is presented AS IS, meaning that you may use it at your own risk. Microsoft Visual FoxPro and Windows are trade marks of Microsoft Corp. All other trademarks are the property of their respective owners. 

    Privacy policy
    Credits: PHP (4.4.9), an HTML-embedded scripting language, MySQL (5.6.39), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
    Last Topics Visited (
    19 sec.Function: 'BlockInput'
    38 sec.Function: 'GdipCreateBitmapFromGdiDib'
    1 min.Function: 'GetHandleInformation'
    1.33 min.Function: 'StrFormatByteSize'
    1.72 min.Function: 'OemToChar'
    2.1 min.Function: 'GdipGetImageVerticalResolution'
    2.52 min.Function: 'GetVersionEx'
    2.88 min.Function: 'DrawDibDraw'
    3.32 min.Function: 'GetEnvironmentVariable'
    3.72 min.Function: 'SQLGetFunctions'
    Advertise here!