Thread: subclassing a wndproc from within a class

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401

    subclassing a wndproc from within a class

    yep, i'm back with more class based problems. this time, ive made a class that encapsulates an edit control and makes it easy to use blah blah. my window procedure is still static, because i guess those rules still apply about things existing at certain times and this pointers and all that crap. anyway, inside the edit window procedure, there is no WM_NCCREATE message where i can retrieve a pointer to the class like i did with my other application class. so therefore i have no way to access any member functions or data members. help me, im stuck again!

    Code:
    class cEdit
    {
    public:
        WNDPROC wpProc;
        static LRESULT CALLBACK EditProc(...);
        cEdit();
    };
    
    cEdit::cEdit()
    {
        HWND hwnd=CreateWindowEx(...,(void *)this);
        wpProc=(WNDPROC)SetWindowLong(hwnd,GWL_WNDPROC,(LONG)EditProc);
    }
    
    LRESULT CALLBACK cEdit::EditProc(...)
    {
        cEdit *ce;
        //there's code here to check whether pointer to class is stored yet
        //and if so, store it in cEdit *ce
        return CallWindowProc(ce->wpProc,...);
    }
    the error message is an access violation on the CallWindowProc command, obviously because it is called at some stage before there is a valid pointer to put into ce. Since i'm using an edit control, and i get no WM_NCCREATE message, how am i supposed to retrieve the necessary pointers to make things work?
    Last edited by bennyandthejets; 01-04-2003 at 07:34 AM.
    [email protected]
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 11:03 PM
  3. Replies: 8
    Last Post: 10-02-2005, 12:27 AM
  4. structure vs class
    By sana in forum C++ Programming
    Replies: 13
    Last Post: 12-02-2002, 07:18 AM