Question:
I have this procedure in my project
procedure DocumentComplete(ASender: TObject; const pDisp: IDispatch; const URL: OleVariant);
Now I need to use it in a loop passing the count variable. I tried as follows:
procedure DocumentComplete(ASender: TObject; const pDisp: IDispatch; const URL: OleVariant; var contagem : Integer);
But it turns out that when I pass the variable, the procedure also asks for the other Sender: TObject; const pDisp: IDispatch; const URL: OleVariant
parameters Sender: TObject; const pDisp: IDispatch; const URL: OleVariant
which, between us, I have no idea what they are.
I'm a hobbyist and I'm doing a little project for a friend, please help me out.
I can't know what to do, I'm sure it's something simple but I've searched all day and I haven't found the solution. What do I put in place of these parameters?
Edit: This is the part where I use the loop to call the procedure, each time it is called a different browser is used.
procedure TForm1.Button1Click(Sender: TObject);
begin
for contagem := 1 to StrtoInt(Edit1.Text) do
begin
browsers[contagem].OnDocumentComplete := nil;
NavigationOK := true;
browsers[contagem].OnDocumentComplete := DocCompleteA;
browsers[contagem].Navigate
('http://****/index.php?id=entrar');
end;
end;
Creation of browsers:
procedure TForm1.Button2Click(Sender: TObject);
begin
for contagem := 1 to StrToInt(Edit1.Text) do
begin
campos[contagem] := TEdit.Create(self);
campos[contagem].Parent := Form1;
campos[contagem].Show;
campos[contagem].Left := 150;
campos[contagem].Top := 350;
campos[contagem].Width := 600;
browsers[contagem] := TWebBrowser.Create(Form1);
TWinControl(browsers[contagem]).Parent := Form1;
browsers[contagem].Align := alTop;
browsers[contagem].Height := 300;
browsers[contagem].Show;
browsers[contagem].Silent := true;
end;
end;
Answer:
try like this
procedure TForm1.Button1Click(Sender: TObject);
var
iCont,iContagem: Integer;
begin
iCont := StrToInt(Edit1.Text);
for iContagem := 0 to iCont-1 do
begin
browsers[iContagem].OnDocumentComplete := nil;
NavigationOK := true;
browsers[iContagem].OnDocumentComplete := DocCompleteA;
browsers[iContagem].Navigate
('http://****/index.php?id=entrar');
end;
end;