ufrmRule.pas
上传用户:yjb1804
上传日期:2021-01-30
资源大小:3105k
文件大小:16k
源码类别:

Email服务器

开发平台:

Delphi

  1. unit ufrmRule;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils,Variants, Classes, Graphics, Controls, Forms,
  5.   Dialogs, StdCtrls, ExtCtrls, cxGraphics, Menus,
  6.   cxLookAndFeelPainters, cxButtons, cxCheckBox, cxTextEdit, cxMaskEdit,
  7.   cxDropDownEdit, cxImageComboBox, cxLabel, cxControls, cxContainer,
  8.   cxEdit, cxGroupBox, dxBar, cxClasses, cxCustomData, 
  9.   cxDataStorage, cxGridCustomTableView, cxGridTableView,
  10.   cxGridCustomView, cxGridLevel, cxGrid, cxButtonEdit, dxBarExtItems,uRulerMgr,
  11.   RzShellDialogs, cxListBox, DB, cxDBData, cxGridDBTableView, cxStyles,
  12.   cxFilter, cxData, dxSkinsCore, dxSkinBlack, dxSkinBlue, dxSkinCaramel,
  13.   dxSkinCoffee, {dxSkinDarkRoom,} dxSkinDarkSide, {dxSkinFoggy,}
  14.   dxSkinGlassOceans, dxSkiniMaginary, dxSkinLilian, dxSkinLiquidSky,
  15.   dxSkinLondonLiquidSky, dxSkinMcSkin, dxSkinMoneyTwins,
  16.   dxSkinOffice2007Black, dxSkinOffice2007Blue, dxSkinOffice2007Green,
  17.   dxSkinOffice2007Pink, dxSkinOffice2007Silver, dxSkinPumpkin, {dxSkinSeven,}
  18.   {dxSkinSharp,} dxSkinSilver, {dxSkinSpringTime,} dxSkinStardust,
  19.   dxSkinSummer2008, dxSkinsDefaultPainters, dxSkinValentine,
  20.   dxSkinXmas2008Blue, dxSkinscxPCPainter, dxSkinsdxBarPainter;
  21. type
  22.   TfrmRule = class(TForm)
  23.     pnl1: TPanel;
  24.     pnl3: TPanel;
  25.     dxbrmngr1: TdxBarManager;
  26.     dxbrmngr1Bar1: TdxBar;
  27.     dxbrbtn1: TdxBarButton;
  28.     dxbrbtn2: TdxBarButton;
  29.     dxbrbtn3: TdxBarButton;
  30.     dxbrbtn4: TdxBarButton;
  31.     pnl2: TPanel;
  32.     btnCancel: TcxButton;
  33.     btnSave: TcxButton;
  34.     btn3: TdxBarLargeButton;
  35.     btn4: TdxBarLargeButton;
  36.     btn5: TdxBarLargeButton;
  37.     btn6: TdxBarLargeButton;
  38.     dlgOpen: TRzOpenDialog;
  39.     lstRules: TcxListBox;
  40.     cxEditStyleController1: TcxEditStyleController;
  41.     dlgSave: TRzSaveDialog;
  42.     pnl4: TPanel;
  43.     cxgrpbx1: TcxGroupBox;
  44.     cxGrid1: TcxGrid;
  45.     tvRules: TcxGridTableView;
  46.     gtvColGrid1TableView1Column1: TcxGridColumn;
  47.     gtvColGrid1TableView1Column2: TcxGridColumn;
  48.     gtvColGrid1TableView1Column3: TcxGridColumn;
  49.     cxgrdbtblvwGrid1DBTableView1: TcxGridDBTableView;
  50.     cxgrdbtblvwGrid1DBTableView1Area: TcxGridDBColumn;
  51.     cxgrdbtblvwGrid1DBTableView1Compare: TcxGridDBColumn;
  52.     cxgrdbtblvwGrid1DBTableView1Text: TcxGridDBColumn;
  53.     cxgrdbtblvwGrid1DBTableView1RecId: TcxGridDBColumn;
  54.     tvRule: TcxGridTableView;
  55.     gtvColGrid1TableView1Column4: TcxGridColumn;
  56.     gtvColGrid1TableView1Column5: TcxGridColumn;
  57.     gtvColGrid1TableView1Column6: TcxGridColumn;
  58.     cxgrdlvlGrid1Level1: TcxGridLevel;
  59.     cxgrpbx2: TcxGroupBox;
  60.     chkDeleteOnServer: TcxCheckBox;
  61.     chkIgnore: TcxCheckBox;
  62.     chkPopTip: TcxCheckBox;
  63.     chkPlaySound: TcxCheckBox;
  64.     chkRunExe: TcxCheckBox;
  65.     edtPlaySound: TcxButtonEdit;
  66.     edtRunExe: TcxButtonEdit;
  67.     pnl5: TPanel;
  68.     lbl1: TcxLabel;
  69.     lbl2: TcxLabel;
  70.     cbAccount: TcxImageComboBox;
  71.     edtRuleName: TcxTextEdit;
  72.     chkEnable: TcxCheckBox;
  73.     chkUseToNew: TcxCheckBox;
  74.     btnAddRow: TcxButton;
  75.     btnDeleteRow: TcxButton;
  76.     btnSaveRecord: TcxButton;
  77.     btn1: TdxBarLargeButton;
  78.     btn2: TdxBarLargeButton;
  79.     procedure btnCancelClick(Sender: TObject);
  80.     procedure FormCreate(Sender: TObject);
  81.     procedure FormDestroy(Sender: TObject);
  82.     procedure lstRulesMouseUp(Sender: TObject; Button: TMouseButton;
  83.       Shift: TShiftState; X, Y: Integer);
  84.     procedure chkPlaySoundClick(Sender: TObject);
  85.     procedure chkRunExeClick(Sender: TObject);
  86.     procedure edtPlaySoundPropertiesButtonClick(Sender: TObject;
  87.       AButtonIndex: Integer);
  88.     procedure edtRunExePropertiesButtonClick(Sender: TObject;
  89.       AButtonIndex: Integer);
  90.     procedure chkEnableClick(Sender: TObject);
  91.     procedure btnAddRowClick(Sender: TObject);
  92.     procedure btnDeleteRowClick(Sender: TObject);
  93.     procedure btn3Click(Sender: TObject);
  94.     procedure btnSaveClick(Sender: TObject);
  95.     procedure btn6Click(Sender: TObject);
  96.     procedure btn4Click(Sender: TObject);
  97.     procedure edtRuleNamePropertiesEditValueChanged(Sender: TObject);
  98.     procedure chkUseToNewClick(Sender: TObject);
  99.     procedure chkDeleteOnServerClick(Sender: TObject);
  100.     procedure chkIgnoreClick(Sender: TObject);
  101.     procedure chkPopTipClick(Sender: TObject);
  102.     procedure cbAccountPropertiesCloseUp(Sender: TObject);
  103.     procedure tvRulesDataControllerRecordChanged(
  104.       ADataController: TcxCustomDataController; ARecordIndex,
  105.       AItemIndex: Integer);
  106.     procedure btnSaveRecordClick(Sender: TObject);
  107.     procedure btn5Click(Sender: TObject);
  108.     procedure btn2Click(Sender: TObject);
  109.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  110.   private
  111.     { Private declarations }
  112.     FRuleItems:TRuleItems;
  113.     FRulesSaveTo:string;
  114.     FIndex:Integer;
  115.     procedure LoadRules;
  116.     procedure ShowRules;
  117.     procedure LoadAccount;
  118.     procedure LoadRuleRows;
  119.     procedure ShowRuleRows;
  120.   public
  121.     { Public declarations }
  122.   end;
  123. var
  124.   frmRule: TfrmRule;
  125. const
  126.   CONST_AREA:array[0..5] of ShortString=('主题','收件人','发件人','抄送','暗送','邮件正文');
  127.   CONST_COMPARE:array[0..3] of ShortString=('包含','相等','空','使用正则表达式');
  128. implementation
  129. uses ufrmMain, uMyXml, NativeXml, uCommon;
  130. {$R *.dfm}
  131. procedure TfrmRule.btnCancelClick(Sender: TObject);
  132. begin
  133.   self.close;
  134.   ModalResult:=mrCancel;
  135. end;
  136. procedure TfrmRule.FormCreate(Sender: TObject);
  137. var
  138.   MyXml:TMyxml;
  139. begin
  140.   tvRule.DataController.Options:=tvRule.DataController.Options+[ dcoImmediatePost,dcoInsertOnNewItemRowFocusing]; //立即自动提交新记录
  141.   FRuleItems:=TRuleItems.Create;
  142.   LoadAccount;
  143.   MyXml:=TMyXml.Create(AppPath+'EmailServers.xml');
  144.   try
  145.     if MyXml.Root.FindNode('Rules')<> nil then
  146.     begin
  147.       FRulesSaveTo:=MyXml.Root.FindNode('Rules').AttributeByName['RulesSaveTo'];
  148.       FRulesSaveTo:=GetFullPath(FRulesSaveTo);
  149.       if FileExists(FRulesSaveTo) then  TRuleItems.ReadFromFile(FRulesSaveTo,FRuleItems);
  150.     end;
  151.     LoadRules;
  152.   finally
  153.     MyXml.Free;
  154.   end;  
  155. end;
  156. procedure TfrmRule.FormDestroy(Sender: TObject);
  157. begin
  158.   FRuleItems.Free;
  159. end;
  160. procedure TfrmRule.LoadAccount;
  161. var
  162.   myxml:TMyXml;
  163.   L:TList;
  164.   I:Integer;
  165. begin
  166.   cbAccount.Properties.Items.Clear;
  167.   with cbAccount.Properties.Items.Add do
  168.   begin
  169.     ImageIndex:=0;
  170.     Description:='所有账号';
  171.     Value:='All';
  172.   end;
  173.   MyXml:=TMyXml.Create(AppPath+'EmailServers.xml');
  174.   try
  175.     L:=TList.Create;
  176.     myxml.Pop3Nodes(L);
  177.     for I:=0 to L.Count-1 do
  178.       with cbAccount.Properties.Items.Add do
  179.       begin
  180.         ImageIndex:=I;
  181.         Description:=TXmlNode(L[I]).ReadString('displayname');
  182.         Value:=TXmlNode(L[I]).ReadString('emailaddr');
  183.       end;
  184.     L.Free;
  185.   finally
  186.     myxml.Free;
  187.   end;
  188. end;
  189. procedure TfrmRule.LoadRules;
  190. var
  191.   I:Integer;
  192. begin
  193.   lstRules.Items.Clear;
  194.   for I:=0 to FRuleItems.Count-1 do
  195.     lstRules.AddItem(TRuleItem(FRuleItems[I]).Name,TObject(FRuleItems.Items[I]));
  196.   if lstRules.Items.Count=0 then
  197.   begin
  198.     FIndex:=-1;
  199.     edtRuleName.Enabled:=False;
  200.   end
  201.   else
  202.   begin
  203.     lstRules.ItemIndex:=0;
  204.     FIndex:=0;
  205.     ShowRules;
  206.   end;
  207. end;
  208. procedure TfrmRule.lstRulesMouseUp(Sender: TObject; Button: TMouseButton;
  209.   Shift: TShiftState; X, Y: Integer);
  210. var
  211.   P:TPoint;
  212. begin
  213.   p.X:=X; P.Y:=Y;
  214.   FIndex:=TcxListBox(Sender).ItemAtPos(P,True);
  215.   if FIndex<0 then Exit;
  216.   
  217.   ShowRules;
  218.   //while tvRule.DataController.RecordCount>0 do tvRule.DataController.DeleteRecord(0);
  219. end;
  220. procedure TfrmRule.chkPlaySoundClick(Sender: TObject);
  221. begin
  222.  edtPlaySound.Visible:=TcxCheckBox(Sender).Checked;
  223. end;
  224. procedure TfrmRule.chkRunExeClick(Sender: TObject);
  225. begin
  226.   edtRunExe.Visible:=TcxCheckBox(Sender).Checked;
  227. end;
  228. procedure TfrmRule.edtPlaySoundPropertiesButtonClick(Sender: TObject;
  229.   AButtonIndex: Integer);
  230. begin
  231.   dlgOpen.Filter:='WAV|*.WAV|MP3|*.MP3|MP3|*.MP4|RM|*.RM|WMA|*.WMA|RA|*.RA|RMX|*.RMX|aif|*.aif|AU|*.AU|MPEG|*.MPEG|MPG|*.MPG|*.*|*.*';
  232.   if dlgOpen.Execute then
  233.   begin
  234.     edtPlaySound.Text:=dlgOpen.FileName;
  235.     TRuleItem(FRuleItems[FIndex]).RulerAction.PlaySound:=edtPlaySound.Text;
  236.   end;
  237. end;
  238. procedure TfrmRule.edtRunExePropertiesButtonClick(Sender: TObject;
  239.   AButtonIndex: Integer);
  240. begin
  241.   dlgOpen.Filter:='EXE|*.exe|BAT|*.bat|*.*|*.*';
  242.   if dlgOpen.Execute then
  243.   begin
  244.     edtRunExe.Text:=dlgOpen.FileName;
  245.     TRuleItem(FRuleItems[FIndex]).RulerAction.RunExe:=edtRunExe.Text;
  246.   end;
  247. end;
  248. procedure TfrmRule.chkEnableClick(Sender: TObject);
  249. begin
  250.   FRuleItems.Items[FIndex].Enabled:=chkEnable.Checked;
  251. end;
  252. procedure TfrmRule.btnAddRowClick(Sender: TObject);
  253. begin
  254.   tvRule.DataController.AppendRecord;
  255. end;
  256. procedure TfrmRule.btnDeleteRowClick(Sender: TObject);
  257. begin
  258.   if not tvRule.DataController.IsEOF then
  259.     tvRule.DataController.DeleteFocused;
  260. end;
  261. procedure TfrmRule.btn3Click(Sender: TObject);
  262. var
  263.   item:TRuleItem;
  264. begin
  265.   item:=FRuleItems.Add;
  266.   item.Name:='新规则';
  267.   lstRules.Items.InsertObject(lstRules.Items.Count,'新规则',TObject(item));
  268.   lstRules.ItemIndex:=lstRules.Count-1;
  269.   FIndex:=lstRules.ItemIndex;
  270.   ShowRules;
  271. end;
  272. procedure TfrmRule.btnSaveClick(Sender: TObject);
  273. begin
  274.   if FIndex<0 then
  275.   begin
  276.     MessageDlg('请选中一个规则,再保存!' + #13#10#13#10#13#10,  
  277.       mtError, [mbOK], 0);
  278.     Exit;
  279.   end;
  280.   //if not FileExists(FRulesSaveTo) then
  281.     FRuleItems.SaveToFile(FRulesSaveTo);
  282.   //else raise Exception.Create('');
  283.   ModalResult:=mrOk;
  284. end;
  285. procedure TfrmRule.ShowRules;
  286. var
  287.   I:Integer;
  288. begin
  289.   if FIndex>=0 then
  290.   begin
  291.     edtRuleName.Enabled:=True;
  292.     edtRuleName.Text:=TRuleItem(FRuleItems[FIndex]).Name;
  293.     chkEnable.Checked:=TRuleItem(FRuleItems[FIndex]).Enabled;
  294.     chkUseToNew.Checked:=TRuleItem(FRuleItems[FIndex]).UseToNewEmail;
  295.     chkDeleteOnServer.Checked:=TRuleItem(FRuleItems[FIndex]).RulerAction.DeleteOnServer;
  296.     chkIgnore.Checked:=TRuleItem(FRuleItems[FIndex]).RulerAction.IgnoreNotRecv;
  297.     chkPopTip.Checked:=TRuleItem(FRuleItems[FIndex]).RulerAction.PopTip;
  298.     chkPlaySound.Checked:=FileExists(TRuleItem(FRuleItems[FIndex]).RulerAction.PlaySound);
  299.     if chkPlaySound.Checked then
  300.     begin
  301.       edtPlaySound.Visible:=chkPlaySound.Checked;
  302.       edtPlaySound.Text:=TRuleItem(FRuleItems[FIndex]).RulerAction.PlaySound;
  303.     end;
  304.     chkRunExe.Checked:=FileExists(TRuleItem(FRuleItems[FIndex]).RulerAction.RunExe);
  305.     if chkRunExe.Checked then
  306.     begin
  307.       edtRunExe.Visible:=chkRunExe.Checked;
  308.       edtRunExe.Text:=TRuleItem(FRuleItems[FIndex]).RulerAction.RunExe;
  309.     end;
  310.     if TRuleItem(FRuleItems[FIndex]).AllAccount then
  311.       cbAccount.ItemIndex:=0
  312.     else
  313.       for I:=0 to cbAccount.Properties.Items.Count-1 do
  314.       begin
  315.         if CompareText(cbAccount.Properties.Items[I].Value,TRuleItem(FRuleItems[FIndex]).Account)=0 then
  316.         begin
  317.           cbAccount.ItemIndex:=I;
  318.           Break;
  319.         end;
  320.       end;
  321.     ShowRuleRows;
  322.   end;
  323. end;
  324. procedure TfrmRule.btn6Click(Sender: TObject);
  325. begin
  326.   dlgSave.Filter:='xml file|*.xml';
  327.   if dlgSave.Execute then
  328.     FRuleItems.SaveToFile(dlgSave.FileName);
  329. end;
  330. procedure TfrmRule.btn4Click(Sender: TObject);
  331. begin
  332.   FRuleItems.Delete(lstRules.ItemIndex);
  333.   lstRules.Items.Delete(lstRules.ItemIndex);
  334.   FIndex:=lstRules.ItemIndex;
  335.   ShowRules;
  336. end;
  337. procedure TfrmRule.edtRuleNamePropertiesEditValueChanged(Sender: TObject);
  338. begin
  339.   lstRules.Items[FIndex]:=edtRuleName.Text;
  340.   FRuleItems.Items[FIndex].Name:=edtRuleName.Text;
  341. end;
  342. procedure TfrmRule.chkUseToNewClick(Sender: TObject);
  343. begin
  344.   FRuleItems.Items[FIndex].UseToNewEmail:=chkUseToNew.Checked;
  345. end;
  346. procedure TfrmRule.chkDeleteOnServerClick(Sender: TObject);
  347. begin
  348.   FRuleItems.Items[FIndex].RulerAction.DeleteOnServer:=chkDeleteOnServer.Checked;
  349. end;
  350. procedure TfrmRule.chkIgnoreClick(Sender: TObject);
  351. begin
  352.   FRuleItems.Items[FIndex].RulerAction.IgnoreNotRecv:=chkIgnore.Checked;
  353. end;
  354. procedure TfrmRule.chkPopTipClick(Sender: TObject);
  355. begin
  356.   FRuleItems.Items[FIndex].RulerAction.PopTip:=chkPopTip.Checked;
  357. end;
  358. procedure TfrmRule.cbAccountPropertiesCloseUp(Sender: TObject);
  359. begin
  360.   if FIndex>=0 then
  361.   begin
  362.     FRuleItems.Items[FIndex].AllAccount:=cbAccount.ItemIndex=0;
  363.     FRuleItems.Items[FIndex].Account:=cbAccount.Properties.Items[cbAccount.ItemIndex].Value;
  364.   end;
  365. end;
  366. procedure TfrmRule.tvRulesDataControllerRecordChanged(
  367.   ADataController: TcxCustomDataController; ARecordIndex,
  368.   AItemIndex: Integer);
  369. //var
  370. //  I:Integer;
  371. //const
  372. //  tips:array[0..2] of string=('区域选项不允许空值','比较选项不允许空值','文本不允许空值');
  373. begin
  374. //  for I:=0 to 2 do
  375. //    if ((I<>3) and VarIsNull(ADataController.Values[ADataController.FocusedRecordIndex,I])) and
  376. //        ((I=3) and VarIsNull(ADataController.Values[ADataController.FocusedRecordIndex,I]) and
  377. //        (ADataController.Values[ADataController.FocusedRecordIndex,2]<>'空')) then
  378. //    begin
  379. //      ADataController.Cancel;
  380. //      MsgBox('出错啦',tips[I]);
  381. //    end;
  382. end;
  383. procedure TfrmRule.LoadRuleRows;
  384. var
  385.   I:Integer;
  386. begin
  387.   FRuleItems.Items[FIndex].Rows.Clear;
  388.   for I:=0 to tvRule.DataController.RecordCount-1 do
  389.   begin
  390.     with FRuleItems.Items[FIndex].Rows.Add do
  391.     begin
  392.       Text:=VarToStr(tvRule.DataController.Values[I,2]);
  393.       Area:=TRuleArea(tvRule.DataController.Values[I,0]);
  394.       Compare:=TRuleCompare(tvRule.DataController.Values[I,1]);
  395. //      if VarToStr(tvRule.DataController.Values[I,0])='主题' then  {主题,收件人,发件人,抄送,暗送,邮件正文}
  396. //        Area:=raSubject
  397. //      else if VarToStr(tvRule.DataController.Values[I,0])='收件人' then
  398. //        Area:=raTo
  399. //      else if VarToStr(tvRule.DataController.Values[I,0])='发件人' then
  400. //        Area:=raFrom
  401. //      else if VarToStr(tvRule.DataController.Values[I,0])='抄送' then
  402. //        Area:=raCC
  403. //      else if VarToStr(tvRule.DataController.Values[I,0])='暗送' then
  404. //        Area:=raCB
  405. //      else if VarToStr(tvRule.DataController.Values[I,0])='邮件正文' then
  406. //        Area:=raBody
  407. //      else {Error!} ;
  408. //
  409. //      if VarToStr(tvRule.DataController.Values[I,1])='包含' then    {包含,相等,空,使用正则表达式}
  410. //        Compare:=rcContains
  411. //      else if VarToStr(tvRule.DataController.Values[I,1])='相等' then
  412. //        Compare:=rcEquals
  413. //      else if VarToStr(tvRule.DataController.Values[I,1])='空' then
  414. //      begin
  415. //        Compare:=rcEmpty;
  416. //        Text:='';
  417. //      end
  418. //      else if VarToStr(tvRule.DataController.Values[I,1])='使用正则表达式' then
  419. //         Compare:=rcRegExpr
  420. //      else {Error!} ;
  421.     end;
  422.   end;
  423. end;
  424. procedure TfrmRule.ShowRuleRows;
  425. var
  426.   I,idx:Integer;
  427. begin
  428.   while tvRule.DataController.RecordCount>0  do tvRule.DataController.DeleteRecord(0);
  429.   
  430.   tvRule.DataController.BeginUpdate;
  431.   try
  432.     for I:=0 to FRuleItems.Items[FIndex].Rows.Count-1 do
  433.     begin
  434.       if not(VarIsOrdinal(FRuleItems.Items[FIndex].Rows.Items[I].Area) and VarIsOrdinal(FRuleItems.Items[FIndex].Rows.Items[I].Compare)) then
  435.         Continue; //忽略无效的值
  436.       idx:=tvRule.DataController.AppendRecord;
  437.       tvRule.DataController.Values[idx,0]:=Ord(FRuleItems.Items[FIndex].Rows.Items[I].Area);
  438.       tvRule.DataController.Values[idx,1]:=Ord(FRuleItems.Items[FIndex].Rows.Items[I].Compare);
  439.       tvRule.DataController.Values[idx,2]:=FRuleItems.Items[FIndex].Rows.Items[I].Text;
  440.       tvRule.DataController.Post;
  441.       //tvRule.DataController.PostEditingData;
  442.     end;
  443.   finally
  444.     tvRule.DataController.EndUpdate;
  445.   end;
  446. end;
  447. procedure TfrmRule.btnSaveRecordClick(Sender: TObject);
  448. var
  449.   I:Integer;
  450.   item:TRuleRow;
  451. begin
  452.   if FIndex<0 then Exit;
  453.   FRuleItems.Items[FIndex].Rows.Clear;
  454.   with tvRule.DataController do
  455.     for I:=0 to RecordCount -1 do
  456.     begin
  457.       if (not VarIsOrdinal(Values[I,0])) or  (not VarIsOrdinal(Values[I,1])) then
  458.         Continue;  //检查数据合法性
  459.         item:=FRuleItems.Items[FIndex].Rows.Add;
  460.       //begin
  461.         item.Area:=TRuleArea(Values[I,0]);
  462.         item.Compare:=TRuleCompare(Values[I,1]);
  463.         item.Text:=VarToStr(Values[I,2]);
  464.      // end;
  465.     end;
  466. end;
  467. procedure TfrmRule.btn5Click(Sender: TObject);
  468. var
  469.   count,I:Integer;
  470. begin
  471.   dlgOpen.Filter:='xml file|*.xml';
  472.   if dlgOpen.Execute then
  473.   begin
  474.     count:=FRuleItems.Count;
  475.     TRuleItems.AppendFromFile(dlgOpen.FileName,FRuleItems);
  476.     for I:=count to  FRuleItems.Count-1 do
  477.       lstRules.AddItem(FRuleItems.Items[I].Name,TObject(FRuleItems.Items[I]));
  478.   end;
  479. end;
  480. procedure TfrmRule.btn2Click(Sender: TObject);
  481. begin
  482.   close;
  483. end;
  484. procedure TfrmRule.FormClose(Sender: TObject; var Action: TCloseAction);
  485. begin
  486.   Action:=caFree;
  487. end;
  488. end.