inheritance - Delphi how to implement baseclass event? -
i have abstract delphi xe form acts base class family of forms used in application. trying figure out best way make function (on f1 keypress) opens wiki-page active form.
i'd function implemented @ base-class level , call when user presses f1 need advice on how in smart way. put keydown-event on base form gets overwritten if subform receives own keydown, @ point have manually call basekeydown. obviously, not optimal.. there way ensure catch f1 keypress @ baseclass level, random overloads nonwithstanding?
i running delphi xe on windows 7
you should override keydown
method in base form class.
type tbaseform = class(tform) protected procedure keydown(var key: word; shift: tshiftstate); override; end; procedure tbaseform.keydown(var key: word; shift: tshiftstate); begin // processing here // ... inherited; // call inherited method call onkeydown if assigned end;
this default implementation of kewdown method calls onkeydown
events
procedure twincontrol.keydown(var key: word; shift: tshiftstate); begin if assigned(fonkeydown) fonkeydown(self, key, shift); end;
Comments
Post a Comment