home *** CD-ROM | disk | FTP | other *** search
/ Delphi 5 for Professionals / DELPHI5.iso / Runimage / Delphi50 / Demos / Experts / exptdemo.dpr < prev    next >
Encoding:
Text File  |  1999-08-11  |  5.1 KB  |  271 lines

  1. library Exptdemo;
  2.  
  3. { Note: IDE Expert DLLs do not have to be compiled with packages, but doing so makes 
  4.   the expert DLL much smaller. }
  5.  
  6. {$IMAGEBASE $50950000}
  7.  
  8. uses 
  9.   ShareMem,
  10.   Forms,
  11.   Windows,
  12.   ExptIntf,
  13.   ToolIntf,
  14.   VirtIntf,
  15.   SysUtils,
  16.   Dlg in 'DLG.PAS' {DlgExpert},
  17.   Exconst in 'EXCONST.PAS',
  18.   App in 'APP.PAS' {AppExpert};
  19.  
  20. type
  21.   TDialogExpert = class(TIExpert)
  22.     function GetName: string; override;
  23.     function GetComment: string; override;
  24.     function GetGlyph: HICON; override;
  25.     function GetStyle: TExpertStyle; override;
  26.     function GetState: TExpertState; override;
  27.     function GetIDString: string; override;
  28.     function GetAuthor: string; override;
  29.     function GetPage: string; override;
  30.     function GetMenuText: string; override;
  31.     procedure Execute; override;
  32.   end;
  33.  
  34.   TApplicationExpert = class(TIExpert)
  35.     function GetName: string; override;
  36.     function GetComment: string; override;
  37.     function GetGlyph: HICON; override;
  38.     function GetStyle: TExpertStyle; override;
  39.     function GetState: TExpertState; override;
  40.     function GetIDString: string; override;
  41.     function GetAuthor: string; override;
  42.     function GetPage: string; override;
  43.     function GetMenuText: string; override;
  44.     procedure Execute; override;
  45.   end;
  46.  
  47. {$R EXPTBMPS.RES}
  48. {$R STRINGS.RES}
  49. {$R RESOURCE.RES}
  50.  
  51. procedure HandleException;
  52. begin
  53.   ToolServices.RaiseException(ReleaseException);
  54. end;
  55.  
  56. { TDialogExpert }
  57. function TDialogExpert.GetName: string;
  58. begin
  59.   try
  60.     Result := LoadStr(sDlgExpertName);
  61.   except
  62.     HandleException;
  63.   end;
  64. end;
  65.  
  66. function TDialogExpert.GetComment: string;
  67. begin
  68.   try
  69.     Result := LoadStr(sDlgExpertDesc);
  70.   except
  71.     HandleException;
  72.   end;
  73. end;
  74.  
  75. function TDialogExpert.GetGlyph: HICON;
  76. begin
  77.   try
  78.     Result := LoadIcon(HInstance, 'DLGEXPT'); 
  79.   except
  80.     HandleException;
  81.     Result := 0;
  82.   end;
  83. end;
  84.  
  85. function TDialogExpert.GetStyle: TExpertStyle;
  86. begin
  87.   try
  88.     Result := esForm;
  89.   except
  90.     HandleException;
  91.     Result := esForm;
  92.   end;
  93. end;
  94.  
  95. function TDialogExpert.GetState: TExpertState;
  96. begin
  97.   try
  98.     Result := [esEnabled];
  99.   except
  100.     HandleException;
  101.     Result := [];
  102.   end;
  103. end;
  104.  
  105. function TDialogExpert.GetIDString: string;
  106. begin
  107.   try
  108.     Result := 'Borland.DlgExpertDemo';
  109.   except
  110.     HandleException;
  111.     Result := '';
  112.   end;
  113. end;
  114.  
  115. function TDialogExpert.GetAuthor: string;
  116. begin
  117.   try
  118.     Result := 'Borland';
  119.   except
  120.     HandleException;
  121.     Result := '';
  122.   end;
  123. end;
  124.  
  125. function TDialogExpert.GetPage: string;
  126. begin
  127.   try
  128.     Result := LoadStr(sDialogsPage);
  129.   except
  130.     HandleException;
  131.     Result := '';
  132.   end;
  133. end;
  134.  
  135. function TDialogExpert.GetMenuText: string;
  136. begin
  137.   Result := '';
  138. end;
  139.  
  140. procedure TDialogExpert.Execute;
  141. begin
  142.   try
  143.     DialogExpert(ToolServices);
  144.   except
  145.     HandleException;
  146.   end;
  147. end;
  148.  
  149. { TApplicationExpert }
  150. function TApplicationExpert.GetName: string;
  151. begin
  152.   try
  153.     Result := LoadStr(sAppExpertName);
  154.   except
  155.     HandleException;
  156.   end;
  157. end;
  158.  
  159. function TApplicationExpert.GetComment: string;
  160. begin
  161.   try
  162.     Result := LoadStr(sAppExpertDesc);
  163.   except
  164.     HandleException;
  165.   end;
  166. end;
  167.  
  168. function TApplicationExpert.GetGlyph: HICON;
  169. begin
  170.   try
  171.     Result := LoadIcon(HInstance, 'APPEXPT'); 
  172.   except
  173.     HandleException;
  174.     Result := 0;
  175.   end;
  176. end;
  177.  
  178. function TApplicationExpert.GetStyle: TExpertStyle;
  179. begin
  180.   try
  181.     Result := esProject;
  182.   except
  183.     HandleException;
  184.     Result := esProject;
  185.   end;
  186. end;
  187.  
  188. function TApplicationExpert.GetState: TExpertState;
  189. begin
  190.   try
  191.     Result := [esEnabled];
  192.   except
  193.     HandleException;
  194.     Result := [];
  195.   end;
  196. end;
  197.  
  198. function TApplicationExpert.GetIDString: string;
  199. begin
  200.   try
  201.     Result := 'Borland.AppExpertDemo';
  202.   except
  203.     HandleException;
  204.     Result := '';
  205.   end;
  206. end;
  207.  
  208. function TApplicationExpert.GetAuthor: string;
  209. begin
  210.   try
  211.     Result := 'Borland';
  212.   except
  213.     HandleException;
  214.     Result := '';
  215.   end;
  216. end;
  217.  
  218. function TApplicationExpert.GetPage: string;
  219. begin
  220.   try
  221.     Result := LoadStr(sProjectsPage);
  222.   except
  223.     HandleException;
  224.     Result := '';
  225.   end;
  226. end;
  227.  
  228. function TApplicationExpert.GetMenuText: string;
  229. begin
  230.   Result := '';
  231. end;
  232.  
  233. procedure TApplicationExpert.Execute;
  234. begin
  235.   try
  236.     ApplicationExpert(ToolServices);
  237.   except
  238.     HandleException;
  239.   end;
  240. end;
  241.  
  242. procedure DoneExpert; export;
  243. begin
  244.   { Put any general destruction code here.  Note that the Delphi IDE
  245.     will destroy any experts which have been registered. }
  246. end;
  247.  
  248. function InitExpert(ToolServices: TIToolServices;
  249.   RegisterProc: TExpertRegisterProc;
  250.   var Terminate: TExpertTerminateProc): Boolean; export; stdcall;
  251. begin
  252.   if ExptIntf.ToolServices = nil then
  253.   begin
  254.     ExptIntf.ToolServices := ToolServices;
  255.     if ToolServices <> nil then
  256.       Application.Handle := ToolServices.GetParentHandle;
  257.   end;
  258.  
  259.   Terminate := DoneExpert;
  260.  
  261.   { register the experts }
  262.   Result := RegisterProc(TDialogExpert.Create) and
  263.     RegisterProc(TApplicationExpert.Create);
  264. end;
  265.  
  266. exports
  267.   InitExpert name ExpertEntryPoint resident;
  268.  
  269. begin
  270. end.
  271.