Rubrica (Delphi 7)

Pubblicità

MrCamarium

Utente Attivo
Messaggi
24
Reazioni
1
Punteggio
25
con un codice riuscivo a visualizzare in un label un nominativo associato ad un server, ad esempio mail.libero.it=infostrada, mail.libero.it compariva in un Tedit e infostrada in un label. Adesso questo codice l'ho modificato per ottenere lo stesso risultato anche per una rubrica ma non vuole funzionare. Posto il codice:
Codice:
unit Email;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, RzPanel, StdCtrls, Buttons, Mask, ToolWin,
  TLHelp32, Printers,
  ComCtrls, ScktComp,
  XPStyleActnCtrls, ActnList, ActnMan, Menus, RzDlgBtn, jpeg, StdActns, ExtActns,
  RzButton, WinTypes, ShellAPI, mmSystem, Sockets, WinInet, RzShellDialogs,
  RzRadGrp, RzEdit, RzStatus, Registry, RzLabel, RzDBLbl,
  RzRadChk, StrUtils, RzCmboBx, RzSpnEdt;

type
  TForm1 = class(TForm)
    Lista: TRzComboBox;
    Conta: TLabel;
    GroupBox2: TGroupBox;
    Label8: TLabel;
    Server: TRzComboBox;
    NomeServer: TLabel;
    Pannello1: TPanel;
    Contatto: TLabel;
    Label1: TLabel;
    Label2: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure ServerChangeClik(Sender: TObject);
    procedure RubricaChangeClik(Sender: TObject);
    procedure CaricaClick(Sender: TObject);

  private

  public
    { Public declarations }
    end;

var
  Form1: TForm1;
  slConfig: TStrings;
const
  CurrentState : byte = 1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
//Carica i contatti
  CaricaClick(Sender);
      end;

//Info Lista Server
procedure TForm1.ServerChangeClik(Sender: TObject);
begin
 NomeServer.Caption := slConfig.Values[Server.Text];
end;

//Info Lista Rubrica
procedure TForm1.RubricaChangeClik(Sender: TObject);
begin
 Contatto.Caption := slConfig.Values
[Lista.Text];
end;

procedure TForm1.CaricaClick(Sender: TObject);
var
CLines, I : Integer;
begin
  slConfig := TStringList.Create;
  slConfig.LoadFromFile('Rubrica.ini');
for I := 0 to pred(slConfig.Count) do Lista.Items.Add(slConfig.Names[i]);
  slConfig.LoadFromFile('Server.ini');
for I := 0 to pred(slConfig.Count) do Server.Items.Add(slConfig.Names[i]);
  CLines := 0;
for I := 0 to  Lista.Items.Count - 1 do
begin
  CLines := CLines + 1;
end;
  Conta.Caption := 'Ci Sono '+ IntToStr(CLines) + ' Contatti!';
  CLines := 0;
for I := 0 to  Server.Items.Count - 1 do
begin
  CLines := CLines + 1;
end;
  Label1.Caption := 'Ci Sono '+ IntToStr(CLines) + ' Server!';
end;

end.
Come posso procedere?
 
Ho fatto in questo modo:
cedure RubricaChangeClik(Sender: TObject);

  1. procedure FormDestroy(Sender: TObject);
  2. procedure ComboChange(Sender: TObject);
  3. private
  4. sPath: String;
  5. Function Carica(oCombo: TRzComboBox; sFileName:String; Var oLista:TStringList): Integer;
  6. public
  7. oListaPublic: TStringList;
  8. { Public declarations }
  9. end;
  10. var
  11. Form1: TForm1;
  12. implementation
  13. {$R *.dfm}
  14. Function TForm1.Carica(oCombo: TComboBox; sFileName:String; Var oLista:TStringList): Integer;
  15. var I : Integer;
  16. slConfig: TStringList;
  17. begin
  18. Result := -1;
  19. slConfig := TStringList.Create;
  20. Try
  21. slConfig.LoadFromFile(sFileName);
  22. For I := 0 to pred(slConfig.Count) do
  23. oCombo.Items.Add(slConfig.Names[i]);
  24. finally
  25. oLista. Text := oLista. Text + slConfig.Text;
  26. Result := slConfig.Count;
  27. slConfig.Free;
  28. end;
  29. end;
  30. procedure TForm1.FormCreate(Sender: TObject);
  31. begin
  32. oListaPublic := TStringList.Create;
  33. sPath:= ExtractFilePath(Application.ExeName);
  34. Conta.Caption := 'Ci Sono '+ IntToStr(Carica(Lista, sPath + '\Rubrica.Ini', oListaPublic)) + ' Contatti!';
  35. Label1.Caption := 'Ci Sono '+ IntToStr(Carica(Server,sPath + '\Server.Ini', oListaPublic)) + ' Server!';
  36. end;
  37. procedure TForm1.FormDestroy(Sender: TObject);
  38. begin
  39. oListaPublic.Free;
  40. end;
  41. procedure TForm1.ComboChange(Sender: TObject);
  42. begin
  43. case (Sender as TcomboBox).Tag of
  44. 1: NomeServer.Caption := oListaPublic.Values[(Sender as TcomboBox).Text];
  45. 2: Contatto.Caption := oListaPublic.Values[(Sender as TcomboBox).Text];
  46. end;
  47. end;
  48. end.



