How would I call that?PHP Code:void (*Function(HWND hwnd);
I'm trying to do like WNDCLASSEX does..... :-\ no luck....
Printable View
How would I call that?PHP Code:void (*Function(HWND hwnd);
I'm trying to do like WNDCLASSEX does..... :-\ no luck....
should be
void (*Function)(HWND hwnd);
and you call it like
Function(somehwnd);
Heres my code: (Its an imitation MFC thing)
I excluded all the irrelevant parts
PHP Code:class Window
{
public:
void (*OnDestroy)(HWND hwnd);
};
NOTE! THAT IS NOT IN THE CLASS!!!!PHP Code:LRESULT CALLBACK WindowProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
switch(msg)
{
case WM_DESTROY:
Window::OnDestroy(hwnd);
//ERROR OCCURS HERE
break;
default:
return DefWindowProc(hwnd,msg,wParam,lParam);
}
return(0);
}
PHP Code:void Cls_OnDestroy(HWND hwnd)
{
PostQuitMessage(0);
}
Error: C2064: term does not evaluate to a functionPHP Code:w.OnDestroy=Cls_OnDestroy;
Any ideas?
call it like:
w.OnDestroy(hwnd);
or change OnDestroy to static
Reason for the error:
Your 'OnDestroy' function pointer is a member variable of each instance of your class. It only has meaning in the context of an object which is an instance of your class; it doesn't mean anything when it's just associated with the class itself, not an instance of that class.
You have used the scope resolution operator, ::, to resolve the scope of your function pointer (ie to acquire the function pointer so you can call it). However, this will only give you access to static class members, since non-static class members have no meaning without an associated instance of that class.
As Kedaman suggests, the solutions are to either make the function pointer static (the same variable is available to all instances of a class) and continuing to use the scope resolution operator, ::, as you do at the moment, or alternatively to instantiate an object of the class and assign the function pointer in that object. You can then use that object to get to your member function pointer, and you can call it using the direct member access operator (the dot . ).
Looks like you want to do it the latter way, by using the dot instead of :: :)
Ahhh! I get it now!!!!
Thanks!
Now I remember that from my certification course thingy (not finished yet)