home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 4 Unleashed / Visual_Basic_4_Unleashed_SAMS_Publishing_1995.iso / vspell / vtshilit.frm (.txt) < prev    next >
Visual Basic Form  |  1994-10-06  |  6KB  |  163 lines

  1. vtshilit
  2. "VisualSpeller Highlighting Example
  3. Form258
  4. CheckButton
  5. &Check
  6. LoadTextButton
  7.     &LoadText
  8. DoneButton
  9. &Done
  10. Text1
  11. Text1
  12. Label1
  13. 2Type text in box and press CHECK to spellcheck it!
  14. Command1_Click
  15. sbefore
  16. SystemInfo
  17. safter
  18. etime#
  19. speller
  20. ClearCounts
  21. VTSpellSystemInfoW
  22.     CheckTexts
  23. Text1
  24. ResultCode
  25. text3
  26. CacheHit
  27. text4
  28.     CacheMiss
  29. Milliseconds
  30.     WordCountJ
  31. text5]
  32. standard
  33. ReplaceCount
  34. VTST_WORD_MISSPELLED
  35. VTST_IGNORE_REPLACE
  36. PopUp
  37. result
  38. VTST_CHECK_CANCELED
  39. ResumeCheckc
  40. VTRC_RECHECK
  41. Command2_Click 
  42. Command3_Click
  43. LoadTextFile0
  44. GetAFileName
  45. Command4_Click
  46.     AutoPopUp
  47. EHandler
  48. VTRC_NOCHECK
  49. EventOptions
  50. AutoReplace
  51. SelStart
  52. WordOffset
  53.     SelLength3
  54. MisspelledWord
  55. repcount
  56. ReplacementCount
  57. VTPOP_MISSPELL
  58.     Form_Load
  59. dialog
  60. UseVBDialog
  61. Text1_Change_
  62. DoneButton_Click
  63. LoadTextButton_Click
  64. CheckButton_Click
  65. ReplaceOccurred
  66. CheckButton_Click
  67.  For spellchecker result codeq
  68.  To build up messagesu
  69.  Here we will use either the VBX internal misspell r
  70.  dialog or a Visual Basic dialog (see VTSPOPUP.FRM)r
  71.  to handle misspell conditions, but only after
  72.  we are notified of the misspell, so that we may
  73.  first highlight the offending word in the texty
  74.  box.t
  75.  The global UseVBDialog should be TRUE if to use
  76.  the VB dialog.
  77.  NOTE: IN ORDER FOR THE SELECTION TO BE HIGHLIGHTED"
  78.  WHILE A DIALOGUE (POPUP) IS DISPLAYED, THEI
  79.  HideSelection PROPERTY OF THE TEXT CONTROLI
  80.  MUST BE SET FALSE!E
  81.  Make sure that automatic popups are disabled.
  82.  Because the popup will not automatically occur,
  83.  there may be events triggered, so let's disabled
  84.  them to avoid invoking unwanted code (since we're
  85.  using the one VTSpell object for many examples).e
  86.  We also want AutoReplace to be TRUE.  This allows
  87.  the VBX to go ahead and replace words flagged for
  88.  GLOBAL REPLACE without us having to do anything.r
  89.  Clearing the counts sets the words checked and
  90.  replaced counters to zero.h
  91.  This disables all eventsa
  92.  Here, the spellcheck is started via CheckText.  WhenO
  93.  control returns, we check the result code to determine
  94.  just what transpired.
  95.  Enable an error handler
  96.  Start the spellchecku
  97.  Get the result code
  98.  Now we fall into a loop.  Result codes of less
  99.  than or equal to zero are all status conditions,
  100.  which we need to handle.  A positive condition is
  101.  an error condition, so we let that fall out of 
  102.  the loop.
  103.  Spellcheck complete!e
  104.  Throw up a box with the count
  105.  of words checked and replaced.
  106. Spellcheck complete!
  107.  Words Checked
  108.  Words Replaced
  109.  Exit loop.
  110.  The VBX has detected a misspelled word, oru
  111.  one which has been flagged for user
  112.  intervention in the Ignore/Replace list
  113.  or an extended custom dictionary (ie, a
  114.  PROMPT condition).  With AutoReplace TRUE,u
  115.  we wouldn't be getting the VTST_IGNORE_REPLACEn
  116.  otherwise.t
  117.  First, update the text in the text controle
  118.  if the a replace occurred, as signaled by
  119.  the speller.ReplaceOccurred property.
  120.  Now we're sure the text control texte
  121.  matches that saved by the VBX, so wee
  122.  can go ahead and highlight the word
  123.  in the textbox, then invoke the popup.o
  124.  This is done by using the WordOffset andt
  125.  the length of the MisspelledWord to set
  126.  the selection in the text box..
  127.  Now invoke the popup and get result code
  128.  If an error condition occurred, exitn
  129.  the loop.
  130.  Check if user punched the cancel button
  131. Canceled
  132.  Check if a word was replaced and update
  133.  text control if so.
  134.  Fall out of the CASEn
  135.  The DoEvents will allow some timesharing forr
  136.  other processes.  Then, we resume the spellcheck
  137.  by setting the ResumeCheck property (VTRC_NOCHECK
  138.  says to not recheck the last word, in case it
  139.  was a replace, or we could use VTRC_RECHECK if
  140.  we wanted the replaced word rechecked).  This
  141.  picks up where the spellcheck left off, using
  142.  the same text loaded by CheckText.  When this
  143.  returns, we get the result code again, and loop
  144.  back to the top of the loop.o
  145.  This is IMPORTANT - if any wordsa
  146.  have been replaced, we need tod
  147.  read the text back out andd
  148.  replace the original text (in
  149.  the text control).  Otherwise
  150.  we will have lost the replaces!
  151.  Disable the error handler
  152.  Exitb
  153.  Display the error
  154.  ContinueD
  155. DoneButton_Click
  156.  Exit this form)
  157. Form_Load
  158. The quifk rown fxo jumps ovr the lazi dog's bac.
  159. LoadTextButton_Click
  160.  This allows a text file to be loaded into the
  161.  text control, for convenience.l
  162. *.txt
  163.