Hello,
I need to get screen coordinates of caret position within text editor in VS 2010.
Note, that is it not a .NET project (it is ATL), so it would be fine if it would work without need to create interop library.
Does anything accessible from native C++ Addin provide a way to get information I need?
Seems that WPF does not cooperate with Win32 API :(
I have tried following Win32 API calls without success:
HWND hwnd = ::GetForegroundWindow(); DWORD remoteThreadId = ::GetWindowThreadProcessId(hwnd, NULL); DWORD currentThreadId = ::GetCurrentThreadId(); ::AttachThreadInput(remoteThreadId, currentThreadId, TRUE); HWND focused = ::GetFocus(); POINT pnt; BOOL caret = ::GetCaretPos(&pnt) && ::ClientToScreen(focused, &pnt); ::AttachThreadInput(remoteThreadId, currentThreadId, FALSE);
and also:
HWND hwnd = ::GetForegroundWindow();
DWORD remoteThreadId = ::GetWindowThreadProcessId(hwnd, NULL);
GUITHREADINFO thr_info;thr_info.cbSize = sizeof(thr_info);
if (GetGUIThreadInfo(remoteThreadId, &thr_info))
{
...
}
Thanks in advance.