home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / d / d009_2 / 1.ddi / SAMPLES / TRAPS / CWTRAP.MS$ / CWTRAP.bin
Encoding:
Text File  |  1992-02-04  |  1.8 KB  |  53 lines

  1. '************************** CWTRAP.MST *********************************
  2. 'Demonstrates:  Trapping a Windows 'Create Window' event from a MSTest
  3. '               script
  4. '
  5. 'Required Files: CWTRAP.DLL, TESTDRVR.EXE
  6. '
  7. 'Uses:
  8. '
  9. 'Complexity Level: ADVANCED
  10. '
  11. 'Notes: This script uses the CWTRAP.DLL to trap a Windows 'Create Window'
  12. '       event.  CWTRAP.DLL must be in the current directory, in the
  13. '       same directory as TESTDRVR.EXE, or on the PATH to be found.
  14. '
  15. '       Note that this trap sample will only work for Windows
  16. '       applications that set their window title at the time the window
  17. '       is created.  Since many Windows application delay setting their
  18. '       window title until after processing their WM_CREATE message, this
  19. '       trap may not work for all windows apps.
  20. '
  21. '************************************************************************
  22. '$INCLUDE: 'MSTEST.INC'
  23.  
  24. Declare Sub SetCWTitle Lib "CWTrap.DLL"  (lpszNewTitle$)
  25. Declare Sub GetCWTitle Lib "CWTrap.DLL"  (lpszBuffer$, cbBuffer%)
  26. GLOBAL trapfile%
  27.  
  28. Viewport Clear
  29. SetCWTitle "Calculator"  'Trap only Create Window events generated by Calculator
  30. trapfile = FREEFILE
  31.  
  32. OPEN "TRAP.LOG" FOR OUTPUT AS # trapfile
  33. PRINT # trapfile, "**************************************************"
  34. PRINT # trapfile, "         TRAP RECORDS FROM TRAP.MST               "
  35. PRINT # trapfile, "         "; DATETIME$
  36. PRINT # trapfile, "**************************************************"
  37. CLOSE # trapfile
  38.  
  39. '*** Run the Windows Calculator program to generate a
  40. '*** Create Window event
  41. RUN "Calc"
  42.  
  43.  
  44.  
  45. END
  46.  
  47. TRAP CWTRAP FROM "CWTRAP.DLL"
  48.     OPEN "TRAP.LOG" FOR APPEND AS # trapfile
  49.     PRINT # trapfile, "CWTRAP Event Occurred..."
  50.     CLOSE # trapfile
  51. END TRAP'**************************************************
  52.  
  53.