// Determine the length of a control's Text. Required since using the // RichTextBox .Length property wipes out the Undo/Redo buffer. public static int GetTextLength(IntPtr hControl) { GETTEXTLENGTHEX lpGTL = new GETTEXTLENGTHEX(); lpGTL.uiFlags = 0; lpGTL.uiCodePage = 1200; // Unicode return(SendMessage(hControl, EM_GETTEXTLENGTHEX, ref lpGTL, IntPtr.Zero)); }
public static int GetTextLength(RichTextBox rt) { GETTEXTLENGTHEX GTL = new GETTEXTLENGTHEX(); GTL.uiFlags = GTL_DEFAULT; GTL.uiCodePage = CP_UNICODE; return((int)SendMessage(rt.Handle, (IntPtr)EM_GETTEXTLENGTHEX, ref GTL, IntPtr.Zero)); }
static extern IntPtr SendMessage(IntPtr hWnd, int wMsg, ref GETTEXTLENGTHEX wParam, IntPtr lParam);
private static extern int SendMessage(IntPtr hWnd, IntPtr msg, ref GETTEXTLENGTHEX wParam, IntPtr lParam);
public static int GetTextLength(RichTextBox rt) { GETTEXTLENGTHEX GTL = new GETTEXTLENGTHEX(); GTL.uiFlags = GTL_DEFAULT; GTL.uiCodePage = CP_UNICODE; return (int)SendMessage(rt.Handle, (IntPtr)EM_GETTEXTLENGTHEX, ref GTL, IntPtr.Zero); }
internal static extern int SendMessage(IntPtr hWnd, int msg, ref GETTEXTLENGTHEX wParam, int lParam);
public static extern int SendMessage(IntPtr hWnd, int Msg, ref GETTEXTLENGTHEX wParam, IntPtr lParam);
public static extern int GetTextLength(IntPtr hWnd, int Msg, ref GETTEXTLENGTHEX wParam, StringBuilder lParam);
private static extern void RichTextBox_GetTextLengthEx(out GETTEXTLENGTHEX value);