Search code examples
delphidelphi-xe2code-completion

Code-completion doesn't list message handlers


When working on an old project in Delphi XE2, the code-completion window that pops up after CTRL-SPACE does not list message handlers like Delphi 7 did:

Screen shot

In the screen shot above, the WM*** routines are missing. Why is that?


Solution

  • The unit names in the uses clause are not fully qualified. Include the namespace for each unit and then the necessary types for the method declarations are found to let the code-completion pop-up window return all members.

    For instance:

    • procedure WMActivate(var Message: TWMActivate); will not be shown when Winapi.Messages.TWMActivate isn't found,
    • procedure CMActivate(var Message: TCMActivate); will not be shown when Vcl.Controls.TCMActivate isn't found.

    Solution:

    uses
      Winapi.Windows, Winapi.Messages, System.Classes, Vcl.Controls, Vcl.Forms,
      Vcl.Graphics;
    

    enter image description here

    Exactly why this is, I do not dare to explain. Especially since all other methods (not being message handlers) are shown whether the concerning unit is fully qualified or not. But it does not really matter; when working in Delphi 2009 or above, you should get accustomed to use fully qualified unit names nevertheless.