A.M. Hoornweg 144 Posted November 25, 2021 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
Anders Melander 1782 Posted November 25, 2021 I would guess that the override is based on the message number but it should be easy to determine; Just try it. Share this post Link to post
Uwe Raabe 2057 Posted November 25, 2021 (edited) 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 November 25, 2021 by Uwe Raabe 1 1 Share this post Link to post
A.M. Hoornweg 144 Posted November 25, 2021 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