Winforms:插入符号位置的屏幕位置

发布于 2024-07-25 02:36:43 字数 41 浏览 1 评论 0原文

如何找到标准 Winforms TextBox 的插入符的屏幕位置?

How can I find the screen position of the caret for a standard Winforms TextBox?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浅紫色的梦幻 2024-08-01 02:36:43

您只能使用本机互操作来完成此操作: GetCaretPos

[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool GetCaretPos(out Point lpPoint);

You can do it only with native interop: GetCaretPos

[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool GetCaretPos(out Point lpPoint);
北凤男飞 2024-08-01 02:36:43

我一直在使用 TextBox.GetPositionFromCharIndex 函数。 它给出相对于文本框左上角的坐标。

I have been using the TextBox.GetPositionFromCharIndex function. It gives coordinates relative to the top left of the the TextBox.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文