Results 1 to 2 of 2

Thread: WindowProc within a class

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2001
    Location
    London, England
    Posts
    4

    WindowProc within a class

    hi all

    Im new to api in c++ and am having a problem and cant work it out.

    my code works correctly if i keep my WindowProc function outside of my class which i am using for creating and destroying the window. which is why i would also like to handle messages within the same class however when i do this i get the following error message.

    bvsetup.cpp(104) : error C2440: '=' : cannot convert from 'long (__stdcall BVSetUp::*)(struct HWND__ *,unsigned int,unsigned int,long)' to 'long (__stdcall *)(struct HWND
    __ *,unsigned int,unsigned int,long)'


    here is a snipit of my code



    class BVSetUp
    {

    public:
    BVSetUp();
    BVSetUp(HINSTANCE, HINSTANCE, LPSTR, int);
    ~BVSetUp();
    bool CreateGLWin();


    void KillGLWindow();

    virtual LRESULT CALLBACK WindowProc(HWND , UINT ,WPARAM , LPARAM );

    };





    bool BVSetUp::CreateGLWin()
    {
    ...

    WNDCLASS wc;

    ...

    wc.lpfnWndProc = WindowProc;
    ...
    }


    I am using MSVC++6. Anything and everything will be appriciated


    Thanks

    Zee
    Limitless Potential

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    window procs can't be normal class members since they don't get a this-pointer. You have to use either a global windproc that calls the class wndproc (like in mfc) or a static member function of the class.

    All the buzzt
    CornedBee

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width