home *** CD-ROM | disk | FTP | other *** search
- '************************** CWTRAP.MST *********************************
- 'Demonstrates: Trapping a Windows 'Create Window' event from a MSTest
- ' script
- '
- 'Required Files: CWTRAP.DLL, TESTDRVR.EXE
- '
- 'Uses:
- '
- 'Complexity Level: ADVANCED
- '
- 'Notes: This script uses the CWTRAP.DLL to trap a Windows 'Create Window'
- ' event. CWTRAP.DLL must be in the current directory, in the
- ' same directory as TESTDRVR.EXE, or on the PATH to be found.
- '
- ' Note that this trap sample will only work for Windows
- ' applications that set their window title at the time the window
- ' is created. Since many Windows application delay setting their
- ' window title until after processing their WM_CREATE message, this
- ' trap may not work for all windows apps.
- '
- '************************************************************************
- '$INCLUDE: 'MSTEST.INC'
-
- Declare Sub SetCWTitle Lib "CWTrap.DLL" (lpszNewTitle$)
- Declare Sub GetCWTitle Lib "CWTrap.DLL" (lpszBuffer$, cbBuffer%)
- GLOBAL trapfile%
-
- Viewport Clear
- SetCWTitle "Calculator" 'Trap only Create Window events generated by Calculator
- trapfile = FREEFILE
-
- OPEN "TRAP.LOG" FOR OUTPUT AS # trapfile
- PRINT # trapfile, "**************************************************"
- PRINT # trapfile, " TRAP RECORDS FROM TRAP.MST "
- PRINT # trapfile, " "; DATETIME$
- PRINT # trapfile, "**************************************************"
- CLOSE # trapfile
-
- '*** Run the Windows Calculator program to generate a
- '*** Create Window event
- RUN "Calc"
-
-
-
- END
-
- TRAP CWTRAP FROM "CWTRAP.DLL"
- OPEN "TRAP.LOG" FOR APPEND AS # trapfile
- PRINT # trapfile, "CWTRAP Event Occurred..."
- CLOSE # trapfile
- END TRAP'**************************************************
-
-