home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 April / Chip_1997-04_cd.bin / prezent / cb / data.z / EXPTDEMO.DPR < prev    next >
Text File  |  1997-01-16  |  5KB  |  242 lines

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