This will completely hide it:
Set the timer1.Interval = 1;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WindowsApplication2
{
public partial class Form1 : Form
{
private bool hidden;
private const UInt32 WM_LBUTTONDOWN = 0x201;
private const UInt32 WM_LBUTTONUP = 0x202;
[DllImport("user32.dll")]
private static extern int SendMessage(IntPtr handle, UInt32 message,
int wParam, int lParam);
[DllImport("user32.dll", EntryPoint = "ShowCaret")]
public static extern long ShowCaret(IntPtr hwnd);
[DllImport("user32.dll", EntryPoint = "HideCaret")]
public static extern long HideCaret(IntPtr hwnd);
public Form1()
{
InitializeComponent();
}
private void timer1_Tick(object sender, EventArgs e)
{
SendMessage(richTextBox1.Handle, WM_LBUTTONDOWN, 0, 0);
SendMessage(richTextBox1.Handle, WM_LBUTTONUP, 0, 0);
timer1.Stop();
}
private void richTextBox1_Click(object sender, EventArgs e)
{
if (!hidden)
{
hidden = true;
HideCaret(richTextBox1.Handle);
}
}
}
}
|