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
Capturing keyboard activity of another application with the Raw Input API (VFP9)
Mapping and disconnecting network drives
Winsock: retrieving directory listing from an FTP server using passive data connection (FTP, port 21)
Winsock: sending email messages (SMTP, port 25)
How to display the Properties dialog box for a file (ShellExecuteEx)
Disk in drive A:
Detecting changes in connections to removable drives (VFP9)
Enumerating raw input devices attached to the system (keyboard, mouse, human interface device)
How to download a file from the FTP server using FtpGetFile
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
Using EnumPrinters function to enumerate locally installed printers
Running MSDOS Shell as a child process with redirected input and output (smarter RUN command)
Splash Screen for the VFP application
Creating irregularly shaped FoxPro form using transparency color key
Subclassing CommandButton control to create BackColor property
Vertical Label control
Converting Unicode data from the Clipboard to a character string using a given code page
Enumerating network resources
Creating a console window for Visual FoxPro application
Converting Unicode data from the Clipboard to a character string using a given code page

User rating: 10/10 (1 votes)
Rate this code sample:
  • ~
More code examples    Listed functions    Add comment     W32 Constants      Translate this page Printer friendly version of this code sample
 
#DEFINE CF_UNICODETEXT  13
DO decl
 
LOCAL hData, lcUnicode
 
IF OpenClipboard(0) <> 0
    IF IsClipboardFormatAvailable(CF_UNICODETEXT) <> 0
        hData = GetClipboardData (CF_UNICODETEXT)
        lcUnicode = memwchar2str(hData)
*        ? uconv (lcUnicode,  866)  && code page  866
        ? uconv (lcUnicode, 1251)  && code page 1251
    ELSE
        ? "No Unicode data available."
    ENDIF
    = CloseClipboard()  && the must
ENDIF
* end of main
 
FUNCTION uconv (lcSrc, lnCodePage)
    LOCAL lcDst, lnUsedDefault, lnResult
    lcDst = Repli(Chr(0), Len(lcSrc) * 2)
    lnUsedDefault = 0
 
    lnResult = WideCharToMultiByte (lnCodePage, 0,;
        lcSrc, Len(lcSrc),;
        @lcDst, Len(lcDst), "?", 0)
 
    IF lnResult = 0
    *   87 - ERROR_INVALID_PARAMETER
    *  122 - ERROR_INSUFFICIENT_BUFFER
    * 1004 - ERROR_INVALID_FLAGS
        ? "Error code:", GetLastError()
        lcDst = ""
    ELSE
        lcDst = SUBSTR(lcDst, 1, lnResult)
    ENDIF
RETURN SUBSTR(lcDst, 1, AT(Chr(0),lcDst)-1)
 
FUNCTION  memwchar2str (lnMemBlock)
* copies Unicode characters (two-byte) from a memory address to a VFP string
RETURN  mem2str(lnMemBlock, Chr(0)+Chr(0))
 
FUNCTION  mem2str(lnMemBlock, end_sequence)
#DEFINE BUFFER_SIZE   16
#DEFINE EMPTY_BUFFER  Repli(Chr(0), BUFFER_SIZE)
 
    DECLARE RtlMoveMemory IN kernel32 As Heap2Str;
        STRING @, INTEGER, INTEGER
 
    LOCAL lnPtr, lcResult, lcBuffer, lnPos
    lnPtr = lnMemBlock
    lcResult = ""
 
    DO WHILE .T.
        lcBuffer = EMPTY_BUFFER
        = Heap2Str (@lcBuffer, lnPtr, BUFFER_SIZE)
        lnPos = AT(end_sequence, lcBuffer)
        IF lnPos > 0
            lcResult = lcResult + SUBSTR(lcBuffer, 1, lnPos-1)
            RETURN  lcResult
        ELSE
            lcResult = lcResult + lcBuffer
            lnPtr = lnPtr + BUFFER_SIZE
        ENDIF
    ENDDO
 
PROCEDURE decl
    DECLARE INTEGER GetLastError IN kernel32
    DECLARE INTEGER OpenClipboard IN user32 INTEGER hwnd
    DECLARE INTEGER CloseClipboard IN user32
    DECLARE INTEGER GetClipboardData IN user32 INTEGER uFormat
    DECLARE INTEGER IsClipboardFormatAvailable IN user32 INTEGER wFormat
 
    DECLARE INTEGER WideCharToMultiByte IN kernel32;
        INTEGER CodePage, INTEGER dwFlags, STRING lpWideCharStr,;
        INTEGER cchWideChar, STRING @lpMultiByteStr, INTEGER cbMultiByte,;
        STRING lpDefaultChar, INTEGER lpUsedDefaultChar
 
 

User rating: 10/10 (1 votes)
Rate this code sample:
  • ~
2223 bytes  
Created: 2002-07-10 15:56:18  
Modified: 2002-07-10 15:57:07  
Visits in 7 days: 211  
Listed functions:
CloseClipboard
GetClipboardData
GetLastError
IsClipboardFormatAvailable
OpenClipboard
WideCharToMultiByte
Printer friendly API declarations
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)
7 sec.Example: 'Splash Screen for the VFP application'
42.85 min.Function: 'DeleteMenu'
Function group: 'Menu'
3.78 hrs.Example: 'How to change display settings: screen resolution, screen refresh rate'
Language: 'C++'
 
Function group: 'GDI+ StringFormat'
 Function: 'AVIStreamGetFrameClose'
Function group: 'Windows Multimedia'
5.87 hrs.Example: 'How to view icons stored in executable files (Icon Viewer) - II'
17.77 hrs.Example: 'How to block the PrintScreen key'
 Example: 'The SQLGetProp() creates a bridge between Visual FoxPro and the ODBC API'
20.25 hrs.Example: 'Printing Image File, programmatically set print page orientation to landscape'
 Example: 'How to change the name and the size of the font in the MessageBox dialog'
Google
Advertise here!