Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
PocketPC: creating directories and files
Reading keys in the specified section of the Win.ini file
Terminating VFP application using the FatalAppExit
Creating hash values for the list of names
Displaying the main Dial-Up Networking dialog box
Initiating Inet connection using a modem
Opening access to the Microsoft Internet functions for the application
Retrieving the System Time adjustment
Searching for the specified file using the SearchPath
How to fill a buffer with random bytes using Cryptography API Functions
How to test file attributes (key method for FileExists and DirectoryExists routines)
Enumerating connections made to a shared resource for the local computer (WinNT only)
Enumerating ODBC drivers available on the local computer
Using the CopyFile
Using the GetLogicalDriveStrings
Dynamic strings implemented through VFP Custom class
GDI+: converting text strings to images and saving in a graphics file
GDI+: Using Scale and Shear transformations
An alternative way of setting Form.Closable to False
How to intercept window messages sent to VFP form
Power capabilities of the system: battery, UPS, sleep and hibernation modes, processor throttling
Retrieving geometrical parameters of the system desktop window
Testing Transparent Menu Class with top-level form (requires VFP9)
Using the Semaphore object
Reading parameters of streams in AVI file

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:
 
#DEFINE OF_SHARE_DENY_WRITE        0x00000020
#DEFINE streamtypeVIDEO "vids"
#DEFINE streamtypeAUDIO "auds"
DO decl
 
= AVIFileInit()  && init library
 
LOCAL cFilename, hAviFile
cFilename = "c:\windows\clock.avi"
hAviFile = OpenAvi(m.cFilename)
 
IF hAviFile = 0
    ? "Error opening AVI file"
ELSE
    = GetStreamInfo(hAviFile, streamtypeAUDIO, "csAudio", 1,1,30,120)
    = GetStreamInfo(hAviFile, streamtypeVIDEO, "csVideo", 7,7,30,120)
    = AVIFileRelease(hAviFile)
ENDIF
 
= AVIFileExit()  && release library
* end of main
 
FUNCTION OpenAvi(cFilename)
    LOCAL nResult, hFile
    hFile = 0
    nResult = AVIFileOpen(@hFile, cFilename, OF_SHARE_DENY_WRITE, 0)
RETURN Iif(nResult=0, hFile, 0)
 
PROCEDURE GetStreamInfo(hFile, fccType, cs,;
    nRow1, nColumn1, nRow2, nColumn2)
 
    LOCAL hStream
    hStream = 0
 
    = AVIFileGetStream(hFile, @hStream, buf2dword(fccType), 0)
 
    IF hStream = 0
        ? "Could not open stream:", fccType
        RETURN
    ENDIF
 
*|typedef struct { 
*|    DWORD fccType;         0:4
*|    DWORD fccHandler;      4:4
*|    DWORD dwFlags;         8:4
*|    DWORD dwCaps;          12:4
*|    WORD  wPriority;       16:2
*|    WORD  wLanguage;       18:2
*|    DWORD dwScale;         20:4
*|    DWORD dwRate;          24:4
*|    DWORD dwStart;         28:4
*|    DWORD dwLength;        32:4
*|    DWORD dwInitialFrames; 36:4
*|    DWORD dwSuggBufSize;   40:4
*|    DWORD dwQuality;       44:4
*|    DWORD dwSampleSize;    48:4
*|    RECT  rcFrame;         52:16
*|    DWORD dwEditCount;     68:4
*|    DWORD dwFormatChgCnt;  72:4
*|    char  szName[64];      76:64
*|} AVISTREAMINFO; Total bytes = 140
#DEFINE AVISTREAMINFO_SIZE 140
 
    LOCAL cBuffer, nScale, nRate, nX0, nY0, nX1, nY1
 
    cBuffer = Repli(Chr(0), AVISTREAMINFO_SIZE)
    = AVIStreamInfo(hStream, @cBuffer, AVISTREAMINFO_SIZE)
 
    CREATE CURSOR (cs) (stmember C(30), stvalue C(100))
 
    _add(cs, "Stream type", SUBSTR(cBuffer, 1,4))
    _add(cs, "Compressor type", SUBSTR(cBuffer, 5,4))
    _add(cs, "AVISTREAMINFO flags", buf2dword(SUBSTR(cBuffer, 9,4)))
    _add(cs, "Capability flags", buf2dword(SUBSTR(cBuffer, 13,4)))
    _add(cs, "Priority of the stream", buf2word(SUBSTR(cBuffer, 17,2)))
    _add(cs, "Language of the stream", buf2word(SUBSTR(cBuffer, 19,4)))
 
    nScale = buf2dword(SUBSTR(cBuffer, 21,4))
    nRate = buf2dword(SUBSTR(cBuffer, 25,4))
    _add(cs, "Time scale", nScale)
    _add(cs, "Samples per second", nRate/nScale)
 
    _add(cs, "First frame sample number", buf2dword(SUBSTR(cBuffer, 29,4)))
    _add(cs, "Length of the stream", buf2dword(SUBSTR(cBuffer, 33,4)))
    _add(cs, "Audio skew", buf2dword(SUBSTR(cBuffer, 37,4)))
    _add(cs, "Suggested buffer, bytes", buf2dword(SUBSTR(cBuffer, 41,4)))
    _add(cs, "Quality indicator", buf2dword(SUBSTR(cBuffer, 45,4)))
    _add(cs, "Sample size, bytes", buf2dword(SUBSTR(cBuffer, 49,4)))
 
    nX0 = buf2dword(SUBSTR(cBuffer, 53,4))
    nY0 = buf2dword(SUBSTR(cBuffer, 57,4))
    nX1 = buf2dword(SUBSTR(cBuffer, 61,4))
    nY1 = buf2dword(SUBSTR(cBuffer, 65,4))
    _add(cs, "Destination rectangle", LTRIM(STR(nX0))+", "+;
        LTRIM(STR(nY0))+", "+LTRIM(STR(nX1))+", "+LTRIM(STR(nY1)))
 
    _add(cs, "Editing count", buf2dword(SUBSTR(cBuffer, 69,4)))
    _add(cs, "Stream description", SUBSTR(cBuffer, 77))
 
    = AVIStreamRelease(hStream)
 
    GO TOP
    BROW NORMAL NOWAIT
    PosWindow(cs, nRow1, nColumn1, nRow2, nColumn2)
 
