Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Building a tree of subdirectories for a given path using FindFile functions
Current System information
How to test file attributes (key method for FileExists and DirectoryExists routines)
Winsock: how to retrieve a service information corresponding to a service name
GDI+: Storing DLL icon resources in image files
Drawing a window caption using the DrawCaption routine
GDI+: converting image file to another graphics format
Saving HKEY_LOCAL_MACHINE\\Software\\ODBC Registry Entries to an XML file
Using Shell for performing operations on files
Who is the first in viewing the Clipboard
How to retrieve version information for the specified file
Retrieving a handle to DLL and address of an exported function in it
Retrieving list of files on the FTP directory
Simple MAPI: how to resolve a name to unique address list entry
Starting a dialog box for connecting to network resources and passing input parameters
How to enumerate terminal servers within the specified Windows domain
How to generate UUID values
Pocket PC: System Registry Viewer
Reading STARTUPINFO structure for the current VFP session
Enumerating MIDI output devices
Setting and retrieving the double-click time for the mouse
How to hot-track menu item selection in top-level form (requires VFP9)
Basic Volume information
Enumerating forms supported by a specified printer
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: 106  
    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 (50.17.109.248)
    3 sec.Example: 'Retrieving Window Class information for the VFP window'
    10 sec.Function: 'CreateWaitableTimer'
    1.4 hrs.Example: 'Reading parameters of streams in AVI file'
    2.67 hrs.Example: 'Obtaining I/O counts for the current process'
     Example: 'Displaying the drive type value'
    4.15 hrs.Example: 'Simple Window Viewer'
     Function: 'GdipCreateMatrix'
    Function group: 'GDI+ Matrix'
    4.96 hrs.Function: 'SetFocus'
    5.44 hrs.Example: 'How to run FoxPro application under different user name (impersonating user)'
     Example: 'Retrieving information about all users currently logged on to the workstation (WinNT only)'
    Google
    Advertise here!