Posted by: bearc0025 | April 15, 2009

Add a spell checker to your C# applications

Add a spell checker to your C# applications using Sentry’s spellchecker

Steps once you get the download the eval:

  • copy DLL (C:\Program Files\ssce\runtime\ssce5532.dll) and C:\Program Files\ssce\runtime\lex folder to target dir
  • add: “using Sentry;” to any classes using the spell checker
  • set the eval key: SpellingCheckerEngine.SetKey(<eval key from email>);
  • set lex path: SpellingCheckerEngine.SetMainLexPath(<target dir> + “\\lex”);
  • set lext files: SpellingCheckerEngine.SetMainLexFiles(“ssceam.tlx,ssceam2.clx”);

Add option and color setting vars (based on the C# sample code project) and event handlers to the RichTextBox (named rtbText here)…

private uint RTB1Options = (uint)SpellingCheckerEngine.backgroundOptions.MARK_COLOR;
private System.Drawing.Color RTB1MarkColor = System.Drawing.Color.Red;

private uint RTB2Options = (uint)SpellingCheckerEngine.backgroundOptions.MARK_STRIKETHROUGH;
private System.Drawing.Color RTB2MarkColor = System.Drawing.Color.Transparent;

private void rtbText_Enter(object sender, EventArgs e)
{
SpellingCheckerEngine.CheckCtrlBackgroundNotify(rtbText.Handle,
RTB1Options, RTB1MarkColor);
}

private void rtbText_MouseUp(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
// Mouse was right-clicked. Present the spelling context menu.
SpellingCheckerEngine.CheckCtrlBackgroundMenu(rtbText.Handle,
e.X, e.Y, RTB1Options, RTB1MarkColor);
}
}

private void rtbText_SelectionChanged(object sender, EventArgs e)
{
SpellingCheckerEngine.CheckCtrlBackgroundNotify(rtbText.Handle,
RTB1Options, RTB1MarkColor);
}

private void rtbText_TextChanged(object sender, EventArgs e)
{
SpellingCheckerEngine.CheckCtrlBackgroundNotify(rtbText.Handle,
RTB1Options, RTB1MarkColor);
}

private void tbSpellCheck_Click(object sender, EventArgs e)
{
SpellingCheckerEngine.CheckCtrlDlg(this.Handle, rtbText.Handle, false);
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: