Board index » delphi » Method 'Click' hides virtual method

Method 'Click' hides virtual method

Can any explain why I get the compiler message:

'Warning: c:\program files\borland\delphi
3\source\vcl\ComCtrls.pas(1271):'Method 'Click' hides virtual method of base
type TControl'

I am using only Delphi 3 native controls.

Thanks in advance,
Charles Green

 

Re:Method 'Click' hides virtual method


Hi Charles,

Quote
> 'Warning: c:\program files\borland\delphi
> 3\source\vcl\ComCtrls.pas(1271):'Method 'Click' hides virtual method of base
> type TControl'

> I am using only Delphi 3 native controls.

The ComCtrls unit contains a set of delphi controls used in the IDE.  What it
seems to me is that you have "C:\program files\borland\delphi 3\source\vcl"
in your library path somewhere.  What is happening is that you maybe using
components that are part of this unit and the compiler automatically searches
all units used in your application by looking in its library path to see if
they need to be recompiled (I think it determines this by the date and time
stamp). Usually this directory is not included in the library path.  It may
have been added on accident.  Remove this directory from your library path
and everything should compile without the warning.

I hope this helps,
Earl Reddell
Res-cue (Resourceful Components for User Ease!)
Check out our web site: http://www.res-cue.com

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    

Re:Method 'Click' hides virtual method


Try assigning an event to the OnClick event rather than overriding Click
directly.

David

Quote
Charles Green <cbgr...@mindspring.com> wrote in message

news:7gq96h$dnc$1@nntp3.atl.mindspring.net...
Quote
> Can any explain why I get the compiler message:

> 'Warning: c:\program files\borland\delphi
> 3\source\vcl\ComCtrls.pas(1271):'Method 'Click' hides virtual method of
base
> type TControl'

> I am using only Delphi 3 native controls.

> Thanks in advance,
> Charles Green

Re:Method 'Click' hides virtual method


In article <7gq96h$dn...@nntp3.atl.mindspring.net>, "Charles Green"

Quote
<cbgr...@mindspring.com> writes:
>Can any explain why I get the compiler message:

>'Warning: c:\program files\borland\delphi
>3\source\vcl\ComCtrls.pas(1271):'Method 'Click' hides virtual method of base
>type TControl'

Click is a virtual method which means that if you call it with an "override"
keyword you can call the original by using "inherited Click;" as a call.

Because you did not use the "override" keyword in your declaration, you are
re-declaring Click as a static method which hides the ancestor and prevents you
calling it.

Virtual methods allow one to build additional descendant behaviour onto
ancestors (ie the OO way). By re-declaring an ancestral method as a static
method you are breaking the inheritance chain, and Delphi is warning you about
it. It may not matter in your particular usage, but as a general practice it is
a bad habit.

Alan Lloyd
alangll...@aol.com

Other Threads