Click here to Skip to main content
14,667,289 members
Rate this:
Please Sign up or sign in to 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

Rate this:
Please Sign up or sign in to vote.

Solution 1

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.
   
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, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100