This project requires delivering working source code using the Win32 API directly in C/C++. MFC or another framework / class library is not an option. Your code must be able to provide the screen location of the caret (text cursor) to a window by sending it a window message whenever the caret is made visible, the focus changes or the caret moves in *any* Windows application in Windows 98/ME/2000/XP/2003.
The system *should not* loop around checking for the position of the caret, but if this is *absolutely* necessary then I'll have to live with it.
Note that this is not as easy as it sounds - you can use the GetCaretPos, GetFocus and ClientToScreen API functions after attaching to the input thread of that process (there are samples if you google), but this will not work for tracking the caret in eg. Mozilla's address bar.
The only other requirement is that the code must be fast (the results of it will be being used in a loop), so no waiting around for 10ms for any reason. That bit probably only applies if you are using the polling option, which I've already expressed preference against.
As a hint, you probably want to use a Windows hook to do this. The Windows Magnifier in XP (under AccessoriesAccessibility) has the correct functionality for tracking the text cursor, so if you can work out how they did it, then you are welcome to just provide that code.
Just to emphasise again - this is only native Windows API C/C++ with *no* external dependencies - no libraries, no DLLs, no class libraries and no frameworks. Obviously this is only a small part of a program, so I don't expect the quotes to get too high, although there *may* be other parts of the project that I might be interested in subcontracting at a later stage.