Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
How to get Special Folders paths
How to save registry key including its subkeys and values to a file
Minimizing all running applications
Retrieving the names of all sections in an initialization file
Time in milliseconds represented as string (e.g. 1 hour 24 min 36 sec)
Closing Windows
Drawing icons associated with the VFP main window
Retrieving information about MS-DOS device names using QueryDosDevice (WinNT only)
Simple MAPI: how to pick an email recipient from Outlook Express address book
Using Path functions from Shell Lightweight Utility APIs (shlapi.dll)
Drawing cursors for the classes defined by the system (preregistered): BUTTON, EDIT, LISTBOX etc.
How to initiate System shutdown
Obtaining heap handles and enumerating memory blocks for the current VFP session (WinNT only)
Starting a dialog box for connecting to network resources and passing input parameters
URL: splitting into its component parts
Using FrameRgn for displaying system colors
Displaying OS Memory Status
How to test file attributes (key method for FileExists and DirectoryExists routines)
Pocket PC: retrieving data from the Contacts Database
Reading data from INI files
Reading virtual key status values and key names
Retrieving information about the specified icon
Creating a clipping region from the path selected into the device context of a form
How to create transparent areas inside a form -- punching holes in the form
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: 80  
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.127.92)
7.22 hrs.Example: 'Using Multimedia Command Strings to play MIDI files'
 Example: 'Displaying dimmed window behind VFP top-level form'
14.71 hrs.Function: 'GdipFillRectangle'
 Function: 'EnumServicesStatus'
Function group: 'Service'
17.48 hrs.Example: 'How to print a bitmap file'
 Function: 'InternetCheckConnection'
Google
Advertise here!