Autor Beitrag
oOXTCOo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 141

Windows XP Prof. 3
Delphi 7
BeitragVerfasst: Mo 25.10.04 00:13 
Hallo DF!!!

Ich habe ein Problem mit der Progressbar.

Ich möchte wenn ich eMails abrufe oder sende eine Progressbar haben die mir den Status anzeigt wie weit er denn mit dem senden ist. Aber nach lange suchen in diesem und anderen Forums und selbst versuchen hab ich es einfach noch immer nicht geschafft ausser das sich die Progressbar nach dem senden aufeinmal komplett füllt.

Darum brauche ich eure Hilfe.

Im moment kann man damit nur senden.

Achja ich habe die Komponete von Indy 9 "Tidsmtp" und "TidMessage" verwendet


Hier der Quellcode:

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, IdMessage, IdBaseComponent, IdComponent,
  IdTCPConnection, IdTCPClient, IdMessageClient, IdSMTP, ComCtrls, ImgList,
  ExtCtrls;

type
  TForm1 = class(TForm)
    SMTP: TIdSMTP;
    IdMsgSend: TIdMessage;
    Button1: TButton;
    Memo1: TMemo;
    edtsubject: TEdit;
    useremail: TEdit;
    tosend: TEdit;
    Username: TEdit;
    passwort: TEdit;
    von: TEdit;
    cbopriority: TComboBox;
    Button2: TButton;
    Button3: TButton;
    OpenDialog1: TOpenDialog;
    LVFiles: TListView;
    ProgressBar1: TProgressBar;
    Button4: TButton;
    Label1: TLabel;
     procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure passwortStartDock(Sender: TObject;
      var DragObject: TDragDockObject);
    procedure passwortClick(Sender: TObject);
    procedure tosendClick(Sender: TObject);
    procedure tosendStartDock(Sender: TObject;
      var DragObject: TDragDockObject);
    procedure edtsubjectClick(Sender: TObject);
    procedure useremailClick(Sender: TObject);
    procedure vonClick(Sender: TObject);
    procedure UsernameClick(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}




procedure TForm1.Button1Click(Sender: TObject);
begin
       with IdMsgSend do
      begin
    //  progressbar1.position:=0;
         Body.Assign(Memo1.Lines);
         From.Text := Von.text;
         ReplyTo.EMailAddresses := 'speedfreak@gmx.at'//muss ich noch ändern
         Recipients.EMailAddresses := tosend.text; { To: header }
         Subject := edtSubject.Text; { Subject: header }
         Priority := TIdMessagePriority(cboPriority.ItemIndex); { Message Priority }


            begin {indicate that there is no receipt recipiant}
               ReceiptRecipient.Text := '';

  {authentication settings}

       SMTP.AuthenticationType := atNone;
       SMTP.AuthenticationType := atLogin; {Simple Login}
   end;
   SMTP.Username := username.text;
   SMTP.Password := passwort.text;

   {General setup}
   SMTP.Host := 'mail.gmx.net';  // wird auch noch geändert 
   SMTP.Port := 25;

   {now we send the message}
   SMTP.Connect;
   try
      SMTP.Send(IdMsgSend);

   // Progressbar      Progressbar1.Position

     //   ProgressBar1.stepby(smtp.sendbuffersize);
     //  ProgressBar1.step := smtp.recvbuffersize;
      ProgressBar1.StepBy(smtp.RecvBufferSize div 100);
    //progressbar1.position :=
  //  ProgressBar1.Position := AWorkCount;
       application.ProcessMessages;

 //    progressbar1.position := smtp.recvbuffersize div smtp.sendBufferSize * 50;
        application.processmessages;
   finally
      SMTP.Disconnect;
   end;
end;

end;

procedure TForm1.FormCreate(Sender: TObject);
begin
   cboPriority.ItemIndex := Ord(IdMsgSend.Priority);
end;

procedure TForm1.passwortStartDock(Sender: TObject;
  var DragObject: TDragDockObject);
begin
  passwort.Clear;
end;

procedure TForm1.passwortClick(Sender: TObject);
begin
passwort.selectall;
end;

procedure TForm1.tosendClick(Sender: TObject);
begin
 tosend.selectall;
end;

procedure TForm1.tosendStartDock(Sender: TObject;
  var DragObject: TDragDockObject);
begin
  tosend.selectall;
end;

procedure TForm1.edtsubjectClick(Sender: TObject);
begin
  edtsubject.selectall;
end;

procedure TForm1.useremailClick(Sender: TObject);
begin
  useremail.selectall;
end;

procedure TForm1.vonClick(Sender: TObject);
begin
   von.selectall;
end;

procedure TForm1.UsernameClick(Sender: TObject);
begin
  username.selectall;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
memo1.Clear;
end;

procedure TForm1.Button3Click(Sender: TObject);
var li: TListItem;
   idx: Integer;
begin
      if OpenDialog1.Execute then
      begin
         TIdAttachment.Create(IdMsgSend.MessageParts, OpenDialog1.FileName);
       //  ResetAttachmentListView;

        lvFiles.Items.Clear;
   for idx := 0 to Pred(IdMsgSend.MessageParts.Count) do
      begin
         li := lvFiles.Items.Add;
         if IdMsgSend.MessageParts.Items[idx] is TIdAttachment then
            begin
               li.ImageIndex := 0;
               li.Caption := TIdAttachment(IdMsgSend.MessageParts.Items[idx]).Filename;
               li.SubItems.Add(TIdAttachment(IdMsgSend.MessageParts.Items[idx]).ContentType);
            end
         else
            begin
               li.ImageIndex := 1;
               li.Caption := IdMsgSend.MessageParts.Items[idx].ContentType;
            end;

      end;
end;
    end;
procedure TForm1.Button4Click(Sender: TObject);
begin
progressbar1.position:= 0;
end;



end.



Für jede Hilfe bin ich sehr dankbar.


mfg. hari
.Chef
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1112



BeitragVerfasst: Mo 25.10.04 00:17 
So aufn ersten Blick würde ich sagen es liegt daran, dass du nur einmal im Laufe des Programms eine ProgressBar-Zuweisung aufrufst.

Ach ja, es dient enorm der Übersicht, wenn du nur entscheidende Abschnitte eines Quelltextes postest.

Gruß,
Jörg

_________________
Die Antworten auf die 5 häufigsten Fragen:
1. Copy(), Pos(), Length() --- 2. DoubleBuffered:=True; --- 3. Application.ProcessMessages bzw. TThread --- 4. ShellExecute() --- 5. Keine Vergleiche von Real-Typen mit "="!
oOXTCOo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 141

Windows XP Prof. 3
Delphi 7
BeitragVerfasst: Mo 25.10.04 00:46 
und wie mache ich das? (Totaler-Anfänger). :(