Reputation: 21
I would like to develop a program which ID's a card as it is played in another running program such as a poker or hearts game or whatever. I'm starting by trying to get the information I need on that game program which is already running, and I'm having problems right from the start. I'm running MSVC++ 2013 and developing an MFC application. Right now I'm playing with the Hearts game and here's the code:
HWND hwnd = FindWindowA(NULL, "Hearts");
if (hwnd == NULL)
{ /* window not found*/
}
else
{ /* window was found */
RECT rect;
GetWindowRect(hwnd, &rect);
int width = rect.right - rect.left;
int height = rect.bottom - rect.top;
}
So I get hwnd just fine and the code works depending on whether I have Hearts open or not. But the line GetWindowRect(hwnd, &rect);
won't compile saying
"error C2660: 'CWnd::GetWindowRect' : function does not take 2 arguments".
There is a GetWindowRect
function which only has the rect argument, but gets the properties of the program window I'm working on. There is lot's of documentation on GetWindowRect
which shows the two arguments as above, but how do I invoke that subroutine?
Upvotes: 2
Views: 151
Reputation:
As you are inside an MFC window class, you are calling the CWnd::GetWindowRect
function - you want to call the one in the Win32 API, so:
::GetWindowRect(hwnd, &rect);
where the ::
scope resolution operator (without a namespace or class name on the left-hand side) says to call the function in the global scope.
Upvotes: 5