惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

MyScale Blog
MyScale Blog
Jina AI
Jina AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
阮一峰的网络日志
阮一峰的网络日志
P
Proofpoint News Feed
Last Week in AI
Last Week in AI
博客园 - 司徒正美
Martin Fowler
Martin Fowler
T
Tailwind CSS Blog
B
Blog RSS Feed
Vercel News
Vercel News
博客园 - 聂微东
I
InfoQ
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
M
MIT News - Artificial intelligence
Recent Announcements
Recent Announcements
GbyAI
GbyAI
L
LangChain Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Microsoft Security Blog
Microsoft Security Blog
C
Check Point Blog
MongoDB | Blog
MongoDB | Blog
B
Blog

博客园 - h2appy

可以使用任何字体的gvim for windows vim编辑二进制文件 数据库连接字符串大全(Database Connection Strings) 在中文下安装PrimeOCR 4.5会出现“Failed open exe”错误 让WordPress注册时不发邮件,直接显示密码 组件的初始化和终止,为什么实现 Dispose 类、组件和控件 ScintillaNet 2.0的中文问题 转帖:使用 Microsoft Visual Studio 2005 时可能遇到的问题 Vmware 6.5.1正式版在Ubuntu 8.10下面运行非常缓慢的解决方法 - h2appy 给控件加上图标,让界面看起来更丰富 开源的.net图表库(A flexible charting library for .NET) 免费的中文OCR软件 转帖:一英文软件安装时出现”Failed to open EXE”问题解决 一款小软件gbridge 7zip美化 转帖:字符编码笔记:ASCII,Unicode和UTF-8 转帖:Endian的由来 字符编码(Character encoding)
改变RichTextBox光标(caret)的形状
h2appy · 2008-12-16 · via 博客园 - h2appy

using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;namespace WindowsApplication1
{
    
public partial class Form1 : Form
    {
        [DllImport(
"user32.dll")]
        
static extern bool CreateCaret(IntPtr hWnd, IntPtr hBitmap, int nWidth, int nHeight);

        [DllImport(

"user32.dll")]
        
static extern bool ShowCaret(IntPtr hWnd);public Form1()
        {
            InitializeComponent();
            richTextBox1.GotFocus 
+= new EventHandler(richTextBox1_GotFocus);
        }
private void richTextBox1_GotFocus(object sender, EventArgs e)
        {
            
this.BeginInvoke(new MethodInvoker(ChangeCaret));
        }
private void richTextBox1_SelectionChanged(object sender, EventArgs e)
        {
            
this.ChangeCaret();
        }
private void richTextBox1_MouseDown(object sender, MouseEventArgs e)
        {
            
this.ChangeCaret();
        }
private void ChangeCaret()
        {
            CreateCaret(
this.richTextBox1.Handle, IntPtr.Zero, 1015);
            ShowCaret(
this.richTextBox1.Handle);
        }
private void richTextBox1_KeyUp(object sender, KeyEventArgs e)
        {
            
this.ChangeCaret();
        }
    }
}