First of all.... you are calling GetDC but are never calling ReleaseDC.
bad bad bad. Be sure to call ReleaseDC before you are done.
Secondly, what's the point of GetCursorPos on line 21? You never use it.
Then... to answer your actual question:
- GetDC gives you the DC of a window's
client area. The client area is the main part of the window that the program draws its contents to. This does not include the window border, menu bar, title bar, status bar, etc.
- GetWindowRect gives you the
window rectangle. The window includes
all parts of the window... including the title bar, menu bar, etc, etc.
So your coordinate conversion code is wrong.
What you want is Client -> Screen coordinates. Fortunately, WinAPI offers a very simple ClientToScreen function, for just this purpose:
http://msdn.microsoft.com/en-us/library/windows/desktop/dd183434%28v=vs.85%29.aspx
1 2 3 4 5 6 7 8 9
|
// assuming i,j have the coords you want:
POINT cursor;
cursor.x = i;
cursor.y = j;
ClientToScreen(lTable, &cursor);
SetCursorPos( cursor.x, cursor.y );
|