Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I've done something like this in the past. </p> <p>There are two ways that I can think of to do this.</p> <p><strong>With Actions:</strong></p> <p>When using actions it's very easy to follow the UI usage by placing code in the TActionList.OnExecute handler. This event fires off before the individual action executes which allows for you to trace what has happened and when.</p> <p>For Example:</p> <pre><code>procedure TForm1.ActionList1Execute(Action: TBasicAction; var Handled: Boolean); begin WriteToLog(TAction(TBasicAction).Caption); end; </code></pre> <p><strong>Without Actions:</strong></p> <p>If your not using Actions it becomes a little more difficult but not impossible. You create have to create a new unit with a TMenuItem descendant with your logging code in it. Make sure to place your new unit after the MENU unit in the uses clause in every unit that makes use of it. The new descendant has to be called TMenuItem for this to work. Since your essentially reintroducing the same class but with extended functionality.</p> <p>Here is a quick unit I threw together showing a very simple example.</p> <pre><code>unit MenuItemLogger; interface uses Menus; Type TMenuItem = class(Menus.TMenuItem) public procedure Click; override; end; implementation uses windows; { TMenuItem } procedure TMenuItem.Click; begin outputdebugstring(PWideChar(self.Caption)); inherited; end; end. </code></pre> <p>To use the above unit place it as the last unit in the uses clause of any form/DataModule with menus (TMainMenu or TPopupMenu) that you want to trace. If you don't want to trace a particular unit don't include it.</p> <pre><code>uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ActnList, Menus, MenuItemLogger; </code></pre> <p>These two methods are simple and while they do work they probably are not the best solutions. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload