全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:4109
推到 Plurk!
推到 Facebook!

AppBar Wizard Source Code

 
axsoft
版主


發表:681
回覆:1056
積分:969
註冊:2002-03-13

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-02-13 15:06:22 IP:61.218.xxx.xxx 未訂閱
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
資深會員


發表:88
回覆:407
積分:274
註冊:2002-03-13

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-07-08 10:16:53 IP:218.1.xxx.xxx 未訂閱
老兄,没有AppBars.pas哦?! ====================== 久病成良医--多试 千人之诺诺,不如一士之谔谔--兼听
iamjsn
初階會員


發表:78
回覆:95
積分:44
註冊:2002-08-16

發送簡訊給我
#3 引用回覆 回覆 發表時間:2005-06-08 23:12:33 IP:203.204.xxx.xxx 未訂閱
版主大大,你轉貼的這個AppBar Wizard Source Code 有沒有簡單的實作範例能post上來參考一下嗎,不知怎麼用耶,謝謝
系統時間:2017-09-25 3:24:41
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!