codetools: fixed example addeventmethod

git-svn-id: trunk@42861 -
This commit is contained in:
mattias 2013-09-18 15:03:58 +00:00
parent 71ce8192f2
commit 012a67a370
2 changed files with 5 additions and 8 deletions

View File

@ -29,7 +29,7 @@ program AddEventMethod;
uses uses
Classes, SysUtils, CodeCache, CodeToolManager, SimpleUnit1, FileProcs, Classes, SysUtils, CodeCache, CodeToolManager, SimpleUnit1, FileProcs,
CodeToolsConfig, CodeCompletionTool, ExtCtrls, Interfaces; CodeToolsConfig, CodeCompletionTool;
const const
ConfigFilename = 'codetools.config'; ConfigFilename = 'codetools.config';
@ -45,12 +45,9 @@ begin
if Code=nil then if Code=nil then
raise Exception.Create('loading failed '+Filename); raise Exception.Create('loading failed '+Filename);
// Example 1: add a method compatible to TTabChangingEvent // Example 1: add a method compatible to TNotifyEvent
// TTabChangingEvent is used in ComCtrls, but defined in ExtCtrls.
// The codetools will search TTabChangingEvent and will add ExtCtrls to the
// uses section.
if CodeToolBoss.CreatePublishedMethod(Code,'TForm1','NewMethod', if CodeToolBoss.CreatePublishedMethod(Code,'TForm1','NewMethod',
typeinfo(TTabChangingEvent),false,'ComCtrls') then typeinfo(TNotifyEvent),false,'Classes') then
begin begin
writeln('Method added: '); writeln('Method added: ');
writeln(Code.Source); writeln(Code.Source);

View File

@ -5,10 +5,10 @@ unit AddEventExample;
interface interface
uses uses
Classes, SysUtils, Forms, Controls, ComCtrls; Classes, SysUtils;
type type
TForm1 = class(TForm) TForm1 = class(TComponent)
PageControl1: TPageControl; PageControl1: TPageControl;
procedure Button1Click(Sender: TObject); procedure Button1Click(Sender: TObject);
procedure CheckBox1Change(Sender: TObject); procedure CheckBox1Change(Sender: TObject);