如何显示光标聚焦的WinForms文本框/ RichTextBox的? [英] How to show cursor in unfocused WinForms TextBox/RichTextBox?
本文介绍了如何显示光标聚焦的WinForms文本框/ RichTextBox的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要显示光标在RichTextBox控件的WinForms应用程序,即使它没有焦点。我怎样才能做到这一点?我为WPF(只找到了办法<一href="http://stackoverflow.com/questions/642498/how-to-keep-wpf-textbox-selection-when-not-focused">How保持WPF文本框选择时不集中?)
I need to show cursor in RichTextBox control in WinForms application even when it's not in focus. How can I do this? I found only the way for WPF ( How to keep WPF TextBox selection when not focused?)
推荐答案
您可以使用WinAPI的。
You can use WinAPI ..
[DllImport("user32.dll", EntryPoint = "ShowCaret")]
public static extern long ShowCaret(IntPtr hwnd);
[DllImport("user32.dll", EntryPoint = "HideCaret")]
public static extern long HideCaret(IntPtr hwnd);
和调用ShowCaret只要你想
and call ShowCaret whenever you want
这篇关于如何显示光标聚焦的WinForms文本框/ RichTextBox的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文