PROCEDURE _add(cCursor, cName, vValue)
    IF VARTYPE(vValue) = "N"
        vValue = LTRIM(STR(vValue))
    ENDIF
    INSERT INTO (cCursor) VALUES (cName, vValue)
 
PROCEDURE decl
    DECLARE AVIFileInit IN avifil32
    DECLARE AVIFileExit IN avifil32
    DECLARE INTEGER AVIFileRelease IN avifil32 INTEGER pfile  
    DECLARE INTEGER AVIStreamRelease IN avifil32 INTEGER pavi  
    DECLARE INTEGER AVIStreamLength IN avifil32 INTEGER pavi  
    DECLARE INTEGER AVIStreamStart IN avifil32 INTEGER pavi  
 
    DECLARE INTEGER AVIFileOpen IN avifil32;
        INTEGER @ppfile, STRING szFile,;
        INTEGER mode, INTEGER pclsidHandler
 
    DECLARE INTEGER AVIFileGetStream IN avifil32;
        INTEGER pfile, INTEGER @ppavi,;
        INTEGER fccType, INTEGER lParam
 
    DECLARE INTEGER AVIStreamInfo IN avifil32;
        INTEGER pavi, STRING @psi, INTEGER lSize
 
FUNCTION buf2dword(lcBuffer)
RETURN Asc(SUBSTR(lcBuffer, 1,1)) + ;
    BitLShift(Asc(SUBSTR(lcBuffer, 2,1)),  8) +;
    BitLShift(Asc(SUBSTR(lcBuffer, 3,1)), 16) +;
    BitLShift(Asc(SUBSTR(lcBuffer, 4,1)), 24)
 
FUNCTION buf2word(lcBuffer)
RETURN Asc(SUBSTR(lcBuffer, 1,1)) + ;
       Asc(SUBSTR(lcBuffer, 2,1)) * 256
 
PROCEDURE PosWindow(cWindow, nRow1, nColumn1, nRow2, nColumn2)
    MOVE WINDOW (cWindow) TO nRow1, nColumn1
    SIZE WINDOW (cWindow) TO nRow2, nColumn2
 
 
 

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
4654 bytes  
Created: 2003-11-28 20:45:37  
Modified: 2009-02-03 15:26:42  
Visits in 7 days: 66  
Listed functions:
AVIFileExit
AVIFileGetStream
AVIFileInit
AVIFileOpen
AVIFileRelease
AVIStreamInfo
AVIStreamLength
AVIStreamRelease
AVIStreamStart
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.242.191.65)
6.65 min.Function: 'SetVolumeMountPoint'
Function group: 'File System'
6.7 min.Function: 'IsWellKnownSid'
Function group: 'Security'
6.75 min.Example: 'Drawing Windows frame controls using the DrawFrameControl function'
Google
Advertise here!