I've seen a program that can go through all the text in a window and highlight a certain word (www.fanix.com).


Based on that, I have a question. If I am typing something, I can always intercept what's being typed and the if I want to modify that word or act upon a certain word, I can send keyboard stroke back to Windows. However, if I want to display a listbox where the caret is in the current window (whichever window happens to be active) like intellisense, except this is Windows wide and concerns nothing of developer tools...

is there an api or set of API's I can use to determins what the screen cordinates are of the caret (no matter what window it's in) and display a listbox at thos coordinates? Other people have done similar things I just don't know how to do it... I can't know anything about the application, because the program I'm making is supposed to work no matter where you're typing in Windows... Except IE, which disables all my keyboard hooks when it starts...


Thanks,
Shawn
Posted on 2001-10-18 15:27:24 by _Shawn
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/caret_44mr.asp

Use GetCaretPosition. It will return x & y in a POINT struct. On an unrealated note, I don't know why I can't reproduce the error that you're getting with IE. Is it possible your hooks are not system-wide? If not, why are you afraid to use the WH_KEYBOARD_LL hook type? I'm using it and IE dosen't give me those kinds of obstacles. Just trying to relieve your headache about it.
Posted on 2001-10-18 16:02:26 by lackluster
Hi _Shawn

In a Keyboard hook I use this to get caret pos.



KeybProc proc nCode:DWORD,wParam:DWORD,lParam:DWORD
mov eax,nCode
.if ax==HC_ACTION
invoke GetCaretPos,ADDR lpPoint
.if eax
.
.
.
.
.endif
.endif
invoke CallNextHookEx,hKHook,nCode,wParam,lParam
xor eax,eax
ret

KeybProc endp


Works well with IE
KetilO
Posted on 2001-10-18 16:04:04 by KetilO
Does that return the caret position relative to the window, or the entire screen? So that if I was to use the coordinates (from an external program) it'll help me place my list box exactly where I want it, irrespective of the window with the current caret?

As for the hooks, I'll try WH_KEYBOARD_LL. It is system-wide only until Internet Explorer opens up then I lose my hook. No IE, no problem.

I would send my source for your viewing pleasures, but I'm programming it in Delphi. I'll do assembly later. But I need to prove my concept rapidly, first.

Thanks,
_Shawn
Posted on 2001-10-18 16:47:31 by _Shawn
Hi _Shawn

GetCaretPos is in client coordinates.
I also has a CBT_HOOK with HCBT_SETFOCUS and then use ClientToScreen.

KetilO
Posted on 2001-10-18 17:53:08 by KetilO