How to Determine Text Cursor Position in Windows

你说的曾经没有我的故事 提交于 2020-01-12 16:49:09

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/5087244/how-to-determine-text-cursor-position-in-windows

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!