AppBar Wizard Source Code |
|
axsoft
版主 發表:681 回覆:1056 積分:969 註冊:2002-03-13 發送簡訊給我 |
AppBar Wizard Source Code
================================= 資料來源:http://safariexamples.informit.com/
unit ABWizard; interface uses Windows, Classes, ToolsAPI; type TAppBarWizard = class(TNotifierObject, IOTAWizard, IOTARepositoryWizard, IOTAFormWizard, IOTACreator, IOTAModuleCreator) private FUnitIdent: string; FClassName: string; FFileName: string; protected // IOTAWizard methods function GetIDString: string; function GetName: string; function GetState: TWizardState; procedure Execute; // IOTARepositoryWizard / IOTAFormWizard methods function GetAuthor: string; function GetComment: string; function GetPage: string; function GetGlyph: HICON; // IOTACreator methods function GetCreatorType: string; function GetExisting: Boolean; function GetFileSystem: string; function GetOwner: IOTAModule; function GetUnnamed: Boolean; // IOTAModuleCreator methods function GetAncestorName: string; function GetImplFileName: string; function GetIntfFileName: string; function GetFormName: string; function GetMainForm: Boolean; function GetShowForm: Boolean; function GetShowSource: Boolean; function NewFormFile(const FormIdent, AncestorIdent: string): IOTAFile; function NewImplSource(const ModuleIdent, FormIdent, AncestorIdent: string): IOTAFile; function NewIntfSource(const ModuleIdent, FormIdent, AncestorIdent: string): IOTAFile; procedure FormCreated(const FormEditor: IOTAFormEditor); end; implementation uses Forms, AppBars, SysUtils, DsgnIntf; {$R CodeGen.res} type TBaseFile = class(TInterfacedObject) private FModuleName: string; FFormName: string; FAncestorName: string; public constructor Create(const ModuleName, FormName, AncestorName: string); end; TUnitFile = class(TBaseFile, IOTAFile) protected function GetSource: string; function GetAge: TDateTime; end; TFormFile = class(TBaseFile, IOTAFile) protected function GetSource: string; function GetAge: TDateTime; end; { TBaseFile } constructor TBaseFile.Create(const ModuleName, FormName, AncestorName: string); begin inherited Create; FModuleName := ModuleName; FFormName := FormName; FAncestorName := AncestorName; end; { TUnitFile } function TUnitFile.GetSource: string; var Text: string; ResInstance: THandle; HRes: HRSRC; begin ResInstance := FindResourceHInstance(HInstance); HRes := FindResource(ResInstance, 'CODEGEN', RT_RCDATA); Text := PChar(LockResource(LoadResource(ResInstance, HRes))); SetLength(Text, SizeOfResource(ResInstance, HRes)); Result := Format(Text, [FModuleName, FFormName, FAncestorName]); end; function TUnitFile.GetAge: TDateTime; begin Result := -1; end; { TFormFile } function TFormFile.GetSource: string; const FormText = 'object %0:s: T%0:s'#13#10'end'; begin Result := Format(FormText, [FFormName]); end; function TFormFile.GetAge: TDateTime; begin Result := -1; end; { TAppBarWizard } { TAppBarWizard.IOTAWizard } function TAppBarWizard.GetIDString: string; begin Result := 'DDG.AppBarWizard'; end; function TAppBarWizard.GetName: string; begin Result := 'DDG AppBar Wizard'; end; function TAppBarWizard.GetState: TWizardState; begin Result := [wsEnabled]; end; procedure TAppBarWizard.Execute; begin (BorlandIDEServices as IOTAModuleServices).GetNewModuleAndClassName( 'AppBar', FUnitIdent, FClassName, FFileName); (BorlandIDEServices as IOTAModuleServices).CreateModule(Self); end; { TAppBarWizard.IOTARepositoryWizard / TAppBarWizard.IOTAFormWizard } function TAppBarWizard.GetGlyph: HICON; begin Result := 0; // use standard icon end; function TAppBarWizard.GetPage: string; begin Result := 'DDG'; end; function TAppBarWizard.GetAuthor: string; begin Result := 'Delphi 5 Developer''s Guide'; end; function TAppBarWizard.GetComment: string; begin Result := 'Creates a new AppBar form.' end; { TAppBarWizard.IOTACreator } function TAppBarWizard.GetCreatorType: string; begin Result := ''; end; function TAppBarWizard.GetExisting: Boolean; begin Result := False; end; function TAppBarWizard.GetFileSystem: string; begin Result := ''; end; function TAppBarWizard.GetOwner: IOTAModule; var I: Integer; ModServ: IOTAModuleServices; Module: IOTAModule; ProjGrp: IOTAProjectGroup; begin Result := nil; ModServ := BorlandIDEServices as IOTAModuleServices; for I := 0 to ModServ.ModuleCount - 1 do begin Module := ModSErv.Modules[I]; // find current project group if CompareText(ExtractFileExt(Module.FileName), '.bpg') = 0 then if Module.QueryInterface(IOTAProjectGroup, ProjGrp) = S_OK then begin // return active project of group Result := ProjGrp.GetActiveProject; Exit; end; end; end; function TAppBarWizard.GetUnnamed: Boolean; begin Result := True; end; { TAppBarWizard.IOTAModuleCreator } function TAppBarWizard.GetAncestorName: string; begin Result := 'TAppBar'; end; function TAppBarWizard.GetImplFileName: string; var CurrDir: array[0..MAX_PATH] of char; begin // Note: full path name required! GetCurrentDirectory(SizeOf(CurrDir), CurrDir); Result := Format('%s\%s.pas', [CurrDir, FUnitIdent, '.pas']); end; function TAppBarWizard.GetIntfFileName: string; begin Result := ''; end; function TAppBarWizard.GetFormName: string; begin Result := FClassName; end; function TAppBarWizard.GetMainForm: Boolean; begin Result := False; end; function TAppBarWizard.GetShowForm: Boolean; begin Result := True; end; function TAppBarWizard.GetShowSource: Boolean; begin Result := True; end; function TAppBarWizard.NewFormFile(const FormIdent, AncestorIdent: string): IOTAFile; begin Result := TFormFile.Create('', FormIdent, AncestorIdent); end; function TAppBarWizard.NewImplSource(const ModuleIdent, FormIdent, AncestorIdent: string): IOTAFile; begin Result := TUnitFile.Create(ModuleIdent, FormIdent, AncestorIdent); end; function TAppBarWizard.NewIntfSource(const ModuleIdent, FormIdent, AncestorIdent: string): IOTAFile; begin Result := nil; end; procedure TAppBarWizard.FormCreated(const FormEditor: IOTAFormEditor); begin // do nothing end; end.================================================================= 下載: ABWizard.pas CodeGen.rc CodeGen.RES CodeGen.txt 網路志工聯盟----Visita網站http://www.vista.org.tw ---[ 發問前請先找找舊文章 ]--- 發表人 - axsoft 於 2003/02/13 15:09:58 |
mustapha.wang
資深會員 發表:89 回覆:409 積分:274 註冊:2002-03-13 發送簡訊給我 |
|
iamjsn
初階會員 發表:78 回覆:95 積分:44 註冊:2002-08-16 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |