mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-17 00:29:31 +01:00
codetools: fixed example addeventmethod
git-svn-id: trunk@42861 -
This commit is contained in:
parent
71ce8192f2
commit
012a67a370
@ -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);
|
||||||
|
|||||||
@ -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);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user