Thread: deriving a class with a wndproc

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

    deriving a class with a wndproc

    ok, one last question: if my base class has a static wndproc which then calls a virtual wndproc, how does my derived class use a wndproc? i mean, does it override the static or virtual wndproc, and how should it itself be declared?
    [email protected]
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    >>how does my derived class use a wndproc? i mean, does it override the static or virtual wndproc, and how should it itself be declared?<<

    In your static wndproc you cast this to your base class pointer which has the virtual wndproc. In each derived class that needs one you declare and define that virtual wndproc (you only need to declare it virtual once but it's clearer, to me anyway, to repeat the virtual keyword in derived class wndprocs).

    The reason you have a virtual fn is because it can be overriden in derived classes; the static wndproc is, as the name implies, 'static'.

    Whichever virtual fn is currently in scope gets called but you can override this by using scope resolution ie 'BaseClass::VirtualWndProc' rather than just 'VirtualWndProc' but only if you need to.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Inherite nonvirtual class functionality
    By DrSnuggles in forum C++ Programming
    Replies: 2
    Last Post: 04-30-2009, 01:52 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. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. structure vs class
    By sana in forum C++ Programming
    Replies: 13
    Last Post: 12-02-2002, 07:18 AM