Using the optional Object parameter
The CodeSiteEx.TraceMethod routine accepts an optional Object parameter.
If you pass it an object, the method text is evaluated as follows:
if FObj is TComponent then
FMethodText := FObj.ClassName + '(' + TComponent(FObj).Name + ').' +
FMethodText
else
FMethodText := FObj.ClassName + '.' + FMethodText;
Suppose your application has a form named frmMyForm of type TMyForm. There is a button, btnOK, on this form. If you add a TraceMethod call to the button's OnClick event as follows:
procedure TMyForm.btnOKClick(Sender: TObject);
begin
CodeSiteEx.TraceMethod(Self, 'btnOKClick');
// your code goes here...
end;
The CodeSite viewer will receive the following text:
TMyForm(frmMyForm).btnOKClick