Thread: problem

  1. #1
    xfish
    Guest

    Angry problem

    i have just started to write an window class... blah blah
    the class looks like this:

    class WINDOW
    {
    private:
    WNDCLASS WndClass;
    public:
    void Create(/*some stuff*/);

    LRESULT CALLBACK WndProc(HWND hWnd,UINT message,WPARAM wParam, LPARAM lParam);

    // and some more stuff
    };

    and here is the problem in create:

    void Create(/*some stuff*/)
    {
    // some ****
    WndClass.lpfnWndProc = /*some thing to set the correct wndproc*/
    }

    if i move WndProc outside the class all works fine and i only need
    to do like this: WndClass.lpfnWndProc = WndProc;
    but when WndProc is in my class msvc complains about that
    iam doing an illegal type cast.

    isnt this possible to do?

    please need help

    //xfish

  2. #2
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    You'll have to make your WndProc a static method. This static function can then call a non-static version of your WndProc if you pass the 'this' pointer in as the extra window creation data in your call to CreateWindow(). You can then extract the 'this' pointer in your static WndProc using GetWindowLong() and use it to call the non-static version (passing the parameters along).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help understanding a problem
    By dnguyen1022 in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2009, 04:21 PM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  3. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  4. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  5. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM