Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Retrieving the priority class for the current process
Using GetBinaryType (WinNT only) to determine the type of an executable file
Using the Semaphore object
Dynamic strings implemented through VFP Custom class
Retrieving geometrical parameters of the system desktop window
Terminating VFP application using the FatalAppExit
Enumerating connections made to a shared resource for the local computer (WinNT only)
Retrieving the System Time adjustment
Another way to go online (it is not about choosing an ISP)
Displaying the main Dial-Up Networking dialog box
Enumerating ODBC drivers available on the local computer
How to drag a Form not using its Titlebar or Caption
PocketPC: creating directories and files
Searching for the specified file using the SearchPath
An alternative way of setting Form.Closable to False
GDI+: Using Scale and Shear transformations
How to test file attributes (key method for FileExists and DirectoryExists routines)
Converting path to original case
How to fill a buffer with random bytes using Cryptography API Functions
Using the GetLogicalDriveStrings
GDI+: converting text strings to images and saving in a graphics file
How to intercept window messages sent to VFP form
Power capabilities of the system: battery, UPS, sleep and hibernation modes, processor throttling
Reading STARTUPINFO structure for the current VFP session
How to intercept window messages sent to VFP form

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:
Before testing this code download WinProcXT.dll to a local directory and register it:

        regsvr32 c:\temp\WinProcXT.dll

Change "c:\temp" to the name of a directory where you copied the DLL file.

This is an ActiveX DLL. The VB code is available here.

The DLL reassignes the WindowProc address of the VFP form to its own function and sends system messages to a text file. Change in the following program code the "c:\temp\log.txt" to any appropriate file name.

Every system message has three parameters to be saved: message identifier, first message parameter, second message parameter.

Run the following code. Right after you close the form a list of system messages saved during its execution appears. Usually this list ends with message identifiers 2 (WM_DESTROY) and 130 (WM_NCDESTROY).

List of some message identifiers is available here.

* * *
For VFP9 use BINDEVENT() to trap Windows messages.
 
PUBLIC objForm
objForm = CreateObject("TForm")
objForm.Visible = .T.
 
DEFINE CLASS TForm As Form
    Width=460
    Height=300
    AutoCenter=.T.
    Caption=" Recording Window Messages"
    KeyPreview=.T.
    recorder=.F.
    hWindow=0
 
PROCEDURE Activate
    IF THIS.hWindow = 0
        DECLARE INTEGER GetFocus IN user32
        THIS.hWindow = GetFocus()
 
        THIS.recorder = CreateObject("TRecorder",;
            THIS.hWindow, "c:\temp\log.txt")
    ENDIF
 
PROCEDURE KeyPress
LPARAMETERS nKeyCode, nShiftAltCtrl
    IF nKeyCode = 27
        ThisForm.Release
    ENDIF
 
ENDDEFINE
 
DEFINE CLASS TRecorder As Custom
    hWindow=0
    LogFile=""
    ole=.F.
 
PROCEDURE Init (hWnd, lcFileName)
    THIS.LogFile = lcFileName
    THIS.hWindow = hWnd
 
    ON ERROR ?? Chr(7)
    THIS.ole = CreateObject("WinProcXT.WinProc")
    ON ERROR
 
    IF TYPE("THIS.ole") <> "O"
        RETURN .F.
    ENDIF
 
    WITH THIS.ole
        .StartService (THIS.hWindow, THIS.LogFile)
        IF Not .IsRunning
            RETURN .F.
        ENDIF
    ENDWITH
 
PROCEDURE Destroy
    THIS.ole.StopService
    IF FILE (THIS.LogFile)
        CREATE CURSOR csMessages (msg N(16), wParam N(16), lParam N(16))
        APPEND FROM (THIS.LogFile) TYPE DELIMITED WITH TAB
        GO TOP
        BROWSE NORMAL NOWAIT
    ENDIF
ENDDEFINE
 
 

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
1207 bytes  
Created: 2002-04-21 18:35:15  
Modified: 2005-10-10 11:22:17  
Visits in 7 days: 49  
Listed functions:
GetFocus
Printer friendly API declarations
My comment:
The WindowProc function is an application-defined function that processes messages sent to a window.
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 (107.22.25.119)
33.98 min.Example: 'Drawing a rectangle using Windows regular edges and borders'
34.08 min.Function: 'InternetDial'
Function group: 'Internet Functions (WinInet)'
Google
Advertise here!