Re: Inherited explained



Anonymous wrote:

procedure WMSysCommand(var Msg: TWMSysCommand); message
WM_SYSCOMMAND;

procedure TForm1.WMSysCommand;
begin
if (Msg.CmdType = SC_CLOSE) then begin // X button clicked in
upper right hand corner of program interface
...do what needs to be done
end
else
inherited; //inherited means to do what you would have
otherwise done
end;

"inherited;" on its own means here: call WMSysCommand(Msg) in the
ancestor class, but only if there is such a method in that class.
Otherwise, ignore the call.

Now "inherited WMSysCommand(Msg);" would also have been possible, but
that would cause a compiler error if the ancestor does not have a
WMSysCommand.

--
Rudy Velthuis http://rvelthuis.de

"It is only those who have neither fired a shot nor heard the
shrieks and groans of the wounded who cry aloud for blood...
War is hell." -- General William Tecumseh Sherman
.


Quantcast