home *** CD-ROM | disk | FTP | other *** search
/ Delphi 2 - Developers' Solutions / Delphi 2 Developers' Solutions.iso / dds / chap10 / howto02 / delphi10 / cciccinf.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-06-12  |  22.9 KB  |  648 lines

  1. unit Cciccinf;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, StdCtrls, Buttons, ExtCtrls, Grids, Outline, CCWSock;
  8.  
  9. type
  10.   TCCICInfoDlg = class(TForm)
  11.     Panel1: TPanel;
  12.     BitBtn1: TBitBtn;
  13.     BitBtn2: TBitBtn;
  14.     Panel4: TPanel;
  15.     ListBox2: TListBox;
  16.     Panel2: TPanel;
  17.     Edit1: TEdit;
  18.     Panel3: TPanel;
  19.     Edit2: TEdit;
  20.     Panel5: TPanel;
  21.     Edit3: TEdit;
  22.     Panel8: TPanel;
  23.     Edit4: TEdit;
  24.     Panel9: TPanel;
  25.     Edit5: TEdit;
  26.     Panel6: TPanel;
  27.     Label1: TLabel;
  28.     Label2: TLabel;
  29.     Button1: TButton;
  30.     Button2: TButton;
  31.     Button3: TButton;
  32.     Button4: TButton;
  33.     ListBox1: TListBox;
  34.     procedure Button1Click(Sender: TObject);
  35.     procedure ListBox2Click(Sender: TObject);
  36.     procedure BitBtn1Click(Sender: TObject);
  37.     procedure BitBtn2Click(Sender: TObject);
  38.     procedure Edit4Exit(Sender: TObject);
  39.     procedure Button2Click(Sender: TObject);
  40.     procedure Button3Click(Sender: TObject);
  41.     procedure Button4Click(Sender: TObject);
  42.     procedure ListBox1DblClick(Sender: TObject);
  43.   private
  44.     { Private declarations }
  45.   public
  46.     { Public declarations }
  47.   end;
  48.  
  49. var
  50.   CCICInfoDlg: TCCICInfoDlg;
  51. const
  52.   LBClickVector : Integer = 0;
  53.   ActiveMailbox : Integer = 0;
  54.  
  55. implementation
  56.  
  57. uses CCICCFrm;
  58.  
  59. function inet_addr( IPAddressName : PChar ) :
  60.           Unsigned_Long_Integer; far; external 'WINSOCK';
  61. function gethostbyname( TheName : PChar ) :
  62.           PHost_Entry; far; external 'WINSOCK';
  63.  
  64. {$R *.DFM}
  65. procedure TCCICInfoDlg.Button1Click(Sender: TObject);
  66. var TempSocket : TCCSocket; { Used for IP Address info }
  67.     DataBuffer : array[ 0 .. 256 ] of char;
  68. begin
  69.   case Tag of
  70.     1 : begin  { Get IP Address Mode }
  71.           { Create the dummy socket }
  72.           TempSocket := TCCSocket.Create( Self );
  73.           TempSocket.Parent := Self;
  74.           { Use it to get the info }
  75.           with TempSocket do
  76.           begin
  77.             { Move the IP address into the data buffer }
  78.             StrPCopy( DataBuffer , Edit1.Text );
  79.             { Turn it into a real IP address in binary form }
  80.             Socket_IP_Address.Socket_Address.Full_Internet_Address :=
  81.              inet_addr( DataBuffer );
  82.             { If not found then do remote lookup }
  83.             if Socket_IP_Address.Socket_Address.Full_Internet_Address = INADDR_NONE then
  84.             begin
  85.               { Call blocking function on IP name }
  86.               Socket_Host_Entry := gethostbyname( DataBuffer );
  87.               { If still no good then error out and exit }
  88.               if Socket_Host_Entry = nil then
  89.               begin
  90.                 Edit2.Text := 'Could Not Convert Host Name';
  91.                 Edit3.Text := '';
  92.               end
  93.               else
  94.               begin
  95.                 { Otherwise get the address }
  96.                 Socket_IP_Address.Socket_Address :=
  97.                  Socket_Host_Entry^.Host_Address^^;
  98.                 Edit2.Text :=
  99.                  IntToStr( Socket_IP_Address.Socket_Address.Net_Byte ) + '.' +
  100.                  IntToStr( Socket_IP_Address.Socket_Address.Host_Byte ) + '.' +
  101.                  IntToStr( Socket_IP_Address.Socket_Address.Local_Host_Byte ) +
  102.                  '.' + IntToStr(
  103.                  Socket_IP_Address.Socket_Address.Local_Machine_Byte );
  104.                 Edit3.Text :=
  105.                  IntToStr( Socket_IP_Address.Socket_Address.
  106.                             Full_Internet_Address );
  107.               end;
  108.             end;
  109.           end;
  110.           { Free the dummy socket }
  111.           TempSocket.Free;
  112.         end;
  113.     2 : begin { Anonymous login punch }
  114.           Edit3.Text := 'anonymous';
  115.           CurrentRealPWString := CurrentPassWordString;
  116.           case PasswordControlVector of
  117.             1 : Edit4.Text := CurrentPassWordString;
  118.             2 : Edit4.Text := '**********';
  119.           end;
  120.         end;
  121.     5 : begin { Toggle subscribe/unsubscribe status }
  122.           if Edit3.Text = 'Subscribed' then Edit3.Text := 'UnSubscribed' else
  123.            Edit3.Text := 'Subscribed';
  124.         end;
  125.   end;
  126. end;
  127.  
  128. procedure TCCICInfoDlg.ListBox2Click(Sender: TObject);
  129. var TheWorkingList  : TList;
  130.     Counter_1       : Integer;
  131.     Finished        : Boolean;
  132. begin
  133.   { Use Tag vector to find out how to interpret a click }
  134.   case Tag of
  135.     2 : begin
  136.           { If nothing in list box then exit }
  137.           if ListBox2.ItemIndex = -1 then exit;
  138.           { Use the data in the Working FTP Site List TList }
  139.           with PConnectionsRecord(
  140.            TheWorkingFTPSL.Items[ ListBox2.ItemIndex ] )^ do
  141.           begin
  142.               Edit1.Text := CProfile;
  143.               Edit2.Text := CIPAddress;
  144.               Edit3.Text := CUserName;
  145.               CurrentRealPWString := CPassword;
  146.               case PasswordControlVector of
  147.                 1 : Edit4.Text := CPassword;
  148.                 2 : Edit4.Text := '**********';
  149.               end;
  150.               Edit5.Text := CStartDir;
  151.           end;
  152.         end;
  153.     4 : begin
  154.           { If nothing in list box then exit }
  155.           if ListBox2.ItemIndex = -1 then exit;
  156.           { Use the data in the Working FTP Site List TList }
  157.           with PConnectionsRecord(
  158.            TheWorkingNSSL.Items[ ListBox2.ItemIndex ] )^ do
  159.           begin
  160.               Edit1.Text := CProfile;
  161.               Edit2.Text := CIPAddress;
  162.           end;
  163.         end;
  164.     5 : begin
  165.           { If nothing in list box then exit }
  166.           if ListBox2.ItemIndex = -1 then exit;
  167.           { Use the data in the Working FTP Site List TList }
  168.           with PNewsGroupRecord(
  169.            TheWorkingNRCSL.Items[ ListBox2.ItemIndex ] )^ do
  170.           begin
  171.               Edit1.Text := GName;
  172.               Edit2.Text := GRealName;
  173.               if GSubScribed then Edit3.Text := 'Subscribed' else
  174.                Edit3.Text := 'UnSubscribed';
  175.           end;
  176.         end;
  177.   end;
  178. end;
  179.  
  180. { This procedure saves the newly modified list of stuff to its base }
  181. procedure TCCICInfoDlg.BitBtn1Click(Sender: TObject);
  182. var Counter_1  : Integer;            { Loop counter        }
  183.     ThePointer : PConnectionsRecord; { Generic TCR Pointer }
  184.     TheNGRecord : PNewsGroupRecord;
  185. begin
  186.   { Use the tag vector to find out what to do }
  187.   case Tag of
  188.     2 : begin { Do FTP Site List }
  189.           { dispose the old FTP site list's pointers }
  190.           for Counter_1 := 0 to TheFTPSiteList.Count - 1 do
  191.           begin
  192.             Dispose( PConnectionsRecord( TheFTPSiteList.Items[ Counter_1 ] ));
  193.           end;
  194.           { Clear the lists }
  195.           TheFTPSiteList.Clear;
  196.           CCInetCCForm.ComboBox1.Clear;
  197.           { Add the new info }
  198.           for Counter_1 := 0 to TheWorkingFTPSL.Count - 1 do
  199.           begin
  200.             { Create a new pointer }
  201.             New( ThePointer );
  202.             { Move the data into it }
  203.             ThePointer^ :=
  204.              PConnectionsRecord( TheWorkingFTPSL.Items[ Counter_1 ] )^;
  205.             { Add the item }
  206.             TheFTPSiteList.Add( ThePointer );
  207.             CCINetCCForm.ComboBox1.Items.Add( PConnectionsRecord(
  208.              TheFTPSiteList.Items[ Counter_1 ] )^.CProfile );
  209.           end;
  210.           CCINetCCForm.ComboBox1.ItemIndex := 0;
  211.         end;
  212.     4 : begin { Do NNTP Site List }
  213.           { dispose the old FTP site list's pointers }
  214.           for Counter_1 := 0 to TheNewsServerList.Count - 1 do
  215.           begin
  216.             Dispose( PConnectionsRecord( TheNewsServerList.Items[ Counter_1 ] ));
  217.           end;
  218.           { Clear the lists }
  219.           TheNewsServerList.Clear;
  220.           CCInetCCForm.ComboBox1.Clear;
  221.           { Add the new info }
  222.           for Counter_1 := 0 to TheWorkingNSSL.Count - 1 do
  223.           begin
  224.             { Create a new pointer }
  225.             New( ThePointer );
  226.             { Move the data into it }
  227.             ThePointer^ :=
  228.              PConnectionsRecord( TheWorkingNSSL.Items[ Counter_1 ] )^;
  229.             { Add the item }
  230.             TheNewsServerList.Add( ThePointer );
  231.             CCINetCCForm.ComboBox1.Items.Add( PConnectionsRecord(
  232.              TheNewsServerList.Items[ Counter_1 ] )^.CProfile );
  233.           end;
  234.           CCINetCCForm.ComboBox1.ItemIndex := 0;
  235.         end;
  236.     5 : begin { Do NNTP Newsgroups List }
  237.           { dispose the old NG list's pointers }
  238.           for Counter_1 := 0 to TheNewsRCList.Count - 1 do
  239.           begin
  240.             Dispose( PNewsGroupRecord( TheNewsRCList.Items[ Counter_1 ] ));
  241.           end;
  242.           { Clear the lists }
  243.           TheNewsRCList.Clear;
  244.           { Add the new info }
  245.           for Counter_1 := 0 to TheWorkingNRCSL.Count - 1 do
  246.           begin
  247.             { Create a new pointer }
  248.             New( TheNGRecord );
  249.             { Move the data into it }
  250.             TheNGRecord^ :=
  251.              PNewsGroupRecord( TheWorkingNRCSL.Items[ Counter_1 ] )^;
  252.             { Add the item }
  253.             TheNewsRCList.Add( TheNGRecord );
  254.           end;
  255.         end;
  256.   end;
  257.   { Leave }
  258.   Close;
  259. end;
  260.  
  261. { This method cancels any changes made from entries in current setup & exits}
  262. procedure TCCICInfoDlg.BitBtn2Click(Sender: TObject);
  263. var Counter_1  : Integer;            { Loop counter        }
  264.     ThePointer : PConnectionsRecord; { Generic TCR Pointer }
  265.     TheNGRecord : PNewsGroupRecord;
  266. begin
  267.   { Use Tag vector do decide what to reset }
  268.   case Tag of
  269.     2 : begin { Reset FTP Site list }
  270.           { Dispose of all the old pointers }
  271.           for Counter_1 := 0 to TheWorkingFTPSL.Count - 1 do
  272.           begin
  273.             Dispose( PConnectionsRecord( TheWorkingFTPSL.Items[ Counter_1 ] ));
  274.           end;
  275.           { Clear the working list }
  276.           TheWorkingFTPSL.Clear;
  277.           { Clear the listbox }
  278.           ListBox2.Clear;
  279.           { Then rebuild the working list and display listbox }
  280.           for Counter_1 := 0 to TheFTPSiteList.Count - 1 do
  281.           begin
  282.             { Create the record }
  283.             New( ThePointer );
  284.             { Move data in }
  285.             ThePointer^ :=
  286.              PConnectionsRecord( TheFTPSiteList.Items[ Counter_1 ] )^;
  287.             { Add the pointer to the list }
  288.             TheWorkingFTPSL.Add( ThePointer );
  289.             { Add the profile name to the list }
  290.             ListBox2.Items.Add( PConnectionsRecord(
  291.              TheFTPSiteList.Items[ Counter_1 ] )^.CProfile );
  292.           end;
  293.         end;
  294.     4 : begin { Reset NNTP Site list }
  295.           { Dispose of all the old pointers }
  296.           for Counter_1 := 0 to TheWorkingNSSL.Count - 1 do
  297.           begin
  298.             Dispose( PConnectionsRecord( TheWorkingNSSL.Items[ Counter_1 ] ));
  299.           end;
  300.           { Clear the working list }
  301.           TheWorkingNSSL.Clear;
  302.           { Clear the listbox }
  303.           ListBox2.Clear;
  304.           { Then rebuild the working list and display listbox }
  305.           for Counter_1 := 0 to TheNewsServerList.Count - 1 do
  306.           begin
  307.             { Create the record }
  308.             New( ThePointer );
  309.             { Move data in }
  310.             ThePointer^ :=
  311.              PConnectionsRecord( TheNewsServerList.Items[ Counter_1 ] )^;
  312.             { Add the pointer to the list }
  313.             TheWorkingNSSL.Add( ThePointer );
  314.             { Add the profile name to the list }
  315.             ListBox2.Items.Add( PConnectionsRecord(
  316.              TheNewsServerList.Items[ Counter_1 ] )^.CProfile );
  317.           end;
  318.         end;
  319.     5 : begin { Reset NNTP NG list }
  320.           { Dispose of all the old pointers }
  321.           for Counter_1 := 0 to TheWorkingNRCSL.Count - 1 do
  322.           begin
  323.             Dispose( PNewsGroupRecord( TheWorkingNRCSL.Items[ Counter_1 ] ));
  324.           end;
  325.           { Clear the working list }
  326.           TheWorkingNRCSL.Clear;
  327.           { Clear the listbox }
  328.           ListBox2.Clear;
  329.           { Then rebuild the working list and display listbox }
  330.           for Counter_1 := 0 to TheNewsRCList.Count - 1 do
  331.           begin
  332.             { Create the record }
  333.             New( TheNGRecord );
  334.             { Move data in }
  335.             TheNGRecord^ :=
  336.              PNewsGroupRecord( TheNewsRCList.Items[ Counter_1 ] )^;
  337.             { Add the pointer to the list }
  338.             TheWorkingNRCSL.Add( TheNGRecord );
  339.             { Add the profile name to the list }
  340.             ListBox2.Items.Add( PNewsGroupRecord(
  341.              TheNewsRCList.Items[ Counter_1 ] )^.GName );
  342.           end;
  343.         end;
  344.   end;
  345.   { Leave }
  346.   Close;
  347. end;
  348.  
  349. procedure TCCICInfoDlg.Edit4Exit(Sender: TObject);
  350. begin
  351.   { Use tag vector to determine action }
  352.   case Tag of
  353.     2 : begin
  354.           { If Edit4 is modified then mangle pw }
  355.           if Edit4.Modified then
  356.           begin
  357.             { Save pw in either case, but mangle if masked }
  358.             case PasswordControlVector of
  359.               1 : CurrentRealPWString := Edit4.Text;
  360.               2 : begin
  361.                     CurrentRealPWString := Edit4.Text;
  362.                     Edit4.Text := '***********';
  363.                   end;
  364.             end;
  365.           end;
  366.         end;
  367.   end;
  368. end;
  369.  
  370. { Add button; do various add actions }
  371. procedure TCCICInfoDlg.Button2Click(Sender: TObject);
  372. var ThePointer  : PConnectionsRecord; { PCR Pointer }
  373.     TheNGRecord : PNewsGroupRecord;
  374.     TempList    : TList;
  375. begin
  376.   { Tag vector control as usual }
  377.   case Tag of
  378.     2 : begin { add new FTP site list entry }
  379.           { Creat new PCR pointer }
  380.           New( ThePointer );
  381.           { Add in the data from the text fields }
  382.           with ThePointer^ do
  383.           begin
  384.             CProfile   := Edit1.Text;
  385.             CIPAddress := Edit2.Text;;
  386.             CUserName  := Edit3.Text;
  387.             { Put in the real pw string }
  388.             CPassword  := CurrentRealPWString;
  389.             CStartDir  := Edit5.Text;
  390.           end;
  391.           { Add pointer to working list }
  392.           TheWorkingFTPSL.Add( ThePointer );
  393.           { Add it to the listbox }
  394.           ListBox2.Items.Add( ThePointer^.CProfile );
  395.           { And set the pointer to it }
  396.           ListBox2.ItemIndex := ListBox2.Items.Count - 1;
  397.         end;
  398.     4 : begin { add new NNTP site list entry }
  399.           { Creat new PCR pointer }
  400.           New( ThePointer );
  401.           { Add in the data from the text fields }
  402.           with ThePointer^ do
  403.           begin
  404.             CProfile   := Edit1.Text;
  405.             CIPAddress := Edit2.Text;;
  406.             CUserName  := '';
  407.             CPassword  := '';
  408.             CStartDir  := '';
  409.           end;
  410.           { Add pointer to working list }
  411.           TheWorkingNSSL.Add( ThePointer );
  412.           { Add it to the listbox }
  413.           ListBox2.Items.Add( ThePointer^.CProfile );
  414.           { And set the pointer to it }
  415.           ListBox2.ItemIndex := ListBox2.Items.Count - 1;
  416.         end;
  417.     5 : begin { add new NNTP newsgroup list entry }
  418.           { Creat new PCR pointer }
  419.           New( TheNGRecord );
  420.           TempList := TList.Create;
  421.           { Add in the data from the text fields }
  422.           with TheNGRecord^ do
  423.           begin
  424.             GName     := Edit1.Text;
  425.             GRealName := Edit2.Text;;
  426.             if Edit3.Text = 'UnSubscribed' then GSubscribed := false else
  427.              GSubScribed := true;
  428.             GLowest              := 0;
  429.             GHighest             := 0;
  430.             GTotalNew            := 0;
  431.             GTotalAvailable      := 0;
  432.             GLowestAvailable     := 0;
  433.             GHighestAvailable    := 0;
  434.             GPostable            := true;
  435.             GTotalArticles       := 0;
  436.             GTotalUnReadArticles := 0;
  437.             GIDNumber            := TheWorkingNRCSL.Count + 1;
  438.             GFileName            := 'NL' + IntToStr( WhichServer ) + 'G' +
  439.                                     IntToStr( GIDNumber) + '.NGR';
  440.             GLTag                := Longint( TempList );
  441.           end;
  442.           { Add pointer to working list }
  443.           TheWorkingNRCSL.Add( TheNGRecord );
  444.           { Add it to the listbox }
  445.           ListBox2.Items.Add( TheNGRecord^.GName );
  446.           { And set the pointer to it }
  447.           ListBox2.ItemIndex := ListBox2.Items.Count - 1;
  448.         end;
  449.   end;
  450. end;
  451.  
  452. { This is the modify button }
  453. procedure TCCICInfoDlg.Button3Click(Sender: TObject);
  454. begin
  455.   { Use Tag vector as usual }
  456.   case Tag of
  457.     2 : begin
  458.           { if nothing to modify the exit }
  459.           if ListBox2.ItemIndex = -1 then exit;
  460.           { get record of current listbox pointer & put in data }
  461.           with PConnectionsRecord(
  462.            TheWorkingFTPSL.Items[ ListBox2.ItemIndex ] )^ do
  463.           begin
  464.             CProfile   := Edit1.Text;
  465.             CIPAddress := Edit2.Text;;
  466.             CUserName  := Edit3.Text;
  467.             { Put in the real pw string }
  468.             CPassword  := CurrentRealPWString;
  469.             CStartDir  := Edit5.Text;
  470.           end;
  471.           { Make sure the display matches the edit control }
  472.           ListBox2.Items[ ListBox2.ItemIndex ] := Edit1.Text;
  473.         end;
  474.     4 : begin
  475.           { if nothing to modify the exit }
  476.           if ListBox2.ItemIndex = -1 then exit;
  477.           { get record of current listbox pointer & put in data }
  478.           with PConnectionsRecord(
  479.            TheWorkingNSSL.Items[ ListBox2.ItemIndex ] )^ do
  480.           begin
  481.             CProfile   := Edit1.Text;
  482.             CIPAddress := Edit2.Text;
  483.             CUserName  := '';
  484.             CPassword  := '';
  485.             CStartDir  := '';
  486.           end;
  487.           { Make sure the display matches the edit control }
  488.           ListBox2.Items[ ListBox2.ItemIndex ] := Edit1.Text;
  489.         end;
  490.     5 : begin
  491.           { if nothing to modify the exit }
  492.           if ListBox2.ItemIndex = -1 then exit;
  493.           { get record of current listbox pointer & put in data }
  494.           with PNewsGroupRecord(
  495.            TheWorkingNRCSL.Items[ ListBox2.ItemIndex ] )^ do
  496.           begin
  497.             GName     := Edit1.Text;
  498.             GRealName := Edit2.Text;;
  499.             if Edit3.Text = 'UnSubscribed' then GSubscribed := false else
  500.              GSubScribed := true;
  501.           end;
  502.           { Make sure the display matches the edit control }
  503.           ListBox2.Items[ ListBox2.ItemIndex ] := Edit1.Text;
  504.         end;
  505.   end;
  506. end;
  507.  
  508. { This is the delete button }
  509. procedure TCCICInfoDlg.Button4Click(Sender: TObject);
  510. var MessageString : String; { String holder }
  511. begin
  512.   { Use tag control vector }
  513.   case Tag of
  514.     2 : begin
  515.           { If nothing to delete then leave }
  516.           if Listbox2.Itemindex = -1 then exit;
  517.           { Set up display }
  518.           MessageString := 'Delete Entry ' + Edit1.Text + '?';
  519.           { Display message box and get result }
  520.           if MessageDlg( MessageString , mtConfirmation , mbYesNoCancel , 0 )
  521.            = mrYes then
  522.           begin
  523.             { if ok delete then remove item from working sl }
  524.             TheWorkingFTPSL.Delete( ListBox2.ItemIndex );
  525.             { delete from listbox }
  526.             ListBox2.Items.Delete( ListBox2.ItemIndex );
  527.             { If nothing left set itemindex and clear edits }
  528.             if ListBox2.Items.Count = 0 then
  529.             begin
  530.               ListBox2.ItemIndex := -1;
  531.               Edit1.Text := '';
  532.               Edit2.Text := '';
  533.               Edit3.Text := '';
  534.               Edit4.Text := '';
  535.               Edit5.Text := '';
  536.             end
  537.             else
  538.             begin
  539.               { Reset listbox pointer }
  540.               ListBox2.ItemIndex  := 0;
  541.               { and reset display to new item }
  542.               with PConnectionsRecord(
  543.                TheWorkingFTPSL.Items[ ListBox2.ItemIndex ] )^ do
  544.               begin
  545.                 Edit1.Text := CProfile;
  546.                 Edit2.Text := CIPAddress;
  547.                 Edit3.Text := CUserName;
  548.                 CurrentRealPWString := CPassword;
  549.                 case PasswordControlVector of
  550.                   1 : Edit4.Text := CPassword;
  551.                   2 : Edit4.Text := '**********';
  552.                 end;
  553.                 Edit5.Text := CStartDir;
  554.               end;
  555.             end;
  556.           end;
  557.         end;
  558.     4 : begin
  559.           { If nothing to delete then leave }
  560.           if Listbox2.Itemindex = -1 then exit;
  561.           { Set up display }
  562.           MessageString := 'Delete Entry ' + Edit1.Text + '?';
  563.           { Display message box and get result }
  564.           if MessageDlg( MessageString , mtConfirmation , mbYesNoCancel , 0 )
  565.            = mrYes then
  566.           begin
  567.             { if ok delete then remove item from working sl }
  568.             TheWorkingNSSL.Delete( ListBox2.ItemIndex );
  569.             { delete from listbox }
  570.             ListBox2.Items.Delete( ListBox2.ItemIndex );
  571.             { If nothing left set itemindex and clear edits }
  572.             if ListBox2.Items.Count = 0 then
  573.             begin
  574.               ListBox2.ItemIndex := -1;
  575.               Edit1.Text := '';
  576.               Edit2.Text := '';
  577.               Edit3.Text := '';
  578.               Edit4.Text := '';
  579.               Edit5.Text := '';
  580.             end
  581.             else
  582.             begin
  583.               { Reset listbox pointer }
  584.               ListBox2.ItemIndex  := 0;
  585.               { and reset display to new item }
  586.               with PConnectionsRecord(
  587.                TheWorkingNSSL.Items[ ListBox2.ItemIndex ] )^ do
  588.               begin
  589.                 Edit1.Text := CProfile;
  590.                 Edit2.Text := CIPAddress;
  591.               end;
  592.             end;
  593.           end;
  594.         end;
  595.     5 : begin
  596.           { If nothing to delete then leave }
  597.           if Listbox2.Itemindex = -1 then exit;
  598.           { Set up display }
  599.           MessageString := 'Delete Entry ' + Edit1.Text + '?';
  600.           { Display message box and get result }
  601.           if MessageDlg( MessageString , mtConfirmation , mbYesNoCancel , 0 )
  602.            = mrYes then
  603.           begin
  604.             { if ok delete then remove item from working sl }
  605.             TheWorkingNRCSL.Delete( ListBox2.ItemIndex );
  606.             { delete from listbox }
  607.             ListBox2.Items.Delete( ListBox2.ItemIndex );
  608.             { If nothing left set itemindex and clear edits }
  609.             if ListBox2.Items.Count = 0 then
  610.             begin
  611.               ListBox2.ItemIndex := -1;
  612.               Edit1.Text := '';
  613.               Edit2.Text := '';
  614.               Edit3.Text := '';
  615.               Edit4.Text := '';
  616.               Edit5.Text := '';
  617.             end
  618.             else
  619.             begin
  620.               { Reset listbox pointer }
  621.               ListBox2.ItemIndex  := 0;
  622.               { and reset display to new item }
  623.               with PNewsGroupRecord(
  624.                TheWorkingNRCSL.Items[ ListBox2.ItemIndex ] )^ do
  625.               begin
  626.                 Edit1.Text := GName;
  627.                 Edit2.Text := GRealName;
  628.                 if not GSubscribed then Edit3.Text := 'UnSubscribed' else
  629.                  Edit3.Text := 'SubScribed';
  630.               end;
  631.             end;
  632.           end;
  633.         end;
  634.   end;
  635. end;
  636.  
  637. procedure TCCICInfoDlg.ListBox1DblClick(Sender: TObject);
  638. begin
  639.   case Tag of
  640.     5 : begin
  641.           if ListBox1.ItemIndex <> -1 then
  642.            Edit2.Text := ListBox1.Items[ Listbox1.ItemIndex ];
  643.         end;
  644.   end;
  645. end;
  646.  
  647. end.
  648.