Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Obtaining MAC address through Address Resolution Protocol (ARP) request
One more way to retrieve environment strings
How to drag a Form not using its Titlebar or Caption
Obtaining the System and Windows folder names
Reading keys in the specified section of the Win.ini file
Saying "Hello World!" with VFP and WinAPI
How to play a waveform sound (a WAV file in particular)
Using the GetLogicalDriveStrings
PocketPC: creating directories and files
Determining whether or not the system is connected to the Internet
Extended OS Version info
Pocket PC: modifying keys in the System Registry
Retrieving graphic capabilities of default printer
Retrieving statistics for the TCP protocol running on the local computer
Retrieving the priority class for the current process
StrDup returns a pointer to the duplicate of a source VFP string
Copying strings through the global memory block
Basic Volume information
Creating two-byte hashes for a list of URLs
Obtaining window class name for the main VFP window
Retrieving current user for the process
Retrieving the path of the printer-driver directory and printer-processor directory
Retrieving the System Time adjustment
Enumerating Performance Counters
Using an Event Object. Part B: running an application responding to events

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:
Compile this code into a separate executable and test with an executable created from the Part A of this example. This is the name of the Event Object, that links two parts.

Start Part A executable prior to the Part B.
 
PUBLIC frm, lcEventName
lcEventName = "TimeToGoHomeNotice"
 
frm = CreateObject ("Tform", lcEventName)
IF TYPE ("frm") = "O"
    frm.Visible = .T.
    READ EVENTS
ENDIF
 
DEFINE CLASS Tform As Form
#DEFINE watchingInterval  500
 
    Width=400
    Height=150
    Caption="Responding to events"
    BackColor=Rgb(230,250,230)
    AutoCenter=.T.
    hEvent=0
 
    ADD OBJECT tm As Timer WITH Interval=0
 
PROCEDURE  Init (lcName)
    DO decl
 
    _SCREEN.WindowState = 2
    _SCREEN.Caption = "Event Client"
 
    IF Not THIS.checkEvent(lcName)
        = MessageB ("Unable to locate the event: " + lcName)
        RETURN .F.
    ENDIF
    THIS.tm.Interval = watchingInterval
 
PROCEDURE  Destroy
    QUIT
 
PROCEDURE  tm.Timer
    IF ThisForm._signaled()
        ThisForm._notify
    ENDIF
 
PROCEDURE  checkEvent (lcName)
#DEFINE STANDARD_RIGHTS_REQUIRED  0xF0000 
#DEFINE SYNCHRONIZE  0x100000 
 
* STANDARD_RIGHTS_REQUIRED Or SYNCHRONIZE Or 0x03
#DEFINE EVENT_ALL_ACCESS 0x1F0003
 
    THIS.hEvent = OpenEvent (EVENT_ALL_ACCESS, 0, lcName)
RETURN  Not (THIS.hEvent = 0)
 
PROCEDURE  _notify
#DEFINE SW_NORMAL  1
#DEFINE SW_SHOWMAXIMIZED 3
 
    * make this window active
    _SCREEN.WindowState = 1
    _SCREEN.WindowState = 2
 
    = MessageB ("Wake Up! It is time to go home.")
    THIS.tm.Interval = watchingInterval
 
PROCEDURE  _signaled
#DEFINE INFINITE  0xffffffff
#DEFINE WAIT_OBJECT_0           0
 
    LOCAL dwWaitResult
    dwWaitResult = WaitForSingleObject (THIS.hEvent, 0)
 
    IF dwWaitResult = WAIT_OBJECT_0
        = ResetEvent (THIS.hEvent)
        THIS.tm.Interval = 0
        RETURN .T.
    ENDIF
RETURN .F.
 
ENDDEFINE
 
PROCEDURE  decl
    DECLARE INTEGER OpenEvent IN kernel32;
        INTEGER dwDesiredAccess,;
        INTEGER bInheritHandle,;
        STRING  lpName
 
    DECLARE INTEGER ResetEvent IN kernel32 INTEGER hEvent
 
    DECLARE INTEGER WaitForSingleObject IN kernel32;
        INTEGER hHandle,;
        INTEGER dwMilliseconds
 
 

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
1878 bytes  
Created: 2001-09-16 12:00:00  
Modified: 2005-12-27 10:34:41  
Visits in 7 days: 76  
Listed functions:
OpenEvent
ResetEvent
WaitForSingleObject
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 (107.20.129.212)
6 sec.Function: 'MAPIAddress'
Function group: 'Simple MAPI'
9 sec.Function: 'midiOutGetDevCaps'
Function group: 'Windows Multimedia'
10.78 hrs.Example: 'Using the DrawText function'
 Function: 'CryptHashData'
Function group: 'Cryptography Reference'
11.11 hrs.Example: 'An alternative way of setting Form.Closable to False'
14.12 hrs.Example: 'Storing content of the Clipboard to a bitmap file'
14.13 hrs.Example: 'How to extract frames from AVI files'
18.63 hrs.Example: 'Confining Windows calculator inside the VFP main window'
18.64 hrs.Function: 'GetPriorityClass'
Function group: 'Process and Thread'
20.35 hrs.Function: 'CeRapiInvoke'
Function group: 'Remote Application Programming (RAPI)'
Google
Advertise here!