Jump to content
A.M. Hoornweg

inherited dynamic message handlers

Recommended Posts

Hello all,

 

I have a question regarding dynamic methods in Delphi that handle Windows messages. The documentation is not clear about this.  Suppose I declare a Windows message handler in my form like 

 

 procedure WMNCCreate (var Message: TWMNCCreate); message WM_NCCREATE;

 

with a trivial implementation like

procedure WMNCCreate(var Message: TWMNCCreate); 
begin
  inherited;
end;

 

how is the inherited() call resolved by Delphi? Is it resolved by method name or by message number?

In other words, does inherited() call an ancestor's method having the name WMNCCreate,  or does it call any method that handles message number WM_NCCreate regardless of the method's name ?

 

 

 

 

Share this post


Link to post

The docs are pretty clear about it (Message Methods) :

Quote

A message method does not have to include the override directive to override an inherited message method. In fact, it does not have to specify the same method name or parameter type as the method it overrides. The message ID alone determines to which message the method responds and whether it is an override.

 

Edited by Uwe Raabe
  • Thanks 1

Share this post


Link to post
27 minutes ago, Uwe Raabe said:

The docs are pretty clear about it (Message Methods😞

 

 

Ah, I've overlooked that! Thanks! 

 

One of the reasons I asked is because many of these message handlers in Vcl.Forms are declared  private.  But apparently, the keyword "private" is meaningless for message methods if they're resolved by number.

 

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×