Mi da questo errore:
[Error] Email.pas(42): Declaration of 'Carica' differs from previous declaration
in questa riga:
Codice sorgente - presumibilmente Delphi

  1. Function TForm1.Carica(oCombo: TComboBox; sFileName:String; Var oLista:TStringList): Integer;



Perchè
dubbioso.gif
e come posso risolvere
dubbioso.gif
 
Ecco la soluzione passatami da Goblin:
Codice:
    unit Email;
     
    interface
     
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, RzCmboBx, ExtCtrls;
     
    type
      TForm1 = class(TForm)
        Lista: TRzComboBox;
        Conta: TLabel;
        GroupBox2: TGroupBox;
        Label8: TLabel;
        Server: TRzComboBox;
        NomeServer: TLabel;
        Pannello1: TPanel;
        Contatto: TLabel;
        Label1: TLabel;
        Label2: TLabel;
        procedure FormCreate(Sender: TObject);
        procedure FormDestroy(Sender: TObject);
        procedure ComboChange(Sender: TObject);
        procedure ServerChange(Sender: TObject);
        procedure ListaChange(Sender: TObject);
     
      private
      sPath: String;
        Function Carica(oCombo: TRzComboBox; sFileName:String; Var oLista:TStringList): Integer;
      public
        oListaPublic: TStringList;
        { Public declarations }
        end;
     
    var
      Form1: TForm1;
     
    implementation
     
    {$R *.dfm}
     
    Function TForm1.Carica(oCombo: TRzComboBox; sFileName:String; Var oLista:TStringList): Integer;
    var I : Integer;
        slConfig: TStringList;
    begin
      Result := -1;
      slConfig := TStringList.Create;
      Try
        slConfig.LoadFromFile(sFileName);
        For I := 0 to pred(slConfig.Count) do
           oCombo.Items.Add(slConfig.Names[i]);
      finally
        oLista. Text := oLista. Text + slConfig.Text;
        Result := slConfig.Count;
        slConfig.Free;
      end;
    end;
     
    procedure TForm1.FormCreate(Sender: TObject);
    begin
      oListaPublic := TStringList.Create;
      sPath:= ExtractFilePath(Application.ExeName);
      Conta.Caption := 'Ci Sono '+ IntToStr(Carica(Lista, sPath + '\Rubrica.Ini', oListaPublic)) + ' Contatti!';
      Label1.Caption := 'Ci Sono '+ IntToStr(Carica(Server,sPath + '\Server.Ini', oListaPublic)) + ' Server!';
    end;
     
    procedure TForm1.FormDestroy(Sender: TObject);
    begin
      oListaPublic.Free;
    end;
     
    procedure TForm1.ComboChange(Sender: TObject);
    begin
      case (Sender as TRzComboBox).Tag of
       1: NomeServer.Caption := oListaPublic.Values[(Sender as TRzComboBox).Text];
       2: Contatto.Caption := oListaPublic.Values[(Sender as TRzComboBox).Text];
      end;
    end;
     
    procedure TForm1.ServerChange(Sender: TObject);
    begin
      NomeServer.Caption := oListaPublic.Values[Server.Text];
    end;
     
    procedure TForm1.ListaChange(Sender: TObject);
    begin
      Contatto.Caption := oListaPublic.Values
[Lista.Text];
    end;
     
    end.
 
Pubblicità
Pubblicità
Indietro
Top