We help IT Professionals succeed at work.
Get Started

Problems with processbar

QC20N
QC20N asked
on
415 Views
Last Modified: 2013-11-23
When I run this code the progressbar just show me the end result. I want it to show me everytime it has handle a request.

I hope this is a simple and eay question.
procedure TFrmMain.Button3Click(Sender: TObject);
var List, ItemList, SubList: TStrings; I, n: Integer;
  aMan: string;
begin
  IdSMTP1.Host := 'mail.firm.org';
  ItemList := TStringList.Create;
  try
    List := TStringList.Create;
    try
      for I := 0 to Memo2.Lines.Count-1 do
      begin
        ItemList.CommaText := Memo2.Lines[I];
        aMan := ItemList[4];
        n := List.IndexOf(aMan);
        if n = -1 then
        begin
          SubList := TStringList.Create;
          n := List.AddObject(aMan, SubList);
        end;
        TStringList(List.Objects[n]).Add(ItemList[0] + ' ' + ItemList[1]);
      end;
      IdMessage1.From.Address := 'Automail@firm.com';
      IdMessage1.Subject := Edit1.Text;
      ProgressBar1.Max := list.Count;
      ProgressBar1.Step := round(100 / progressbar1.Max);
      for I := 0 to List.Count-1 do
      begin
        IdMessage1.Body.Clear;
        IdMessage1.Recipients.Add.Address := '';
        IdMessage1.Subject := 'Manager ' + List[I];
        IdMessage1.Body.AddStrings(memo1.Lines);
        IdMessage1.Body.Add('');
        IdMessage1.Body.Add('Manager ' + List[I]);
        IdMessage1.Body.Add('----------------------');
        IdMessage1.Body.AddStrings(TStringList(List.Objects[I]));
        IdMessage1.Body.Add('');
        IdMessage1.Body.Add('');
        IdSMTP1.Connect;
        IdSMTP1.Send(IdMessage1);
        IdSMTP1.Disconnect();
        ProgressBar1.Stepit;
        Application.Processmessages;
      end;
    finally
      FreeAndNil(List);
    end;
  finally
    FreeAndNil(ItemList);
  end;
  Edit1.Clear;
  memo1.Clear;
end;

Open in new window

Comment
Watch Question
This problem has been solved!
Unlock 1 Answer and 9 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE