views:

240

answers:

3

Is there any tool that can do this? Just like a website and for the same basic reasons?

UPDATE --- I mean collecting statistics info about an application that I am writing I need to know what options are used most, when, times, etc.

A: 

I assume you are talking about the windows performance counters

Have a look at this link

Use the Windows System Monitor (SYSMON) to see the result

have a look at this link

There is also Prof's Performance Monitoring Components for delphi

Charles Faiga
A: 

Do you need some coverage analysis tool?

Kirill V. Lyadvinsky
+1  A: 

I've done something like this in the past.

There are two ways that I can think of to do this.

With Actions:

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.

For Example:

procedure TForm1.ActionList1Execute(Action: TBasicAction; var Handled: Boolean);
begin
   WriteToLog(TAction(TBasicAction).Caption);
end;

Without Actions:

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.

Here is a quick unit I threw together showing a very simple example.

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.

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.

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ActnList, Menus, MenuItemLogger;

These two methods are simple and while they do work they probably are not the best solutions.

Ryan J. Mills