home *** CD-ROM | disk | FTP | other *** search
- unit UDemo;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, StdCtrls,
- Forms, Dialogs,
- XDKMain, // added to call XDK initialization/deinitialization functions
- XDKNotif, XDKMenu, XDKExpt, XDKSnips, XDKGen,
- Proxies,
- DsgnIntf,
- EditIntf; // added to work with TIFormInterface, etc
-
- type
- TDemoDataModule = class(TDataModule)
- xdkAddInMenu1: TxdkAddInMenu;
- AddInMenu: TxdkAddInMenuItem;
- CheckItem: TxdkAddInMenuItem;
- LineItem1: TxdkAddInMenuItem;
- RadioItem1: TxdkAddInMenuItem;
- RadioItem2: TxdkAddInMenuItem;
- RadioItem3: TxdkAddInMenuItem;
- DisabledItem: TxdkAddInMenuItem;
- TestHierarchy: TxdkAddInMenuItem;
- Item1: TxdkAddInMenuItem;
- Item2: TxdkAddInMenuItem;
- Item3: TxdkAddInMenuItem;
- Item4: TxdkAddInMenuItem;
- Item5: TxdkAddInMenuItem;
- Item6: TxdkAddInMenuItem;
- BarItem: TxdkAddInMenuItem;
- DEMOItem: TxdkAddInMenuItem;
- xdkStandardExpert1: TxdkStandardExpert;
- xdkRepositoryExpert1: TxdkRepositoryExpert;
- UnitSnippet: TxdkSnippet;
- UnitCreator: TxdkModuleCreator;
- FormSnippet: TxdkSnippet;
- FormCreator: TxdkModuleCreator;
- DMSnippet: TxdkSnippet;
- DMCreator: TxdkModuleCreator;
- BtnFormCreator: TxdkModuleCreator;
- BtnFormSnippet: TxdkSnippet;
- procedure CheckItemClick(Sender: TObject);
- procedure xdkRadioItemClick(Sender: TObject);
- procedure xdkTestClickItemClick(Sender: TObject);
- procedure DEMOItemClick(Sender: TObject);
- function UnitCreatorSourceWriting(UnitIdent, FormIdent,
- AncestorIdent: String): String;
- function FormCreatorSourceWriting(UnitIdent, FormIdent,
- AncestorIdent: String): String;
- function DMCreatorSourceWriting(UnitIdent, FormIdent,
- AncestorIdent: String): String;
- function BtnFormCreatorSourceWriting(UnitIdent, FormIdent,
- AncestorIdent: String): String;
- procedure BtnFormCreatorFormCreated(Sender: TObject;
- IForm: TIFormInterface);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
-
- var
- DemoDataModule: TDemoDataModule;
-
- implementation
-
- uses
- FDemo;
-
- {$R *.DFM}
-
- procedure TDemoDataModule.CheckItemClick(Sender: TObject);
- begin
- TxdkAddInMenuItem(Sender).Checked:=not TxdkAddInMenuItem(Sender).Checked;
- if TxdkAddInMenuItem(Sender).Checked then
- TxdkAddInMenuItem(Sender).Caption:='Checked'
- else
- TxdkAddInMenuItem(Sender).Caption:='Unchecked';
- end;
-
- procedure TDemoDataModule.xdkRadioItemClick(Sender: TObject);
- begin
- TxdkAddInMenuItem(Sender).Checked:=true;
- end;
-
- procedure TDemoDataModule.xdkTestClickItemClick(Sender: TObject);
- begin
- ShowMessage('Menu item clicked !');
- end;
-
- procedure TDemoDataModule.DEMOItemClick(Sender: TObject);
- begin
- // calling DemoForm with 'Steps'
- DemoForm:=TDemoForm.Create(nil);
- DemoForm.ShowModal;
- DemoForm.Free;
- end;
-
- function TDemoDataModule.UnitCreatorSourceWriting(UnitIdent, FormIdent,
- AncestorIdent: String): String;
- begin
- UnitSnippet.ParamValues['UnitName']:=UnitIdent; // the first way to set params value
- UnitSnippet.Params.Add('ProcName=MyProc'); // the second way to set params value
- UnitSnippet.DoResultCode; // replacing all params to neccessary values
- Result:=UnitSnippet.ResultCodeText; //return result code as long string
- end;
-
- function TDemoDataModule.FormCreatorSourceWriting(UnitIdent, FormIdent,
- AncestorIdent: String): String;
- begin
- FormSnippet.ParamValues['UnitName']:=UnitIdent; // the first way to set params value
- // note: DoResultCode is not case-sensitive
- FormSnippet.Params.Add('FORMNAME='+FormIdent); // the second way to set params value
- FormSnippet.ParamValues['ancestorname']:=AncestorIdent;
- FormSnippet.DoResultCode; // replacing all params to neccessary values
- Result:=FormSnippet.ResultCodeText; //return result code as long string
- end;
-
-
- function TDemoDataModule.DMCreatorSourceWriting(UnitIdent, FormIdent,
- AncestorIdent: String): String;
- begin
- DMSnippet.ParamValues['UnitName']:=UnitIdent; // the first way to set params value
- // note: DoResultCode is not case-sensitive
- DMSnippet.Params.Add('dmNAME='+FormIdent); // the second way to set params value
- DMSnippet.DoResultCode; // replacing all params to neccessary values
- Result:=DMSnippet.ResultCodeText; //return result code as long string
- end;
-
-
- function TDemoDataModule.BtnFormCreatorSourceWriting(UnitIdent, FormIdent,
- AncestorIdent: String): String;
- begin
- BtnFormSnippet.ParamValues['UnitName']:=UnitIdent;
- BtnFormSnippet.ParamValues['FormName']:=FormIdent;
- BtnFormSnippet.DoResultCode; // replacing all params to neccessary values
- Result:=BtnFormSnippet.ResultCodeText; //return result code as long string
- end;
-
- procedure TDemoDataModule.BtnFormCreatorFormCreated(Sender: TObject;
- IForm: TIFormInterface);
- var
- FormIComp : TIComponentInterface;
- Form : TForm;
- BtnIComp : TIComponentInterface;
- Btn : TButton;
- OnClickMethod:TMethod;
- W,H : integer;
- s : string;
- begin
- FormIComp:=IForm.GetFormComponent;
- with FormIComp do
- try
- W:=260;
- SetPropByName('Width',W); // first way to set properties; set value via variables only, for exam.: use W, but not 260
- H:=200;
- SetPropByName('Height',H);
- s:='Form with button';
- SetPropByName('Caption',s);
- Form:=TForm(FormIComp.GetComponentHandle);
-
- Btn:=TButton.Create(nil); // create button (without owner!)
- try
- Btn.Name:='Button1';
- Btn.Caption:='Click me!';
- Form.InsertComponent(Btn); // set the button's Owner
- Form.InsertControl(Btn); // set the button's Parent
- Btn.Left:=30;
- Btn.Top:=40;
- OnClickMethod.Code:=CreateSubClassMethod(Form,'Button1Click'); // creating method with function from 'Proxies' unit
- OnClickMethod.Data:=Form;
- Btn.OnClick:=TNotifyEvent(OnClickMethod); // set the OnClick-handler for Button
- except
- Btn.Free;
- end;
-
- finally
- FormIComp.Free;
- end;
- end;
-
- initialization
- // datamodule initialization
- xdkInitModule(TDemoDataModule,DemoDataModule);
-
- finalization
- // datamodule deinitialization
- xdkDoneModule(DemoDataModule);
- end.
-