Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
An alternative way of setting Form.Closable to False
DiskFreeSpace class
GDI+: reading and writing metadata in JPEG and TIFF files
GDI+: Using Scale and Shear transformations
Hiding mouse cursor
How to display the Print property sheet
How to find when the application started
Obtaining the bounding rectangle for the specified device context
Reading and setting explicit Application User Model ID for the current process (Win7)
Retrieving System Error message strings
Saving available locale records into a cursor
Winsock: initializing the service in the VFP application
GDI+: converting text strings to images and saving in a graphics file
Retrieving configuration information for the specified server (Win98/Me)
Simulating DOEVENTS
Using Custom FTP class (DEFINE CLASS ftp As Custom)
Using the MessageBox Win32 function
Using the Semaphore object
Who owns the Windows Clipboard
GDI+: rotating images using matrix transformations
Retrieving the IP-to-physical address mapping table
Using shared memory to exchange data between two FoxPro applications
Winsock: how to retrieve a service information corresponding to a service name
Current System information
Accessing examples contained in this reference from a VFP application

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:
With this code you can reach the list of examples on this reference from your VFP application through HTTP connection.


Downloadable code samples are available for registered annual subscribers.

Try similar example Accessing examples contained in this reference through Web Services (requires VFP8).

* * *
See also:

  • ApiViewer for Visual FoxPro



  •  
    PUBLIC objForm
    objForm = CreateObject("Tform")
    objForm.Visible = .T.
    * end of main
     
    DEFINE CLASS Tform As Form
    #DEFINE ccBaseAddr "http://www.news2news.com/vfp/"
    #DEFINE ccCgiAddr  "http://www.news2news.com/cgi-bin/w32query.php?quser=guest&"
        Caption=" VFP code samples on " + ccBaseAddr
        Width=760
        Height=500
        Autocenter=.T.
        ShowTips=.T.
        csList="cs" + SUBSTR(SYS(2015),3,10)
     
        ADD OBJECT pframe As Tframe WITH Left=6, Top=5, Width=748, Height=440
        ADD OBJECT lblUrl As Label WITH Left=12, Top=460, Autosize=.T.,;
            ForeColor=Rgb(0,0,192), FontUnderline=.T.,;
            TooltipText="Click to open"
     
    PROCEDURE Init
        DECLARE INTEGER ShellExecute IN shell32;
            INTEGER, STRING, STRING, STRING, STRING, INTEGER
        DECLARE INTEGER URLDownloadToCacheFile IN urlmon;
            INTEGER lpUnkcaller, STRING szURL, STRING @szFileName,;
            INTEGER dwBufLength, INTEGER dwReserved, INTEGER pBSC
        THIS.pframe.Resize
        THIS.PopulateList
     
    PROCEDURE Destroy
        THIS.pframe.pgList.lst.RowsourceType = 0
        IF USED(THIS.csList)
            USE IN (THIS.csList)
        ENDIF
     
    procedure resize
    * Thanks Bruce :)
        with this
            stor .Width - 12 to .pframe.Width
            stor .Height - 60 to .pframe.Height    
            stor .Height - 40 to .lblUrl.Top
        endWith
     
    PROCEDURE pframe.pgList.lst.InteractiveChange
        ThisForm.lblUrl.Caption = ThisForm.GetUrl()
     
    PROCEDURE lblUrl.MouseDown
    LPARAMETERS nButton, nShift, nXCoord, nYCoord
        = ShellExecute(0, "open", ThisForm.GetUrl(), "", "", 3)
     
    PROCEDURE pframe.pgExample.Activate
        ThisForm.DisplayExample
     
    PROCEDURE pframe.pglist.lst.DblClick
        ThisForm.pframe.ActivePage = 2
     
    FUNCTION GetUrl
    RETURN ccBaseAddr + "?example=" + ALLT(THIS.pframe.pgList.lst.Value)
     
    PROCEDURE PopulateList
        LOCAL cRequest, cTargetFile
        cRequest = ccCgiAddr + "qtarget=examples&qmode=list"
        cTargetFile = THIS.RemoteToLocal(cRequest)
     
        IF Not EMPTY(cTargetFile)
            CREATE CURSOR (THIS.csList) (id N(5), name C(200))
            APPEND FROM (cTargetFile) TYPE DELIM WITH ,
            WITH THIS.pframe.pgList.lst
                .RowsourceType = 2
                .Rowsource = THIS.csList
                .ColumnWidths="40,500"
                IF .listCount > 0
                    .listIndex = 1
                ENDIF
                .InteractiveChange
            ENDWITH
        ENDIF
     
    PROCEDURE DisplayExample
        LOCAL cRequest, cTargetFile
        cRequest = ccCgiAddr + "qtarget=examples&qmode=source&qindex=" +;
            ALLTRIM(ThisForm.pframe.pgList.lst.Value)
        cTargetFile = THIS.RemoteToLocal(cRequest)
     
        IF Not EMPTY(cTargetFile)
            WITH ThisForm.pframe.pgExample.txtSource
                .Value = FILETOSTR(cTargetFile)
                .Refresh
            ENDWITH
        ENDIF
     
    FUNCTION RemoteToLocal(cRequest)
        LOCAL nResult, cTargetFile
        cTargetFile = Repli(Chr(0), 250)
        WAIT WINDOW NOWAIT "Downloading remote file..."
        nResult = URLDownloadToCacheFile(0, cRequest, @cTargetFile,;
            Len(cTargetFile), 0,0)
        WAIT CLEAR
        DOEVENTS
    RETURN STRTRAN(cTargetFile, Chr(0), "")
    ENDDEFINE
     
    DEFINE CLASS Tframe As PageFrame
        ADD OBJECT pgList As TpageList WITH Caption="List of examples"
        ADD OBJECT pgExample As TpageExample WITH Caption="Source Code"
     
    PROCEDURE Resize
        WITH THIS.pgList
            .lst.Width = THIS.Width - 14
            .lst.Height = THIS.height - .lst.Top - 50
        ENDWITH
        WITH THIS.pgExample
            .txtSource.Width = THIS.Width - 14
            .txtSource.Height = THIS.height - .txtSource.Top - 50
        ENDWITH
    ENDDEFINE
     
    DEFINE CLASS TpageList As Page  && Page object
        ADD OBJECT lst As ListBox WITH Left=5, Top=5, FontName="Arial",;
            FontSize=10, ColumnCount=2, BoundColumn=1
    ENDDEFINE
     
    DEFINE CLASS TpageExample As Page  && Page object
        ADD OBJECT txtSource As EditBox WITH Left=5, Top=5,;
            FontName="Courier New", FontSize=9, ForeColor = RGB(0,96,128)
    ENDDEFINE
     
     
     

    User rating: 0/10 (0 votes)
    Rate this code sample:
    • ~
    3645 bytes  
    Created: 2001-11-28 18:21:41  
    Modified: 2011-12-10 09:20:22  
    Visits in 7 days: 104  
    Listed functions:
    ShellExecute
    URLDownloadToCacheFile
    Printer friendly API declarations
    My comment:
    This is how the interaction between VFP and remote data works (almost a Web service :). The VFP code sends a request to a remote script. Two request types are supported:

    - list of examples
    - the source code of a particular example (membership is required)


    The remote script retrieves data from a database and sends it back. Finally the VFP code converts received data to a local ASCII file.

    P.S. Sometimes you need to clear your local Internet cache to view the latest changes.
    Word Index links for this example:
    Translate this page:
      Spanish    Portuguese    German    French    Italian  
    FreeTranslation.com offers instant, free translations of text or web pages.
    User Contributed Notes:
    There are no notes on this subject.


    Copyright © 2001-2013 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.1.55-log), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
    Last Topics Visited (107.21.186.38)
    4 sec.Example: 'Confining Windows calculator inside the VFP main window'
    13.3 min.Function: 'CeRegDeleteValue'
    13.33 min.Example: 'Printing Image File, programmatically set print page orientation to landscape'
    3.25 hrs.Example: 'How to print a bitmap file'
     Function: 'JetRollback'
    Function group: 'Extensible Storage Engine (ESE, Jet Blue)'
    9.43 hrs.Example: 'Retrieving window and menu help context identifiers'
     Example: 'Using File Mapping for enumerating files opened by Visual FoxPro'
    12.71 hrs.Example: 'Writing to INI file'
     Function: 'RegDeleteValue'
     Example: 'Peer-to-peer LAN messenger built with Mailslot API functions'
    Google
    Advertise here!