5
I have this project
procedure DocumentComplete(ASender: TObject; const pDisp: IDispatch; const URL: OleVariant);
Now I need to use it in a loop by passing the count variable. I tried it 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, Procedure also asks for the other parameters Sender: TObject; const pDisp: IDispatch; const URL: OleVariant
that, between you and me, I have no idea what they are.
I program for a hobby and I’m doing a little project for a friend, please help me.
I can’t figure out what to do, I’m sure it’s something simple but I’ve been researching all day and I haven’t found a solution. What step in place of these parameters?.
Edit: This is the part where I use the loop to call the Procedure, each time it is called is a different browser 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;
But is this a single-component event... if it’s a post here which one you’re using?.
– Jefferson Rudolf
@Yes, Ondocumentcomplete event of a Webbrowser, but this Webbrowser is created in Runtime, so I need the loop. The process will be executed once for each browser created
– Marciel Fonseca
As you are handling this loop, you can post the source code in the question, so it would help the forum staff to better understand and help you. Hugs
– Jefferson Rudolf
@Jeffersonrudolf changed the question with the part where I call the loop with the file inside. If it’s not enough I can post the whole code. Sorry for the mess in formatting but I always mess around in this part rsrs
– Marciel Fonseca
for each browser created, you treat a different way in the Doccompletaa function?... or it is the same for all browser created. If so, it is not necessary to pass a counting variable as parameter, for each loop it executes the event, got it... anything but talk
– Jefferson Rudolf
@Jeffersonrudolf Same task for each browser, the problem is that without passing the variable occurs an error of those complicated to know (rsrs), "Violation 0x00000" <- similar to this. Manually placing the number (browsers[1]...) makes the error stop, which made me assume that the error is being in the variable that is not being passed
– Marciel Fonseca
There is a way to do exactly what you are asking, but I think there would be a less radical solution to your problem. To do what you are asking, simply create a class by inheriting from Twebbrowser, and overwrite the Property that receives the Ondocumentcomplete method by adding its new parameter. If you can’t solve the problem, we can try this solution.
– Victor Tadashi