如何确定 Windows 中的文本光标位置 [英] How to Determine Text Cursor Position in Windows

查看:20
本文介绍了如何确定 Windows 中的文本光标位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

确定当前活动文本输入光标的屏幕坐标的最佳方法是什么?

What is the best way to determine the screen co-ordinates of the currently active text input cursor?

我需要将其用于内嵌音译程序,以便在输入文本时向用户显示一些建议选项.

I need this for an in-line transliteration program so that I can display some suggestions options to the user as the text is entered.

推荐答案

首先将线程输入附加到活动应用程序 (AttachThreadInput).然后使用 GetCaretPos<获取插入符号的位置/代码>.位置在客户端坐标,调用GetFocus 获得带有插入符号的窗口的句柄,然后使用 ClientToScreen.最后通过再次调用 AttachThreadInput 来分离线程输入.

First attach the thread input to the active application (AttachThreadInput). Then get the caret's position with GetCaretPos. The position is in client coordinates, call GetFocus to have the handle to the window that has the caret, then convert the coordinates to screen coordinates with ClientToScreen. Finally detach the thread input by calling again AttachThreadInput.

这篇关于如何确定 Windows 中的文本光标位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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