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 >
Wrap
Visual Basic Form
|
1994-10-06
|
6KB
|
163 lines
vtshilit
"VisualSpeller Highlighting Example
Form258
CheckButton
&Check
LoadTextButton
&LoadText
DoneButton
&Done
Text1
Text1
Label1
2Type text in box and press CHECK to spellcheck it!
Command1_Click
sbefore
SystemInfo
safter
etime#
speller
ClearCounts
VTSpellSystemInfoW
CheckTexts
Text1
ResultCode
text3
CacheHit
text4
CacheMiss
Milliseconds
WordCountJ
text5]
standard
ReplaceCount
VTST_WORD_MISSPELLED
VTST_IGNORE_REPLACE
PopUp
result
VTST_CHECK_CANCELED
ResumeCheckc
VTRC_RECHECK
Command2_Click
Command3_Click
LoadTextFile0
GetAFileName
Command4_Click
AutoPopUp
EHandler
VTRC_NOCHECK
EventOptions
AutoReplace
SelStart
WordOffset
SelLength3
MisspelledWord
repcount
ReplacementCount
VTPOP_MISSPELL
Form_Load
dialog
UseVBDialog
Text1_Change_
DoneButton_Click
LoadTextButton_Click
CheckButton_Click
ReplaceOccurred
CheckButton_Click
For spellchecker result codeq
To build up messagesu
Here we will use either the VBX internal misspell r
dialog or a Visual Basic dialog (see VTSPOPUP.FRM)r
to handle misspell conditions, but only after
we are notified of the misspell, so that we may
first highlight the offending word in the texty
box.t
The global UseVBDialog should be TRUE if to use
the VB dialog.
NOTE: IN ORDER FOR THE SELECTION TO BE HIGHLIGHTED"
WHILE A DIALOGUE (POPUP) IS DISPLAYED, THEI
HideSelection PROPERTY OF THE TEXT CONTROLI
MUST BE SET FALSE!E
Make sure that automatic popups are disabled.
Because the popup will not automatically occur,
there may be events triggered, so let's disabled
them to avoid invoking unwanted code (since we're
using the one VTSpell object for many examples).e
We also want AutoReplace to be TRUE. This allows
the VBX to go ahead and replace words flagged for
GLOBAL REPLACE without us having to do anything.r
Clearing the counts sets the words checked and
replaced counters to zero.h
This disables all eventsa
Here, the spellcheck is started via CheckText. WhenO
control returns, we check the result code to determine
just what transpired.
Enable an error handler
Start the spellchecku
Get the result code
Now we fall into a loop. Result codes of less
than or equal to zero are all status conditions,
which we need to handle. A positive condition is
an error condition, so we let that fall out of
the loop.
Spellcheck complete!e
Throw up a box with the count
of words checked and replaced.
Spellcheck complete!
Words Checked
Words Replaced
Exit loop.
The VBX has detected a misspelled word, oru
one which has been flagged for user
intervention in the Ignore/Replace list
or an extended custom dictionary (ie, a
PROMPT condition). With AutoReplace TRUE,u
we wouldn't be getting the VTST_IGNORE_REPLACEn
otherwise.t
First, update the text in the text controle
if the a replace occurred, as signaled by
the speller.ReplaceOccurred property.
Now we're sure the text control texte
matches that saved by the VBX, so wee
can go ahead and highlight the word
in the textbox, then invoke the popup.o
This is done by using the WordOffset andt
the length of the MisspelledWord to set
the selection in the text box..
Now invoke the popup and get result code
If an error condition occurred, exitn
the loop.
Check if user punched the cancel button
Canceled
Check if a word was replaced and update
text control if so.
Fall out of the CASEn
The DoEvents will allow some timesharing forr
other processes. Then, we resume the spellcheck
by setting the ResumeCheck property (VTRC_NOCHECK
says to not recheck the last word, in case it
was a replace, or we could use VTRC_RECHECK if
we wanted the replaced word rechecked). This
picks up where the spellcheck left off, using
the same text loaded by CheckText. When this
returns, we get the result code again, and loop
back to the top of the loop.o
This is IMPORTANT - if any wordsa
have been replaced, we need tod
read the text back out andd
replace the original text (in
the text control). Otherwise
we will have lost the replaces!
Disable the error handler
Exitb
Display the error
ContinueD
DoneButton_Click
Exit this form)
Form_Load
The quifk rown fxo jumps ovr the lazi dog's bac.
LoadTextButton_Click
This allows a text file to be loaded into the
text control, for convenience.l
*.txt