deriving a class with a wndproc

This is a discussion on deriving a class with a wndproc within the Windows Programming forums, part of the Platform Specific Boards category; ok, one last question: if my base class has a static wndproc which then calls a virtual wndproc, how does ...

  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?
    benforbes@optusnet.com.au
    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, 10: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, 06:18 AM
  5. Abstract class problem
    By VanJay011379 in forum C++ Programming
    Replies: 9
    Last Post: 07-31-2002, 01:30 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21