Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
How to enumerate sessions and processes on a specified terminal server
HOWTO: Use the Win32 API to Access File Dates and Times
Retrieving local computer and user names
System and Local Time values
Attaching menu to a top-level form
How to display the port-configuration dialog box for a port on the specified server
How to find when the application started
Obtaining list of tables stored in an ODBC Data Source
Retrieving the name and type of all available RAS-capable devices
Testing if a connection to an Url can be established
Windows Shell Icons displayed and exported to ICO files (Vista)
How to retrieve adapter information for the local computer (including MAC address)
Removing FTP directory
Retrieving the User Datagram Protocol (UDP) listener table
Using custom Simple MapiSendMail class
Retrieving information about the main VFP window
Using NetWkstaTransportEnum to obtain MAC Address of remote server
Accessing LSA Policy object (Local Security Authority)
GDI+ fun: roach-infested desktop
How to retrieve number of objects in the Recycle Bin
How to view icons stored in executable files (Icon Viewer)
Setting the date and time that a file was created
How to make the caption of a VFP application flashing in the Windows task bar
How to retrieve list of system DSNs (Data Source Name) with parameters
Accessing examples contained in this reference through Web Services

User rating: 7/10 (3 votes)
Rate this code sample:
  • ~
More code examples    Listed functions    Add comment     W32 Constants      Translate this page Printer friendly version of this code sample
Versions:
click to open
Before you begin:
Get WSDL and description of exposed functions in this article.
Use at least VFP8 to test this example.



See also:
  • ApiViewer for Visual FoxPro

  •  
    PUBLIC objForm
    objForm = CreateObject("Tform")
    IF VARTYPE(objForm)="O"
        objForm.Visible = .T.
    ENDIF
    * end of main
     
    DEFINE CLASS Tform As Form
    #DEFINE ccBaseAddr "http://www.news2news.com/vfp/"
    #DEFINE ccWSDL  "http://www.news2news.com/cgi-bin/w32/services/ws.php?wsdl"
    #DEFINE ccUsrname "guest"
    #DEFINE ccPwd ""
        Caption=" VFP code samples on " + ccBaseAddr
        Width=760
        Height=500
        MaxButton=.F.
        MinButton=.F.
        Autocenter=.T.
        ShowTips=.T.
        csList="cs" + SUBSTR(SYS(2015),3,10)
        ws=0
     
        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
        LOCAL ex As Exception, lError
        lError=.F.
        TRY
            THIS.ws = CREATEOBJECT("mssoap.soapclient")
            THIS.ws.mssoapinit(ccWSDL)
        CATCH TO ex
            THIS.ws_error(ex, "Could not initialize SOAP Client.")
            lError=.T.
        ENDTRY
     
        IF m.lError
            RETURN .F.
        ENDIF
     
        DECLARE INTEGER ShellExecute IN shell32;
            INTEGER, STRING, STRING, STRING, STRING, INTEGER
        THIS.pframe.Resize
        THIS.PopulateList
     
    PROTECTED PROCEDURE ws_error(ex, cCaption)
        = MESSAGEBOX(TRANSFORM(ex.ErrorNo) + ". " +;
            ex.Message + "     " + CHR(13) + CHR(13) +;
            "detail: " + TRANSFORM(THIS.ws.detail) + "     " + CHR(13)+CHR(13) +;
            "faultfactor: " + TRANSFORM(THIS.ws.faultactor) + "     " + CHR(13) +;
            "faultcode: " + TRANSFORM(THIS.ws.faultcode) + "     " + CHR(13) +;
            "faultstring: " + TRANSFORM(THIS.ws.faultstring) + "     ",;
            48, m.cCaption)
     
    PROCEDURE Destroy
        THIS.ws=Null
        THIS.pframe.pgList.lst.RowsourceType = 0
        IF USED(THIS.csList)
            USE IN (THIS.csList)
        ENDIF
     
    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 cResult, ex As Exception
        TRY
            WAIT WINDOW NOWAIT "Retrieving list of examples..."
            cResult = THIS.ws.GetListOfExamples()
            XMLTOCURSOR(m.cResult, THIS.csList, 0)
        CATCH TO ex
            cResult=""
            THIS.ws_error(ex, "SOAP error")
        FINALLY
            WAIT CLEAR
        ENDTRY
        IF USED(THIS.csList)
            WITH THIS.pframe.pgList.lst
                .RowsourceType = 2
                .Rowsource = THIS.csList
                .ColumnWidths="60,700"
                IF .listCount > 0
                    .listIndex = 1
                ENDIF
                .InteractiveChange
            ENDWITH
        ENDIF
     
    PROCEDURE DisplayExample
        LOCAL nId, cResult, ex As Exception
        nId = VAL(ThisForm.pframe.pgList.lst.Value)
        TRY
            WAIT WINDOW NOWAIT "Retrieving requested example..."
            cResult = THIS.ws.GetExample(nId, ccUsrname, ccPwd)
            XMLTOCURSOR(m.cResult, "csExample", 0)
        CATCH TO ex
            cResult=""
            THIS.ws_error(ex, "SOAP error")
        FINALLY
            WAIT CLEAR
        ENDTRY
        IF USED("csExample")
            WITH ThisForm.pframe.pgExample.txtSource
                .Value = csExample.body
                .Refresh
            ENDWITH
            USE IN csExample
        ENDIF
    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: 7/10 (3 votes)
    Rate this code sample:
    • ~
    4021 bytes  
    Created: 2004-09-17 08:30:10  
    Modified: 2010-09-11 14:56:53  
    Visits in 7 days: 71  
    Listed functions:
    ShellExecute
    Printer friendly API declarations
    My comment:
    C# version of this code sample. Click on the image below to download VS2008 C# project.

    Download VS2008 project

    VB.Net version of this code sample.



    Start new Windows Application project. Place on the form TabControl, ListBox, TextBox and LinkLabel controls.

    Add to the project new Web Reference pointing at http://www.news2news.com/vfp/wsdl/webservices.WSDL.
    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 (54.235.20.17)
    4 sec.Function: 'GetWindowLong'
    6.05 hrs.Function: 'JetCommitTransaction'
    Function group: 'Extensible Storage Engine (ESE, Jet Blue)'
     Example: 'GDI+: printing image file'
    10.03 hrs.Example: 'Copying picture of the active form to the Clipboard using Enhanced Metafile API functions'
    12.71 hrs.Example: 'Adding supplementary data to AVI files'
     Function: 'GetWindow'
     Example: 'Using the ChooseColor function'
    13.99 hrs.Example: 'Winsock: resolving an address to a host name'
     Example: 'Storing screen shot of a form to bitmap file'
    18.27 hrs.Example: 'Pocket PC: Folder Viewer'
    Google
    Advertise here!