Class+WNDPROC
-
Hi i have a class that makes a custom window,and at the WNDCLASS structure at
wc.lpfnWndProc=(WNDPROC)&CustomWindow::WndProc;
i get the error:error C2440: 'type cast' : cannot convert from 'LRESULT (__stdcall CustomWindow::*) (HWND,UINT,WPARAM,LPARAM)' to 'WNDPROC' There is no context in which this conversion is possible
worked before in non class app aswc.lpfnWndProc=WndProc;
if someone could point out the problem or share a solution, it would be very apriciated. -
Hi i have a class that makes a custom window,and at the WNDCLASS structure at
wc.lpfnWndProc=(WNDPROC)&CustomWindow::WndProc;
i get the error:error C2440: 'type cast' : cannot convert from 'LRESULT (__stdcall CustomWindow::*) (HWND,UINT,WPARAM,LPARAM)' to 'WNDPROC' There is no context in which this conversion is possible
worked before in non class app aswc.lpfnWndProc=WndProc;
if someone could point out the problem or share a solution, it would be very apriciated.To use a member function (method) as a callback like this, the method needs to be declared static. That's because the OS knows nothing of your C++ object so it can't pass the implicit "this" pointer that gets passed to non-static class methods. Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
-
To use a member function (method) as a callback like this, the method needs to be declared static. That's because the OS knows nothing of your C++ object so it can't pass the implicit "this" pointer that gets passed to non-static class methods. Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
-
Could you be more specific because im a noob :D should i put static in front of my method declaration ? Thanks for putting up with me in advance :P
See 6.1 Why can't I use a member function as a callback?[^] [33.2] How do I pass a pointer-to-member-function to a signal handler, X event callback, system call that starts a thread/task, etc?[^]
--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ Dunder-Mifflin, this is Pam.
-
Could you be more specific because im a noob :D should i put static in front of my method declaration ? Thanks for putting up with me in advance :P
shaderx wrote:
should i put static in front of my method declaration ?
offcourse ! :cool:
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You