Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

leandro

C++ and WIN32 API's WNDPROC

This topic is 5294 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 trying to make a class that contains a callback message handler function as a member. The problem is I cann''t convert it to a WNDPROC to use it as a Window''s callback function. I mean: class myclass { public: LRESULT CALLBACK MsgHandler(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam); } void myfunction(WNDPROC MsgHandler) {} void winmain(...) { myclass myobject; myfunction(myobject.MsgHandler); //<-- Error!!!; //or myfunction((WNDPROC)myobject.MsgHandler); // Error !!! }

Share this post


Link to post
Share on other sites
Advertisement
This might be completely wrong since I might have missunderstod your problem. But anyway, declaring your MsgHandler function as static should solve the problem.

class myclass {
public:
static LRESULT CALLBACK MsgHandler(HWND hwnd, UINT msg,
WPARAM wparam, LPARAM lparam);
}

LRESULT CALLBACK myclass::MsgHandler( HWND hw... )
{

}

The Lord says He can get me out of this mess, but He''s pretty sure you''re fucked.
- Stephen (Braveheart)

Share this post


Link to post
Share on other sites
Making your WNDPROC static should solve the problem. Remember to use
myfunction(myobject::MsgHandler);
instead, since it''s static.

Share this post


Link to post
Share on other sites
The answer is correct but the problem is that inside the
class myclass there are non static objects that get called from
whithin the MsgHandler. I could do those objects static too, but I want to know if there is another solution.

Share this post


Link to post
Share on other sites
One solution: use a static WndProc that get's the actual pointer to the window object (either using a map or storing the pointer in the window data). then you can call the non static method. But you should use the forum's search function, this question has been asked several times.

[edited by - VolkerG on May 22, 2004 3:15:07 AM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!