I have written a DLL that intercepts calls to DrawTextA to read text sent by
another program to the screen, and to get the text coordinates. My problem
is that the coordinates passed to DrawTextA() are relative to the specific
device context, and I need the screen coordinates.
DrawTextA must use the HDC parameter to determine the screen coordinates at
which the text is to be printed – it has no other way of knowing. So how can
I find out? I have tried calling WindowFromDC, but it returns NULL. Calls to
GetCurrentPositionEx, GetViewportOrg and GetWindowOrg give inconsistent and
apparently meaningless results, and passing their output to LPtoDP or DPtoLP
doesn’t help. What should I do?