Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Detecting changes in connections to removable drives (VFP9)
Enumerating devices installed on the local machine
Vertical Label control
How to ping a remote site using IP Helper API calls
A class that encrypts and decrypts files using Cryptography API Functions
Custom HttpRequest class (WinHTTP)
Switching between keyboard layouts
Drawing icons associated with the VFP main window
System Image List Viewer
Testing serial ports
Creating a clipping region from the path selected into the device context of a form
How to make a VFP form fading out when released (GDI version)
How to load a user profile
Disconnecting USB Mass Storage Device programmatically
How to enable the SE_SHUTDOWN_NAME privilege for the application
How to make application automatically close all documents it opened
Reading the structure of VFP main menu
Winsock: retrieving the standard host name and IP address for the local machine
Customizing the frame of top-level form: removing the standard frame (VFP9, Vista)
Displaying hypertext links with the SysLink control (VFP9, Comctl32.dll)
GDI+ fun: roach-infested desktop
Loading a string resource from an executable file
Reading and setting explicit Application User Model ID for the current process (Win7)
How to prevent users from accessing the Windows Desktop and from switching to other applications
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: 123  
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-2017 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.38), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
Last Topics Visited (
18 sec.Example: 'Detecting changes in connections to removable drives (VFP9)'
37 sec.Example: 'Sending email messages with Simple MAPI'
54 sec.
1.23 min.Function: 'waveOutUnprepareHeader'
Function group: 'Windows Multimedia'
1.53 min.Function: 'waveOutGetPosition'
Function group: 'Windows Multimedia'
1.88 min.Function: 'FindClosePrinterChangeNotification'
Function group: 'Printing and Print Spooler'
2.2 min.Updates
2.58 min.
Function group: 'System Information'
3.07 min.Function: 'GetNumberOfPhysicalMonitorsFromHMONITOR'
3.5 min.Example: 'How to make a VFP form fading out when released (GDI+ version)'
Advertise here!