Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Retrieving information about all users currently logged on to the workstation (WinNT only)
Using an Event Object. Part B: running an application responding to events
Using the high-resolution performance counter
Reading and setting explicit Application User Model ID for the current process (Win7)
Reading current hardware profile
Reading Internet Query options
Using MessageBeep
GDI+: loading image file, drawing on it, saving the result to another file
Initiating Inet connection using a modem
Scanning a hierarchy of child windows down from the Windows Desktop
URL: converting unsafe characters and spaces into escape sequences
Copying files as a transacted operation (Vista)
Dial the Net Automatically
Pocket PC: retrieving data from the Contacts Database
Removing FTP directory
Retrieving the name of the network resource associated with a local device
Saving available locale records into a cursor
Using Multimedia Command Strings to play MIDI files
Using the FindMediaType function
Winsock: retrieving information from a host database for a given host name
Using GetSysColor
Converting long file names to the short format and vice versa
How to retrieve information about a cache entry (Internet Explorer)
Memory usage info for current VFP session (WinNT only)
Printf-style formatted text output in VFP

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 wnsprintf function is similar to the printf function from the C language, also with variable number of input parameters, though some limited. It does not support floating point or pointer types.
 
? printf("Width=%d, Height=%4d, Alignment=%s", 100, 200, "Center")
 
PROCEDURE  printf (lcSource, p0, p1, p2, p3, p4, p5, p6, p7,;
    p8,p9,p10,p11,p12,p13,p14,p15)
* VFP Help: A maximum of 27 parameters can be passed
* from a calling program
 
    LOCAL lnIndex, lcDecl, lvValue, lcType, lcDecl,;
        lnResult, lcTarget
 
    lcDecl = ""
    FOR lnIndex=0 TO 15
        IF lnIndex <= PARAMETERS()-2
            lvValue = EVAL("p" + LTRIM(STR(lnIndex)))
            lcType = TYPE("lvValue")
 
            DO CASE
            CASE lcType = "C"
                lcDecl = lcDecl + ", STRING"
            CASE lcType = "N"
                lcDecl = lcDecl + ", INTEGER"
            ENDCASE
        ELSE
            lcDecl = lcDecl + ", INTEGER"
        ENDIF
 
    ENDFOR
 
    * every time this function has to be redeclared
    * according to the parameters passed to it
 
    lcDecl = "DECLARE INTEGER wnsprintf IN Shlwapi " +;
        "STRING @lpOut, INTEGER cchLimitIn, STRING pszFmt" +;
        lcDecl
 
    &lcDecl
 
    lcTarget = Space(4096)
    lnResult = wnsprintf (@lcTarget, Len(lcTarget), lcSource,;
        p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15)
RETURN  Left(lcTarget, lnResult)
 
 

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
1079 bytes  
Created: 2002-01-18 20:01:38  
Modified: 2002-01-18 20:27:35  
Visits in 7 days: 107  
Listed functions:
wnsprintf
Printer friendly API declarations
My comment:
This is quite unusual situation for a Win32 function requiring a variable number of parameters. So is the approach to declare the wnsprintf function through a macro substitution.

Valid % specifiers (quite possible there could be some more)
  • %d, %i - integer
  • %u - unsigned decimal
  • %s - string
  • %x, %X - unsigned hex value
This function does not support the %o option (unsigned octal value), that is strange.
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 (184.73.7.143)
6 sec.Example: 'Reading and setting the priority class values for the current process and thread'
9 sec.Example: 'Using Video Capture: enumerating installed capture drivers'
26.38 min.Function: 'AVIStreamInfo'
Function group: 'Windows Multimedia'
26.43 min.Function: 'PostMessage'
26.48 min.Example: 'How to put a horizontal text scrolling on the form (a news line)'
1.66 hrs.Example: 'Enumerating the subkeys for a given registry key'
 Function: 'SetPriorityClass'
1.99 hrs.Example: 'Custom FTP Class for Visual FoxPro application'
 Example: 'Subclassing CommandButton control to create BackColor property'
 Example: 'Enumerating printer drivers installed'
Google
Advertise here!