Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Printing text with the Escape function
Detecting changes in connections to removable drives (VFP9)
Adding a background image to VFP report (VFP9, ReportListener)
Enumerating Processes -- WinNT
How to control Adobe Reader 9.0 (SDI mode) from VFP application
How to print a bitmap file
Switching between keyboard layouts
How to put a horizontal text scrolling on the form (a news line, marquee)
Generating random cryptographic keys
Custom HttpRequest class (WinHTTP)
How to enumerate sessions and processes on a specified terminal server
How to suspend or hibernate your system
Enumerating Processes -- Win9*
GDI+: creating a gradient
Creating a console window for Visual FoxPro application
Listing child windows for the Windows desktop
Placing an arbitrary rectangular area of main VFP window on the Clipboard
How to view system icons for the classes installed on the local machine
Enumerating raw input devices attached to the system (keyboard, mouse, human interface device)
How to print FoxPro form
Downloading files from the FTP server using InternetReadFile
How to display advanced Task Dialog (Vista)
How to print picture stored in enhanced-format metafile (*.emf)
Compressing and decompressing files with Windows API Runtime Library routines
GDI+: creating a gradient

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.
DO declare

PRIVATE gdiplus as gdiplusinit
gdiplus = CREATEOBJECT("gdiplusinit")

LOCAL oBitmap as gdibitmap
cFilename = "gradientsample.png"
nImgWidth = 300
nImgHeight = 300

oBitmap = CREATEOBJECT("gdibitmap",;
    nImgWidth, nImgHeight)

WITH oBitmap
            ARGB(255,255,255, 255),;

nPointCount = 128
nRadius = 120
cPoints = GeneratesCirclePoints(;

hBrush = 0
    @cPoints, nPointCount, 4, @hBrush)

IF hBrush <> 0
    nColor1 = ARGB(0,156,0, 255)
    nColor2 = ARGB(230,255,230, 64)

    GdipSetPathGradientCenterColor(hBrush, nColor1)

    cColors = num2dword(nColor2)
    nColorCount = 1
        hBrush, @cColors, @nColorCount)

    cPoints = num2dword(130) +;

        hBrush, @cPoints)

    GdipFillRectangle(;, hBrush,;
        0, 0, nImgWidth, nImgHeight)


ShellExecute(0, "open", cFilename, "", "", 3)

* end of main

PROCEDURE GeneratesCirclePoints(;
    nAxisX, nAxisY, nRadius, nPointCount)
* generates a series of points forming a circle
    LOCAL nStep, nAngle, cResult
    nStep = (2 * PI()) / nPointCount

    cResult = ""
    FOR nAngle = 0 TO (2 * PI()) STEP nStep
        cResult = cResult +;
            num2dword(nAxisX + nRadius * COS(nAngle)) +;
            num2dword(nAxisY + nRadius * SIN(nAngle))
RETURN cResult

    DECLARE INTEGER ShellExecute IN shell32; 
        INTEGER hWindow, STRING lpOperation,; 
        STRING lpFile, STRING lpParameters,;  
        STRING lpDirectory, INTEGER nShowCmd

    DECLARE INTEGER GdipCreatePathGradientI IN gdiplus;
        STRING @points, INTEGER pointcount,;
        INTEGER wrapMode, INTEGER @polyGradient

    DECLARE INTEGER GdipSetPathGradientCenterColor IN gdiplus;
        INTEGER brush, INTEGER colors

    DECLARE INTEGER GdipSetPathGradientSurroundColorsWithCount;
    IN gdiplus;
        INTEGER brush, STRING @argbColor, INTEGER @colorcount

    DECLARE INTEGER GdipSetPathGradientCenterPointI IN gdiplus;
        INTEGER brush, STRING @points

    DECLARE INTEGER GdipGetPathGradientCenterPointI IN gdiplus;
        INTEGER brush, STRING @points

FUNCTION num2dword(lnValue)
#DEFINE m0 0x0000100
#DEFINE m1 0x0010000
#DEFINE m2 0x1000000
    IF lnValue < 0
        lnValue = 0x100000000 + lnValue
    LOCAL b0, b1, b2, b3
    b3 = Int(lnValue/m2)
    b2 = Int((lnValue - b3*m2)/m1)
    b1 = Int((lnValue - b3*m2 - b2*m1)/m0)
    b0 = Mod(lnValue, m0)
RETURN Chr(b0)+Chr(b1)+Chr(b2)+Chr(b3)

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
2754 bytes  
Created: 2013-12-02 11:44:22  
Modified: 2013-12-02 11:56:34  
Visits in 7 days: 147  
Listed functions:
Printer friendly API declarations
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 (
20 sec.Examples
40 sec.Function: 'SQLGetEnvAttr'
Function group: 'ODBC API'
58 sec.Login
1.28 min.Function: 'AVIFileInit'
Function group: 'Windows Multimedia'
1.6 min.Example: 'Printing Image File, programmatically set print page orientation to landscape'
1.88 min.Function: 'FtpPutFile'
Function group: 'Internet Functions (WinInet)'
2.15 min.Example: 'Using WM_COPYDATA for interprocess communication (VFP9)'
Language: 'C#'
2.45 min.Example: 'How to change display settings: screen resolution, screen refresh rate'
Language: 'C++'
2.82 min.Function: 'CeFindAllFiles'
Function group: 'Remote Application Programming (RAPI)'
3.12 min.Function: 'inet_ntoa'
Advertise here!