在绘制的WinForms一个闪烁的插入符号 [英] Drawing a blinking caret in Winforms

查看:258
本文介绍了在绘制的WinForms一个闪烁的插入符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个自定义的控制,其中大部分类似于一个文本区域。我绘制文本,这正常运行,并且接受输入也可以工作。但我(用户)我猜测左对光标所在,而I型,因为我手工做的一切。
我如何画一个闪烁的插入符号,以显示在那里我目前打字?是否有这样做的标准方式?

I'm developing a custom control, which most resembles a text area. I am drawing text, which works correctly, and accepting input which also works.. But I (the user) am left guessing where the caret is while I type, since I'm doing everything manually. How do I draw a blinking caret to show where I am currently typing? Is there a standard way to do this?

推荐答案

我认为,烦人,对于插入记号没有管理的API。你必须,因此,无论是的PInvoke到Win32函数的插入记号,或者自己实现该功能(如绘画,隐藏着一个闪烁的插入符,当且仅当您的控件具有输入焦点)。

I think that, annoyingly, there is no managed API for Carets. You must, therefore, either PInvoke to the Win32 functions for carets, or, implement that functionality yourself (i.e. painting and hiding a blinking caret, when and only when your control has the input focus).

请参阅 http://stackoverflow.com/questions/609927/custom-caret -for-的WinForms,文本框例如

这篇关于在绘制的WinForms一个闪烁的插入符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