Jump to content
  • Advertisement
Sign in to follow this  
Koen VB

Making window procedure a class member

This topic is 4625 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm making a class that encapsulates a window. Now I want to make the window procedure a class member, like this: class CWindow { ... LRESULT CALLBACK WndProc(HWND HWindow, UINT Msg, WPARAM wParam, LPARAM lParam); } This function is used during the creation of the window class. WinClass.lpfnWndProc = (WNDPROC)WndProc; This results in the following error message: Error E2235: Member function must be called or its address taken in function CWindow::CWindow(...) One thing I tried was making the WndProc function static. This worked, but the problem was that you could no longer access non-static members of the class, while I really need access to them. Is there a way to use a member function of a class as a window procedure without making it static?

Share this post


Link to post
Share on other sites
Advertisement
You can't assign a pointer to a non-static member function to a pointer to a normal function. The usual method to handle this is to assign a static or normal function to the windows procedure and use GetWindowLong() or GetWindowLongPtr() to a pointer from the GWL_USERDATA of the windows class. See this article for more details.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!