Skip to main content
GameDev.net gamedev.net
🔒 Locked

function pointer conversion

Started by conman Oct 4, 2005 at 11:54 AM 0 replies 950+ views
Original Post
conman
conman
Hi, I try to pass a member-function of a C++ class to a Win32-API function.

struct HookData {
  ...
  LRESULT HookCallback(int code, WPARAM wparam, LPARAM lparam);
};

LRESULT HookData::HookCallback(int code, WPARAM wparam, LPARAM lparam) 
{ ... }

// later in the source:
HookData *pHook = new HookData();
SetWindowsHookEx(hookID, pHook->HookCallback, g_AppInstance, threadID);


in the last line this compiler error occurres: error C2664: 'SetWindowsHookExA' : cannot convert parameter 2 from 'LRESULT (int,WPARAM,LPARAM)' to 'HOOKPROC' now HOOKPROC is defined as:

typedef LRESULT(*HOOKPROC)(int, WPARAM, LPARAM);
So I am not sure what happend: Is it maybe a problem to provide a member-function to that API-function? Or do I need a prefix like CALLBACK/__stdcall or something like that? thanks, Constantin
conman
conman
Hmm, I found this explanation.
It seems to be a problem to do it at all... :(

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.