Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
How to change display settings: screen resolution, screen refresh rate
Enumerating data formats currently available on the clipboard
Custom GDI+ class
Mapping and disconnecting network drives
Winsock: sending email messages (SMTP, port 25)
Capturing keyboard activity of another application with the Raw Input API (VFP9)
Winsock: retrieving directory listing from an FTP server using passive data connection (FTP, port 21)
Converting Unicode data from the Clipboard to a character string using a given code page
Enumerating raw input devices attached to the system (keyboard, mouse, human interface device)
How to display the Properties dialog box for a file (ShellExecuteEx)
Disk in drive A:
Enumerating network resources
Detecting changes in connections to removable drives (VFP9)
How to download a file from the FTP server using FtpGetFile
Splash Screen for the VFP application
Using EnumPrinters function to enumerate locally installed printers
Using Font and Text functions
How to play AVI file on the _screen
Using Video Capture: displaying on FoxPro form frames and previewing video obtained from a digital camera
Retrieving the name of the network resource associated with a local device
Running MSDOS Shell as a child process with redirected input and output (smarter RUN command)
Creating a console window for Visual FoxPro application
Creating irregularly shaped FoxPro form using transparency color key
How to put a horizontal text scrolling on the form (a news line)
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: 80  
    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.226.5.29)
    4 sec.Function: 'DeleteFileTransacted'
    Function group: 'File Management'
    7.36 hrs.Example: 'GetFocus returns a HWND value'
     Example: 'Testing serial ports'
    15.13 hrs.Example: 'URL: splitting into its component parts'
     Function: 'GetFileSizeEx'
    18.99 hrs.Gallery
    19 hrs.Example: 'How to prevent users from accessing the Windows Desktop and from switching to other applications'
    19.79 hrs.Function: 'FormatMessage'
    Function group: 'Error Handling'
     
    Function group: 'Kernel Transaction Manager'
     Example: 'How to convert a bitmap file to monochrome format (1 bpp)'
    Google
    Advertise here!