コード例 #1
0
ファイル: RichTextBoxEx.cs プロジェクト: jfbauer1/tesvsnip
        private string CharRangeToString(CHARRANGE c)
        {
            var lParam = new TEXTRANGE();

            lParam.chrg = c;
            //if ((c.cpMax > this.Text.Length) || ((c.cpMax - c.cpMin) <= 0))
            //{
            //    return string.Empty;
            //}
            int        size   = (c.cpMax - c.cpMin) + 1;
            CharBuffer buffer = CharBuffer.CreateBuffer(size);
            IntPtr     ptr    = buffer.AllocCoTaskMem();

            if (ptr == IntPtr.Zero)
            {
                throw new OutOfMemoryException("OutOfMemory");
            }
            lParam.lpstrText = ptr;
            var num1 = (int)SendMessage(new HandleRef(this, base.Handle), 0x44b, 0, lParam);

            buffer.PutCoTaskMem(ptr);
            if (lParam.lpstrText != IntPtr.Zero)
            {
                Marshal.FreeCoTaskMem(ptr);
            }
            return(buffer.GetString());
        }
コード例 #2
0
 internal static extern int SendMessage(IntPtr hWnd, int msg, int wParam, TEXTRANGE range);
コード例 #3
0
ファイル: RichTextBoxEx.cs プロジェクト: rxantos/tesv-snip
 private string CharRangeToString(CHARRANGE c)
 {
     var lParam = new TEXTRANGE();
     lParam.chrg = c;
     //if ((c.cpMax > this.Text.Length) || ((c.cpMax - c.cpMin) <= 0))
     //{
     //    return string.Empty;
     //}
     int size = (c.cpMax - c.cpMin) + 1;
     CharBuffer buffer = CharBuffer.CreateBuffer(size);
     IntPtr ptr = buffer.AllocCoTaskMem();
     if (ptr == IntPtr.Zero)
     {
         throw new OutOfMemoryException("OutOfMemory");
     }
     lParam.lpstrText = ptr;
     var num1 = (int) SendMessage(new HandleRef(this, base.Handle), 0x44b, 0, lParam);
     buffer.PutCoTaskMem(ptr);
     if (lParam.lpstrText != IntPtr.Zero)
     {
         Marshal.FreeCoTaskMem(ptr);
     }
     return buffer.GetString();
 }
コード例 #4
0
ファイル: RichTextBoxEx.cs プロジェクト: rxantos/tesv-snip
 public static extern IntPtr SendMessage(HandleRef hWnd, int msg, int wParam, TEXTRANGE lParam);
コード例 #5
0
ファイル: RichTextBoxEx.cs プロジェクト: jfbauer1/tesvsnip
 public static extern IntPtr SendMessage(HandleRef hWnd, int msg, int wParam, TEXTRANGE lParam);
コード例 #6
0
 private static extern void RichTextBox_TextRange(out TEXTRANGE value);