Re: Inherited explained



Rob Kennedy wrote:

Rudy Velthuis wrote:
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.

In this case, it doesn't necessarily mean to call WMSysCommand.
Rather, it means to call the next-less-derived method that's also
marked with "message wm_SysCommand."

That is true for message handlers indeed. Not the name is searched, but
the same slot in the dynamic method table. But we can generally assume
it will also be called WMSysCommand, if people followed the tradition.
<g>

--
Rudy Velthuis http://rvelthuis.de

"RAM /abr./: Rarely Adequate Memory." -- From the Jargon File
.


Quantcast