Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I am creating a screen manager for a game I am creating. The fundamental operation of the screen manager is based on a pointer to a base class that screen objects inherit. Here is the declaration:

class screen_base
{
friend class screen_manager;
public:
    virtual bool init()=0;
    virtual bool deinit()=0;
    virtual bool render()=0;
    virtual bool update()=0;
    virtual void event_handle(HWND, UINT, WPARAM, LPARAM)=0;
protected:
    app_data win_data;
    unsigned int state;
    float fim;
};


whenever I try to call the event_handle() function inside the window procedure (from the pointer) The program just ends execution returning 0, the window is never even created. I tried putting the call into a separate function and calling that in the window procedure but that didn't work either.

Is there any way to call this function?
Posted

1 solution

I note your handle is a void function.
The window procedure is instead an LRESULT returning function.

Unfortunately, some nested messages are supposed to return meaningful LRESULT values to the calling ones.
By throwing away the result, at a certain point you end up by returning "false" to WM_NCCREATE, that makes all the creation process to fail.

Just consider a handle with proper prototype LRESULT handle(HWND,UINT,WPARAM,LPARAM) and manage the return value properly.
 
Share this answer
 
Comments
Dalek Dave 22-Nov-10 4:05am    
Good Answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900