Hello! Is it possible to use MouseProc callback function as a class member function?
private:
LRESULT CALLBACK MouseWndProc(int nCode, WPARAM wParam, LPARAM lParam);
And when I try to pass a MouseWndProc function pointer as the second parameter of the function SetWindowsHookEx:
SetWindowsHookEx(WH_MOUSE, (HOOKPROC)MouseWndProc,
here I get an error: member function must be called or its address taken
[edit]
I changed the code as follows:
class MyClass
{
public:
void MyClass();
void ~MyClass();
static LRESULT CALLBACK MouseWndProc(int nCode, WPARAM wParam, LPARAM lParam);
private:
int x;
int y;
};
LRESULT CALLBACK MyClass::MouseWndProc(int nCode, WPARAM wParam, LPARAM lParam)
{
switch(wParam)
{
case WM_MOUSEMOVE:
{
x = pMouseStruct->pt.x;
y = pMouseStruct->pt.y;
break;
}
}
return CallNextHookEx(hhk, nCode, wParam, lParam);
}
And when I try to compile this code, on this lines:
x = pMouseStruct->pt.x;
y = pMouseStruct->pt.y;
I have got an error:
Member MyClass::x cannot be used without an object
Member MyClass::y cannot be used without an object
How to fix this?
[/edit]