overriding WndProc

  • Thread starter Thread starter fh1996
  • Start date Start date
F

fh1996

Protected override void WndProc(ref Message m)
{
....
base.WndProc(ref m);
}

When should override the WndProc member of base class?

Can "Parent.WndProc(...)" be used to replace "base.WndProc(...)" in the
following code?

What's the meaning of "parent" in C#?

Why is it needed to call "base.WndProc(ref m);" at the end of the WndProc()?

Thanks!
 
Protected override void WndProc(ref Message m)
{
...
base.WndProc(ref m);
}

When should override the WndProc member of base class?

if this is you who define the base class, you can override also the WndProc
of base class. in any other case it could be difficult. note that in the
above code you do not override the WndProc of the base class but you just
call it.
Can "Parent.WndProc(...)" be used to replace "base.WndProc(...)" in the
following code?

it can be used but it could have no sense at all.
What's the meaning of "parent" in C#?

Parent form of a form F is a Parent window of it (typically: a window that
created F).
Why is it needed to call "base.WndProc(ref m);" at the end of the
WndProc()?

to preserve the functionality of the newly created class. if you do not call
the WndProc from a base class, the newly created class will have only the
functionality that is defined inside it.
 
As i understand it you need to pass the messages you do not handle to your
base class.
Although in the help it says base.WndProc(m) it don't work as i tested this
myself :)
Instead you must use xxx::WndProc(m). Where xxx stands for you class name.
 
Back
Top