Click here to Skip to main content
15,892,005 members
Articles / DevOps / Load Testing

NHunspell Component for Visual Studio

Rate me:
Please Sign up or sign in to vote.
4.90/5 (31 votes)
1 Sep 2013CPOL6 min read 113.9K   4.1K   46  
NHunspell component example for WindowsForms
using System;
using System.Runtime.InteropServices;

namespace NHunspellComponent.SupportClasses
{
   internal class NativeMethods
   {
      #region Unmanaged Code

      [StructLayout(LayoutKind.Sequential)]
      internal struct RECT
      {
         public int Left;
         public int Top;
         public int Right;
         public int Bottom;
      }

      [StructLayout(LayoutKind.Sequential)]
      internal struct CHARRANGE
      {
         public int cpMin; //First character of range (0 for start of doc)
         public int cpMax; //Last character of range (-1 for end of doc)
      }

      [StructLayout(LayoutKind.Sequential)]
      internal struct FORMATRANGE
      {
         public IntPtr hdc; //Actual DC to draw on
         public IntPtr hdcTarget; //Target DC for determining text formatting
         public RECT rc; //Region of the DC to draw to (in twips)
         public RECT rcPage; //Region of the whole DC (page size) (in twips)
         public CHARRANGE chrg; //Range of text to draw (see earlier declaration)
      }

      internal const int WM_USER = 0x0400;
      internal const int EM_FORMATRANGE = WM_USER + 57;

      [DllImport("user32")]
      internal static extern IntPtr SendMessage(IntPtr hWnd, uint msg, IntPtr wp, ref FORMATRANGE lp);

      [DllImport("user32", CharSet = CharSet.Auto, EntryPoint = "SendMessage")]
      internal static extern IntPtr SendMessageInt(
         IntPtr handle,
         uint msg,
         IntPtr wParam,
         IntPtr lParam
         );

      internal const int EM_LINEINDEX = 0x00BB;
      internal const int EM_LINELENGTH = 0x00C1;
      internal const int EM_POSFROMCHAR = 0x00D6;
      internal const int EM_CHARFROMPOS = 0x00D7;
      internal const int EM_GETFIRSTVISIBLELINE = 0xCE;

      [DllImport("user32", EntryPoint = "ShowCaret")]
      [return: MarshalAs(UnmanagedType.Bool)]
      internal static extern bool ShowCaretAPI(
         IntPtr hwnd);

      #endregion

      private NativeMethods()
      {
      }
   }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Ukraine Ukraine
"a man can do no more than he can" (proverb)
Don't you think there are a lot of things you couldn't do couple of years before but now you can? Things didn't change, but the only thing that changed is belief in yourself.

Comments and Discussions